Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » AspectJ » @DeclareParents
@DeclareParents [message #63097] Thu, 23 March 2006 23:42 Go to next message
Eclipse UserFriend
Originally posted by: skingdon.mmm.com

I am using @AspectJ annotation style development. Thumbs up to whomever
decided to do it this way. I like it. However I think I might be way to
early in trying to use it. @DeclareParents does not appear to be working.
I found this
( http://dev.eclipse.org/mhonarc/lists/aspectj-dev/msg01841.ht ml) posting
and its related messages. I am wondering if this is still not in? Or am I
missing something?

Here is the code I am running. It was taken from
http://static.springframework.org/spring/docs/2.0-m2/referen ce/ataspectj.html
and was slightly modified. It assumes an implementation of a Lockable
interface which has three methods: void lock(), void unlock(), boolean
locked(). It also assumes you have a class (HelloAnnotetedAOP - just a
hello world type class) to weave into.

@Aspect
public class AnnotatedAspect {

@DeclareParents(value="HelloAnnotetedAOP",
defaultImpl=DefaultLockable.class)
public static Lockable mixin;

@Pointcut("execution(* *())")
void anyExecution() {}

@Before(value="anyExecution() && this(mixin)")
public void checkNotLocked(Lockable mixin) {
if (mixin.locked()) System.out.println("Locked!...");
else System.out.println("Not locked!...");
}

@Before("anyExecution()")
public void doBefore() {
System.out.println("Hello before!...");
}

@After("anyExecution()")
public void doAfter() {
System.out.println("Hello after!...");
}


}

This prints out:
Hello before!...
Hello after!...
Re: @DeclareParents [message #63124 is a reply to message #63097] Fri, 24 March 2006 08:21 Go to previous message
Andrew Clement is currently offline Andrew ClementFriend
Messages: 162
Registered: July 2009
Senior Member
Hi Scott,

indeed that message you reference is very old. @DeclareParents is
working and this example from the developers notebook works fine in
current AspectJ:

http://www.eclipse.org/aspectj/doc/released/adk15notebook/at aspectj-itds.html

(are you using a recent dev build or just AspectJ1.5.0?)

Andy.

(ps. you are likely to get more responses if you use the mailing list
rather than this newsgroup.)

Scott wrote:
> I am using @AspectJ annotation style development. Thumbs up to whomever
> decided to do it this way. I like it. However I think I might be way to
> early in trying to use it. @DeclareParents does not appear to be
> working. I found this
> ( http://dev.eclipse.org/mhonarc/lists/aspectj-dev/msg01841.ht ml) posting
> and its related messages. I am wondering if this is still not in? Or am
> I missing something?
> Here is the code I am running. It was taken from
> http://static.springframework.org/spring/docs/2.0-m2/referen ce/ataspectj.html
> and was slightly modified. It assumes an implementation of a Lockable
> interface which has three methods: void lock(), void unlock(), boolean
> locked(). It also assumes you have a class (HelloAnnotetedAOP - just a
> hello world type class) to weave into.
> @Aspect public class AnnotatedAspect {
> @DeclareParents(value="HelloAnnotetedAOP",
> defaultImpl=DefaultLockable.class) public static Lockable mixin;
> @Pointcut("execution(* *())") void anyExecution()
> {} @Before(value="anyExecution() && this(mixin)")
> public void checkNotLocked(Lockable mixin) {
> if (mixin.locked()) System.out.println("Locked!...");
> else System.out.println("Not locked!..."); }
> @Before("anyExecution()") public void doBefore() {
> System.out.println("Hello before!..."); }
> @After("anyExecution()") public void doAfter() {
> System.out.println("Hello after!..."); } }
> This prints out: Hello before!... Hello after!...
Re: @DeclareParents [message #592678 is a reply to message #63097] Fri, 24 March 2006 08:21 Go to previous message
Andrew Clement is currently offline Andrew ClementFriend
Messages: 162
Registered: July 2009
Senior Member
Hi Scott,

indeed that message you reference is very old. @DeclareParents is
working and this example from the developers notebook works fine in
current AspectJ:

http://www.eclipse.org/aspectj/doc/released/adk15notebook/at aspectj-itds.html

(are you using a recent dev build or just AspectJ1.5.0?)

Andy.

(ps. you are likely to get more responses if you use the mailing list
rather than this newsgroup.)

Scott wrote:
> I am using @AspectJ annotation style development. Thumbs up to whomever
> decided to do it this way. I like it. However I think I might be way to
> early in trying to use it. @DeclareParents does not appear to be
> working. I found this
> ( http://dev.eclipse.org/mhonarc/lists/aspectj-dev/msg01841.ht ml) posting
> and its related messages. I am wondering if this is still not in? Or am
> I missing something?
> Here is the code I am running. It was taken from
> http://static.springframework.org/spring/docs/2.0-m2/referen ce/ataspectj.html
> and was slightly modified. It assumes an implementation of a Lockable
> interface which has three methods: void lock(), void unlock(), boolean
> locked(). It also assumes you have a class (HelloAnnotetedAOP - just a
> hello world type class) to weave into.
> @Aspect public class AnnotatedAspect {
> @DeclareParents(value="HelloAnnotetedAOP",
> defaultImpl=DefaultLockable.class) public static Lockable mixin;
> @Pointcut("execution(* *())") void anyExecution()
> {} @Before(value="anyExecution() && this(mixin)")
> public void checkNotLocked(Lockable mixin) {
> if (mixin.locked()) System.out.println("Locked!...");
> else System.out.println("Not locked!..."); }
> @Before("anyExecution()") public void doBefore() {
> System.out.println("Hello before!..."); }
> @After("anyExecution()") public void doAfter() {
> System.out.println("Hello after!..."); } }
> This prints out: Hello before!... Hello after!...
Previous Topic:@DeclareParents
Next Topic:Build problems with converted projects
Goto Forum:
  


Current Time: Fri Mar 29 11:34:29 GMT 2024

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

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

Back to the top