Uploaded image for project: 'JBoss Enterprise Application Platform'
  1. JBoss Enterprise Application Platform
  2. JBEAP-70

CDI injecting self not executing interceptors

XMLWordPrintable

      I have a CDI which needs to inject "itself" in order to fire the interceptors defined in the bean methods.
      I'm facing this limitation right now in JBoss EAP 6.1.
      The injection actually works, but the aspects (i.e.: Interceptors) are not applied.

      This scenario replicates the issue:

      @Named
      @RequestScoped
      public class MyBean {
      
      @Inject
      private MyBean self;
      
      @Interceptors(InterceptorA.class)
      public void methodA()
      { self.methodB(); }
      
      @Interceptors(InterceptorB.class)
      public void methodB()
      { System.out.println("extra"); }
      
      }
      

      When I call methodA, InterceptorA is called, but when this method calls methodB, the InterceptorB is never called.
      If I instead, get a new MyBean reference from BeanManager, the interceptors work fine.
      The other workaround I found was injecting a new bean which has methodB defined, however this implies creating a new class.

      Thanks in advance for your thoughts.

              sdouglas1@redhat.com Stuart Douglas (Inactive)
              rsisto_jira Rafael Sisto (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: