4 Replies Latest reply: Jan 11, 2012 9:03 AM by Jozef Hartinger RSS

    Abstract method and Interceptor

    Vitaly Masterov Newbie

      There is an AbstractSimpleBean abstract class with the doAction() method and the handle() abstract method. SimpleBean is a child of AbstractSimpleBean, SimpleBean implements the handle() method. Also there are an Interceptor class and the @Simple qualifier with @InterceptorBinding.
      If the handle() method is annotated as @Simple, the interceptor class does not work.


      @InterceptorBinding
      @Target({TYPE, METHOD})
      @Retention(RUNTIME)
      @Documented
      public @interface Simple {
           
      
      }
      


      @Interceptor @Simple
      public class SimpleInterceptor implements Serializable {
           
           private static final long serialVersionUID = 6824959430435594183L;
           
           @Inject
           private Logger log;
           
           @AroundInvoke
           public Object around(InvocationContext ctx) throws Exception {
                log.info("... around() ...");
                return ctx.proceed();
           }
      
      }
      


      public abstract class AbstractSimpleBean {
           
           @Inject
           protected Logger log;
                          
           public abstract void handle();
                     
           public void doAction() {
                log.info("... doAction() ...");
                handle();
           }     
      
      }
      


      public class SimpleBean extends AbstractSimpleBean {
      
           private static final long serialVersionUID = 7944713842447575257L;
                
           @Simple
           public void handle() {
                log.info("... handle() ...");
           }
           
      }
      


      When the doAction() method is annotated as @Simple in the AbstractSimpleBean parent class, all works fine. Is this a limitation for abstract methods in CDI and Weld or is it a bug?