[jboss-user] [JBoss AOP] - Re: Are names supposed to be unique in JBoss AOP?

flavia.rainone@jboss.com do-not-reply at jboss.com
Wed Apr 9 15:59:37 EDT 2008


Hi!

It is expected that JBoss AOP would create four instances of aspects instead of two.
This is true because an interceptor tag declares a new interceptor to JBoss AOP. Whether you have more than one interceptor declaration with the same class is not relevant. Look at the example below:

<bind pointcut="execution(static * POJO->*(..))">
  |     <interceptor class="MethodInterceptor name="interceptor1"/>
  | </bind>
  | 
  | <bind pointcut="execution(* POJO$Bar->*(..))">
  |     <interceptor class="MethodInterceptor" name="interceptor2"/>
  | </bind>

In the xml tags above two different interceptors, with the same class, are declared. Their names are "interceptor1" and "interceptor2". If their names are not defined, JBoss AOP creates a name for those interceptors.

So, if you want to use a single interceptor, i.e., to have only one aspect definition generated to represent your interceptor, you should do something like this:
<interceptor class="MethodInterceptor name="interceptor1"/>
  | 
  | <bind pointcut="execution(static * POJO->*(..))">
  |     <interceptor-ref name="interceptor1"/>
  | </bind>
  | 
  | <bind pointcut="execution(* POJO$Bar->*(..))">
  |     <interceptor-ref name="interceptor1"/>
  | </bind>

However, it looks like JBoss AOP does create two interceptors with the same name when the name attributes are not defined. I will do some investigation before answering this part of your question.


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4142966#4142966

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4142966



More information about the jboss-user mailing list