[aspectwerkz-user] Custom annotations with jdk5
"AVERY, Neil, FM" <[email protected]> Tue, 5 Jul 2005 12:48:42 +0100
| Newsgroups | gmane.comp.java.aspectwerkz.user |
|---|---|
| Message-ID | <6C6F6659FF768141BE4E4945FA71AE0E2283FC0A@lon0349xns.fm.rbsgrp.net> |
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
********************************************************************************