1 Reply Latest reply on Jun 13, 2006 8:14 AM by Olivier Michalet

    Inheritance of EJB3 Session Interceptors

    Olivier Michalet Newbie

      Hello,
      I've introduced a superclass to deal with interceptors for a kind of session beans. If I define a @AroundInvoke method on the superclass, it's successfully invoked for all the subclasses. But if I define a @Interceptors annotation on the superclass, it is ignored by the subclasses. I don't think this is correct according to the spec...
      I've tested that with a true Stateless Session superclass, annotated with @Stateless @Remote({ CPageFacade.class }), or with an annotated POJO and the result is the same.
      Greetings.

      Here's the code :

      @Interceptors({ CPageSecurityInterceptor.class })
      // this one is never invoked for the subclasses
      public abstract class CPageFacadeBean implements CPageFacade {

      @AroundInvoke
      public Object intercept(InvocationContext invocationContext) throws Exception {
      // this one is ok !
      return invocationContext.proceed();
      }
      }

      ____________________________________________________

      @Stateless
      @Remote(HelloFacade.class)
      public class HelloFacadeBean extends CPageFacadeBean implements HelloFacade {

      public String sayHello(String who) {
      // do the stuff here
      return "hello " + who;
      }
      }

      ____________________________________________________

      public class CPageSecurityInterceptor {

      @Resource
      private SessionContext sessionContext;

      @AroundInvoke
      public Object authorize(InvocationContext invocationContext) throws Exception {
      // this one is never called for the subclasses
      return invocationContext.proceed();
      }

      ____________________________________________________

      public interface HelloFacade extends CPageFacade {
      String sayHello(String who);
      }

      ____________________________________________________

      public interface CPageFacade {
      // no-op
      }