This content has been marked as final.
Show 5 replies
-
1. Re: inheritance of aspects
stalep Dec 4, 2006 6:57 AM (in response to fabiocsilva)hi, i guess this question should be answered by kabir. atm he is on vacation, but he will answer you when he's back.
in the meantime i guess you have to add @Aspect on all subclasses (i dont know how many classes you got, but hopefully its not too big of a job :) -
2. Re: inheritance of aspects
flavia.rainone.old Dec 4, 2006 9:35 AM (in response to fabiocsilva)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. -
3. Re: inheritance of aspects
fabiocsilva Dec 7, 2006 8:11 PM (in response to fabiocsilva)Good solution, thank you.
-
4. Re: inheritance of aspects
flavia.rainone.old Dec 7, 2006 8:49 PM (in response to fabiocsilva)You're welcome! :)
-
5. Re: inheritance of aspects
sunnymoon Jun 11, 2008 6:07 PM (in response to fabiocsilva)But what if one is using the annotations based approach, do you inherit Pointcuts defined in the super abstract class?