Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » AJDT » inject default constructor and round it
inject default constructor and round it [message #57390] Thu, 13 October 2005 10:43 Go to next message
Maciej is currently offline Maciej
Messages: 2
Registered: July 2009
Junior Member
Hi, here is my problem:
I have interface which does not have default constructor.

public class NotYetABean {
public NotYetABean(Long id) {}

public class Factory {
public NotYetABean newInstance() { }
}
}

I want to add default constructor and then around default constructor
I would like to return Factory.newInstance() instead of call to
default constructor. Is it possible?

I tried:
aspect ConstructorInjection {
public NotYetABean() { this(new Long(1); }
NotYetABean around(): call(NotYeatABean.new()) {
System.out.println("foo");
return Factory.newInstance();
}
}

but it does not work, default constructor is added but around-code is
not called.

Is it possible to write such aspect?

Thank you for any help.

--
GMail::Hamster
jid: hamster@chrome.pl
Re: inject default constructor and round it [message #57621 is a reply to message #57390] Mon, 17 October 2005 13:32 Go to previous message
Sian January is currently offline Sian January
Messages: 83
Registered: July 2009
Member
Hello,

Your syntax was wrong to begin with, however when I corrected it and
attempted to compile it myself I got a NullPointerException so I have
raised a bug to track that -
https://bugs.eclipse.org/bugs/show_bug.cgi?id=112783. When that bug is
fixed you should be able to do the following:

aspect ConstructorInjection {

public NotYetABean.new() {
this(new Long(1));
}

NotYetABean around(): call(NotYeatABean.new()) {
System.out.println("foo");
return Factory.newInstance();
}

}


Sian



hamster wrote:
> Hi, here is my problem:
> I have interface which does not have default constructor.
>
> public class NotYetABean {
> public NotYetABean(Long id) {}
>
> public class Factory {
> public NotYetABean newInstance() { }
> }
> }
>
> I want to add default constructor and then around default constructor
> I would like to return Factory.newInstance() instead of call to
> default constructor. Is it possible?
>
> I tried:
> aspect ConstructorInjection {
> public NotYetABean() { this(new Long(1); }
> NotYetABean around(): call(NotYeatABean.new()) {
> System.out.println("foo");
> return Factory.newInstance();
> }
> }
>
> but it does not work, default constructor is added but around-code is
> not called.
>
> Is it possible to write such aspect?
>
> Thank you for any help.
>
> --
> GMail::Hamster
> jid: hamster@chrome.pl
>
>
Re: inject default constructor and round it [message #590486 is a reply to message #57390] Mon, 17 October 2005 13:32 Go to previous message
Sian January is currently offline Sian January
Messages: 83
Registered: July 2009
Member
Hello,

Your syntax was wrong to begin with, however when I corrected it and
attempted to compile it myself I got a NullPointerException so I have
raised a bug to track that -
https://bugs.eclipse.org/bugs/show_bug.cgi?id=112783 When that bug is
fixed you should be able to do the following:

aspect ConstructorInjection {

public NotYetABean.new() {
this(new Long(1));
}

NotYetABean around(): call(NotYeatABean.new()) {
System.out.println("foo");
return Factory.newInstance();
}

}


Sian



hamster wrote:
> Hi, here is my problem:
> I have interface which does not have default constructor.
>
> public class NotYetABean {
> public NotYetABean(Long id) {}
>
> public class Factory {
> public NotYetABean newInstance() { }
> }
> }
>
> I want to add default constructor and then around default constructor
> I would like to return Factory.newInstance() instead of call to
> default constructor. Is it possible?
>
> I tried:
> aspect ConstructorInjection {
> public NotYetABean() { this(new Long(1); }
> NotYetABean around(): call(NotYeatABean.new()) {
> System.out.println("foo");
> return Factory.newInstance();
> }
> }
>
> but it does not work, default constructor is added but around-code is
> not called.
>
> Is it possible to write such aspect?
>
> Thank you for any help.
>
> --
> GMail::Hamster
> jid: hamster@chrome.pl
>
>
Previous Topic:Problem with Eclipse 3.0.2 and AJDT 1.2.1
Next Topic:Problem with Eclipse 3.0.2 and AJDT 1.2.1
Goto Forum:
  


Current Time: Thu Oct 23 05:23:42 GMT 2014

Powered by FUDForum. Page generated in 0.01543 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software