Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Pointcut definition with annotations

The *target* of the call is the target object, and @target will match
any call where the runtime type of the target of a call has the given
annotation. It would match in your case if Foo had the
@ManagedResourceAnnotation. However, you are trying to match
annotations not on the target, but on the method that gets invoked.
For this you need to use @annotation.

So you should write:

pointcut  annotatedResourceInvocation() : call(* *(..)) &&  
                                                           
@annotation(ManagedResourceAnnotation);

-- Adrian.

On 18/07/05, Valerio Schiavoni <ervalerio@xxxxxxxxxx> wrote:
> hello
> i have a set of interfaces, and some of their methods are annotated via
> a custom annotation, called, ManagedResourceAnnotation, something like
> the following:
> 
> public interface Foo{
>     @ManagedResourceAnnotation
>     void push (String s);
> }
> 
> Now, i'd like to define a pointcut to capture a call to any method with
> that annotation.
> 
> i tried with:
> 
> *pointcut annotatedResourceInvocation(): call(* *(..)) && @target
> (ManagedResourceAnnotation);
> 
> *before annotatedResourceInvocation() {
>     //do some stuff
> }
> 
> 
> but this doesn't look to be the way, getting this (in ajdt eclipse plugin):
> "advice definied in MyAspect has not been applied [Xlint: adviceDidNotMatch]
> I'm using ajdt build 20050715120753
> 
> Did i misunderstood what it is explained in the aj5.0 dev book (the
> example i followed is taken from:
> http://www.eclipse.org/aspectj/doc/next/adk15notebook/annotations-pointcuts-and-advice.html#d0e1194
> 
> /call(* *(..)) && @target(Classified)/
> 
>     /    Matches a call to any object where the target of the call has a
>     @Classified annotation./
> 
> 
> Thanks,
> Valerio
> 
> 
> 
> 
> 
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
> 


-- 
-- Adrian
adrian.colyer@xxxxxxxxx


Back to the top