1 Reply Latest reply on Mar 9, 2006 2:24 PM by Andrew May

    AroundInvoke for Inherited business methods

    Andrew May Newbie

      I am having a problem with an @AroundInvoke interceptor not running for methods that are implemented in a superclass of a Stateless session bean:

      public interface A
      {
       public String getMessage();
      }
      
      public interface B extends A
      {
       String getOtherMessage();
      }
      
      abstract public class ABean implements A
      {
       public String getMessage()
       {
       return "The Message";
       }
      }
      
      @Stateless
      @Remote(B.class)
      @Interceptors({Intercept.class})
      public class BBean extends ABean implements B
      {
       public String getOtherMessage()
       {
       return "The Other Message";
       }
      }
      
      public class Intercept
      {
       @AroundInvoke
       Object audit(InvocationContext ctx) throws Exception
       {
       String message = (String)ctx.proceed();
       System.out.println("Interceptor called for "+ctx.getMethod().getName());
       return "Intercepted: "+message;
       }
      }
      
      public class Client
      {
       public static void main(String[] args) throws Exception
       {
       Context ctx = new InitialContext();
       B b = (B)ctx.lookup("BBean/remote");
       System.out.println(b.getMessage());
       System.out.println(b.getOtherMessage());
       }
      }
      


      When the client is run it prints:
      The Message
      Intercepted: The Other Message

      i.e. the interceptor is only called for methods implemented in BBean, and not those implemented in the superclass.

      This is similar to http://jira.jboss.com/jira/browse/EJBTHREE-376 - but that was about @AroundInvoke methods in the superclass rather than inherited business methods. The test case that was added for that issue doesn't have any inherited business methods as far as I can see.

      Thanks for your help,
      Andrew