@DeclareParents [message #63097] |
Thu, 23 March 2006 18:42  |
Eclipse User |
|
|
|
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 03:21  |
Eclipse User |
|
|
|
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 03:21  |
Eclipse User |
|
|
|
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!...
|
|
|
Powered by
FUDForum. Page generated in 0.07166 seconds