[jboss-user] [JBoss AOP] - Interceptors not fired on methods called from within bean?

jnorris10 do-not-reply at jboss.com
Wed Jul 12 17:07:12 EDT 2006


I am using JBoss 4.0.4.GA (w/ JBoss AOP 1.5.0.GA and EJB RC7).

Here is my jboss-aop.xml:

    
  |     <aop>
  |       <interceptor class="org.jnorris10.TestInterceptor" scope="PER_VM"/>
  | 
  |       <domain name="Test Domain" extends="Stateless Bean" inheritBindings="true">
  |         <bind pointcut="execution(public * *->*(..))">
  |           <interceptor-ref name="org.jnorris10.TestInterceptor"/>
  |         </bind>
  |         <precedence>
  |           <interceptor-ref name="org.jnorris10.TestInterceptor"/>
  |           <interceptor-ref name="org.jboss.ejb3.tx.TxInterceptorFactory"/>
  |         </precedence>
  |       </domain>
  |     </aop>
  |     

    Here is my interceptor:

    
  |     package org.jnorris10
  | 
  |     import ... etc.
  | 
  |     public class TestInterceptor implements Interceptor, Serializable
  |     {
  |         private static final long serialVersionUID = 1L;
  | 
  |         public TestInterceptor()
  |         {
  |         }
  | 
  |         public String getName()
  |         {
  |             return "TestInterceptor";
  |         }
  | 
  |         public Object invoke(Invocation invocation) throws Throwable
  |         {
  |             try
  |             {
  |                 System.out.println(">>>>>>>>>>TestInterceptor begin: >>>>>>>>>>");
  |                 System.out.println("\t" + invocation);
  |                 return invocation.invokeNext();
  |             }
  |             finally
  |             {
  |                 System.out.println(">>>>>>>>>>TestInterceptor   end: >>>>>>>>>>");
  |             }
  |         }
  |     }
  |     

    Then here is my stateless session bean:

    
  |     @Stateless
  |     @AspectDomain("Test Domain")
  |     public class A
  |     {    
  |          A()
  |          {
  |          }
  | 
  |          public void x()
  |          {
  |              y();
  |          }
  | 
  |          public void y()
  |          {
  |          }
  |     }
  |     

The problem is that if I invoke x() on a bean reference to A, the interceptor is invoked.  However, the interceptor is *not* invoked on the call to y() from x().  It seems that the interceptor is only called when the method is invoked across class boundaries and not when it's called internally.  What am I missing?

Thanks.

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

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



More information about the jboss-user mailing list