Uploaded image for project: 'Weld'
  1. Weld
  2. WELD-1019

Interceptor not applied on method of bean within custom scope.

    XMLWordPrintable

Details

    • Hide

      @InterceptorBinding
      @Target(

      {METHOD, TYPE}

      )
      @Retention(RUNTIME)
      public @interface MyInterceptor {
      }

      @Interceptor
      @GridInterceptor
      public class GridSynchronizer implements Serializable{
      private static final long serialVersionUID = 7685137612002720995L;
      @AroundInvoke
      public Object intercept(InvocationContext ctx) throws Exception

      { System.out.println("Within interceptor"); Object result = ctx.proceed(); return result; }

      }

      @NormalScope(passivating=true)
      public @interface MyScope {
      }

      public class MyScopeContext implements Context {
      // implementation removed
      }

      public class MyScopeExtension implements Extension {

      public void beforeBeanDiscovery(@Observes BeforeBeanDiscovery event, BeanManager manager)

      { event.addScope(MyScope.class, true, true); }

      public void afterBeanDiscovery(@Observes AfterBeanDiscovery event, BeanManager manager)

      { event.addContext(new MyScopeContext()); }

      }

      @MyScope
      @Named
      public class HelloBean implements Serializable {
      private static final long serialVersionUID = -3216074155876250969L;

      @GridInterceptor
      public String getMessage()

      { return "Hello World"; }

      }

      Show
      @InterceptorBinding @Target( {METHOD, TYPE} ) @Retention(RUNTIME) public @interface MyInterceptor { } @Interceptor @GridInterceptor public class GridSynchronizer implements Serializable{ private static final long serialVersionUID = 7685137612002720995L; @AroundInvoke public Object intercept(InvocationContext ctx) throws Exception { System.out.println("Within interceptor"); Object result = ctx.proceed(); return result; } } @NormalScope(passivating=true) public @interface MyScope { } public class MyScopeContext implements Context { // implementation removed } public class MyScopeExtension implements Extension { public void beforeBeanDiscovery(@Observes BeforeBeanDiscovery event, BeanManager manager) { event.addScope(MyScope.class, true, true); } public void afterBeanDiscovery(@Observes AfterBeanDiscovery event, BeanManager manager) { event.addContext(new MyScopeContext()); } } @MyScope @Named public class HelloBean implements Serializable { private static final long serialVersionUID = -3216074155876250969L; @GridInterceptor public String getMessage() { return "Hello World"; } }
    • Compatibility/Configuration

    Description

      When the interceptor binding annotation is placed on a method (and class itself also) of a bean which is placed in a custom defined scope, the interceptor isn't executed.

      Attachments

        Activity

          People

            marko.luksa@gmail.com Marko Luksa (Inactive)
            rdebusscher@gmail.com Rudy De Busscher (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: