RE: [aspectwerkz-user] Custom annotations with jdk5 and ElementTy pe.TYPE?

"AVERY, Neil, FM" <[email protected]> Tue, 5 Jul 2005 15:45:14 +0100
Newsgroups gmane.comp.java.aspectwerkz.user
Message-ID <6C6F6659FF768141BE4E4945FA71AE0E2283FC15@lon0349xns.fm.rbsgrp.net>
Yup that worked although I couldn't use the '&&' notation  as it blows up
with the error below.. I ended up using ... 
<pointcut name="withinInvocation" expression="execution(* *..*(..)) AND
within(@org.neo.swarm.interceptor.within.InterceptWithin *)"/> 

Thanks again Alex!
-neil.

Error........................................

Error on '&&'
AspectWerkz - INFO - Pre-processor
org.codehaus.aspectwerkz.transform.AspectWerkzPreProcessor loaded and
initialized
org.dom4j.DocumentException: Error on line 10 of document  : The entity name
must immediately follow the '&' in the entity reference. Nested exception:
The entity name must immediately follow the '&' in the entity reference.
	at org.dom4j.io.SAXReader.read(SAXReader.java:355)

-----Original Message-----
From: Alexandre Vasseur [mailto:[email protected]] 
Sent: 05 July 2005 15:33
To: [email protected]
Subject: Re: [aspectwerkz-user] Custom annotations with jdk5 and
ElementType.TYPE?


The expression 

"execution(* @org.neo.swarm.interceptor.within.InterceptWithin.*(..))"

is indeed invalid since it does not follow the "type dot methodname" style.
Try with:

"execution(* *..*(..)) &&
within(@org.neo.swarm.interceptor.within.InterceptWithin *)"

Note: since the following is not supported (and is rather ugly anyway)
"execution(* (@org.neo.swarm.interceptor.within.InterceptWithin *).*(..))"


Alex

On 7/5/05, AVERY, Neil, FM <[email protected]> wrote:
> Thanks Alex,
> (what a silly mistake I made) the test now works, however..what I 
> would really like to be able to do is use a TYPE annotation to bind an 
> aspect to a class instance. (the same as if I were using an interface 
> to bind aspects).
> 
> Config:
>  <aspect class="WithinAspect" deployment-model="perInstance">
>         <pointcut name="withinInvocation" expression="execution(* 
> @org.neo.swarm.interceptor.within.InterceptWithin.*(..))"/>
>         <advice name="execute" type="around" 
> bind-to="withinInvocation"/>  </aspect>
> 
> Annotation:
>  @Retention(RetentionPolicy.RUNTIME)
>  @Target(ElementType.TYPE)
>  public @interface InterceptWithin {
>  }
> 
> Applied to this class:
>  @InterceptWithin
>  public class SomeComponent {
>         public String doStuff(){
>                 return "stuff";
>   }
>  }
> 
> Is this possible or is my config broken again? AW doesn't like to 
> formatting of the XML and blows up with the error blow Many thanks
> Neil.
> 
> 
> Error....
> AspectWerkz - INFO - Pre-processor 
> org.codehaus.aspectwerkz.transform.AspectWerkzPreProcessor loaded and 
> initialized
> org.codehaus.aspectwerkz.exception.DefinitionException: expression is 
> not well-formed [execution(*
> @org.neo.swarm.interceptor.within.InterceptWithin.*(..))]: Encountered 
> "@org.neo.swarm.interceptor.within.InterceptWithin" at line 1, column 
> 13. Was expecting one of:
>     <METHOD_CLASS_PATTERN> ...
>     "(" ...
> 
>         at 
> org.codehaus.aspectwerkz.expression.ExpressionInfo.<init>(ExpressionIn
> fo.jav
> a:96)
> 
> -----Original Message-----
> From: Alexandre Vasseur [mailto:[email protected]]
> Sent: 05 July 2005 12:58
> To: [email protected]
> Subject: Re: [aspectwerkz-user] Custom annotations with jdk5
> 
> 
> Hi Neil
> 
> Use the full qualified name of the annotation in the pointcut 
> expression (I guess this one is in some package)
> 
> Alex
> 
> On 7/5/05, AVERY, Neil, FM <[email protected]> wrote:
> > Hi All,
> > Im trying to get a simple testcase working where I define my own 
> > aspect which is driven by an Annotation Ive defined - however I 
> > cannot get it to work. My component does get aspectised in the test 
> > case.
> >
> > Is there something Im doing wrong in my pointcut definition?
> >
> > The aspect:
> >  public class WithinAspect {
> >
> >         public Object execute(JoinPoint jp) throws Throwable{
> >                 System.err.println("within got Aspect called with:" +
jp);
> >                 return jp.proceed();
> >         }
> >  }
> >
> > The component being Aspectised:
> >   public class SomeComponent {
> >         @InterceptWithinInvocation
> >         public String doStuff(){
> >                 return "stuff";
> >         }
> >  }
> >
> > Config awerkz-aop.xml:
> >   <aspectwerkz>
> >         <system id="test">
> >                 <package name="org.neo.swarm.interceptor.within">
> >
> >                         <aspect class="WithinAspect" 
> > deployment-model="perInstance">
> >                                 <pointcut name="withinInvocation" 
> > expression="execution(@InterceptWithinInvocation * *.doStuff(..))"/>
> > <!-- this works                 <pointcut name="withinInvocation"
> > expression="execution(* *.doStuff(..))"/> -->
> >
> >                                 <advice name="execute" type="around" 
> > bind-to="withinInvocation"/>
> >                         </aspect>
> >                 </package>
> >         </system>
> >   </aspectwerkz>
> >
> > The annotation:
> >   @Retention(RetentionPolicy.RUNTIME)
> >   @Target(ElementType.METHOD)
> >   public @interface InterceptWithinInvocation {
> >   }
> >
> > The test:
> >         public void testWithin() throws Exception {
> >                 SomeComponent component = new SomeComponent();
> >                 component.doStuff();
> >         }
> >
> >
> > ********************************************************************
> > **
> > *************
> > The Royal Bank of Scotland plc. Registered in Scotland No 90312.
> Registered Office: 36 St Andrew Square, Edinburgh EH2 2YB.
> > Authorised and regulated by the Financial Services Authority
> >
> > This e-mail message is confidential and for use by the addressee 
> > only. If the message is received by anyone other than the addressee, 
> > please return the message to the sender by replying to it and then 
> > delete the message from your computer. Internet e-mails are not 
> > necessarily secure. The Royal Bank of Scotland plc does not accept 
> > responsibility for changes made to this message after it was sent.
> >
> > Whilst all reasonable care has been taken to avoid the transmission 
> > of viruses, it is the responsibility of the recipient to ensure that 
> > the onward transmission, opening or use of this message and any 
> > attachments will not adversely affect its systems or data.  No 
> > responsibility is accepted by The Royal Bank of Scotland plc in this 
> > regard and the recipient should carry out such virus and other 
> > checks as it considers appropriate.
> >
> 
> > Visit our websites at: http://www.rbs.co.uk/CBFM 
> > http://www.rbsmarkets.com
> >
> 
> > ********************************************************************
> > **
> > **********
> >
> >
>