Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Detect annotated method

Hi -

AJDT/ajc is pretty good at telling you where the problem is.
The syntax error is due to using the annotation for the method
name (illegal) not the method modifiers.  The signature pattern 
should look like a method declaration, which puts the modifiers
in front of everythihng.

err: call(* *.(@MyAnnotation *)(..))
 ok: call(@MethodAnnotation * *.*(..))
 ok: call(public !synchronized @MethodAnnotation * *.*(..))

To target a method with an annotated return type:
 ok: call((@ReturnAnnotation *) *.*(..))

To target a method declared on an annotated class:
 ok: call(* (@ReturnAnnotation *).*(..))

(except: is the latter working? was that a bug at one point?)

hope this helps - Wes

> ------------Original Message------------
> From: "matsui akira" <akira_in_tokyo@xxxxxxxxxxx>
> To: aspectj-users@xxxxxxxxxxx
> Date: Tue, Mar-21-2006 8:00 AM
> Subject: [aspectj-users] Detect annotated method
>
> Hello,
> 
> I'm trying to write a pointcut that runs around every method that has a 
> 
> certain annotation. For example, I'm would like to run around code on 
> this 
> method:
> 
> @MyAnnotation
> public void m( )
> {
>     // code....
> }
> 
> but I don't wan to run around code on this other one:
> 
> public void n( )
> {
>     // code....
> }
> 
> I thought it was ok to do something like this:
> 
> Object around(): call(* *.*(..)) && !call(* *.(@MyAnnotation *)(..)) && 
> 
> etc....
> 
> But AJDT points that the code has syntax errors.
> 
> What is the right way to acomplish what I want to do?
> Sure I can do this filtering by using some reflection. But I want 
> programmers to see only aspect application marks only in calls in which 
> 
> aspects are really applied. So I'm pretty convinced that that should be 
> a 
> way to do it by writing correct pointcut code.
> 
> Thanks in advance.
> 
> _________________________________________________________________
> MSNショッピングでXbox360を早速チェック! 
> http://shopping.msn.co.jp/softcontent/softcontent.aspx?scmId=593 
> 
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
> 



Back to the top