[jboss-user] [JBoss AOP] - Re: inheritance of aspects
flavia.rainone
do-not-reply at jboss.com
Mon Dec 4 09:35:59 EST 2006
Hi,
It is not allowed to put an expression in the 'class' attribute of 'aspect' tag.
Still, you can simulate the inheritance of aspect advices. As Stalep said, you need to declare the subclasses as aspects in the xml file, and declare the bindings like in the following example.
| >>>>> ASPECTS
|
| class MyAspect1 extends MySuperAspect
| {
| public Object advice(Invocation invocation) throws Throwable
| {
| // do something I want to and then invoke super aspect
| return super.advice(invocation);
| }
| }
|
| class MyAspect2 extends MySuperAspect
| {
| public Object advice(Invocation invocation) throws Throwable
| {
| // do only what I want to, don't call super aspect
| .....
| return invocation.invokeNext();
| }
| }
|
| public abstract class MySuperAspect
| {
| public Object advice(Invocation invocation) throw Throwable
| {
| ....
| }
| }
|
| >>>>> XML FILE
|
| <?xml ....?>
| <aop>
| <aspect class="MyAspect1" scope="PER_VM" />
| <aspect class="MyAspect2" scope="PER_VM" />
|
| <bind pointcut=">whatever you want here<" />
| <advice name="advice" aspect="MyAspect1"/>
| <advice name="advice" aspect="MyAspect2"/>
| </bind>
| </aop>
|
Notice MySuperAspect can also be an interface or a concrete class.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3991008#3991008
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3991008
More information about the jboss-user
mailing list