Re: [aspectwerkz-user] RE: Pb with annotations and constructor selection

Alexandre Vasseur <[email protected]> Tue, 19 Jul 2005 17:16:42 +0200
Newsgroups gmane.comp.java.aspectwerkz.user
Message-ID <[email protected]>
in 
execution(@org.annotations.Authorization * *..*.new(..)) 

there is a star for a return type, which is not consistent since
constructor don't have a return type that you can match on.

Try:
execution(@org.annotations.Authorization *..*.new(..)) 

That said, this means
"match all execution of constructor that are annotated with the
Authorization annotation" which is different from what you are trying
to do (it seems).

For field interception you need to use a get/ set pointcut

Alex

On 7/19/05, Olivier Mallassi <[email protected]> wrote:
>  
>  
> 
> Hi all, 
> 
>   
> 
> I have a field with an annotation like this 
> 
> … 
> 
> @Authorization(authorization = { AuthorizationEnum.PROFILE_ONE }) 
> 
> private Action _action; 
> 
> … 
> 
>   
> 
> the action is instantiated later in the code by this way: 
> 
>   
> 
> _action = new AbstractAction("the action..."){ 
> 
>    … 
> 
> }; 
> 
>   
> 
>   
> 
> I am trying to define a pointcut that could select the construction of
> _action 
> 
> So I tried the following expression… 
> 
>   
> 
> execution(@org.annotations.Authorization * *..*.new(..)) 
> 
>   
> 
> …which respects, I guess, the pattern <annotations> <modifiers>
> <className>.<new>(<parameter_types>) 
> 
>   
> 
> when I run the app., the "weave phase" fail with the following error 
> 
>   
> 
> AspectWerkz - INFO - Pre-processor
> org.codehaus.aspectwerkz.transform.AspectWerk 
> 
> zPreProcessor loaded and initialized 
> 
> org.codehaus.aspectwerkz.exception.DefinitionException:
> expression is not well-f 
> 
> ormed [execution(@org.annotations.Authorization * *..*.new(..))]: Using a c 
> 
> onstructor pattern with an explicit return type is not allowed 
> 
>         at
> org.codehaus.aspectwerkz.expression.ExpressionInfo.<init>(ExpressionI
> 
> nfo.java:96) 
> 
>         at
> org.codehaus.aspectwerkz.definition.DefinitionParserHelper.createAndA
> 
> ddPointcutDefToAspectDef(DefinitionParserHelper.java:62) 
> 
>         at
> org.codehaus.aspectwerkz.definition.DocumentParser.parsePointcutEleme
> 
> nts(DocumentParser.java:631) 
> 
> …… 
> 
>   
> 
> I have certainly misunderstood something but I really don't know what…… 
> 
>   
> 
> Thanks for your help. 
> 
>   
> 
> Olivier 
> 
>   
> 
> PS: the following expression works well but I am not sure to get only the
> construction of the field: 
> 
> set(@org.annotations.Authorization private * *..*.*) 
> 
>   
> 
>   
> 
>   
> 
>