7 Replies Latest reply on Jan 12, 2011 3:37 AM by jaikiran pai

    Interceptor sub classing

    blep Newbie

      Hello,

       

      Suppose I have an abstract generified base class to be deployed as an EJB interceptor:

       

      {code}

      public abstract class AbstractServiceInitializer<T> {

      @PostConstruct

          public void init(InvocationContext ctx) {

                Object o = ctx.getTarget();

              try {

                  T service = (T) o;

                  init(service);

              } catch (ClassCastException e) {

                  log.warn("Class {} is not supported... doing nothing", o.getClass().getName());

                  return;

              }

          }

           public abstract void init(T service);

      }

      {code}

       

      And a subclass :

       

      {code}

      public class MyEjbImplInitializer extends AbstractServiceInitializer<MyEjbImpl>{

           @Override

          public void init(MyEjbImpl service) {

              // specific init stuff

          }

      }

      {code}

       

      The problem I face is that during the PostConstruct phase of the MyEjbImpl lifecycle, the init(InvocationContext ctx) method from the  superclass is not invoked (of course the @Interceptors directive is correctly declared). The only way to make it work is to override that method in the subclass with a simple :

      {code}

          @PostConstruct

          @Override

          public void init(InvocationContext ctx) {

              super.init(ctx);

          }

      {code}

       

      is it normal or is it related to https://issues.jboss.org/browse/JBMDR-73 ?

       

      Regards