Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » AspectJ » @DeclareParents
@DeclareParents [message #592666] Thu, 23 March 2006 23:42
Scott is currently offline ScottFriend
Messages: 33
Registered: July 2009
Member
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:Infinite build loop
Next Topic:@DeclareParents
Goto Forum:
  


Current Time: Fri Apr 19 04:49:12 GMT 2024

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

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

Back to the top