You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openwebbeans.apache.org by "Kevin Pollet (JIRA)" <ji...@apache.org> on 2011/07/20 11:52:57 UTC

[jira] [Reopened] (OWB-593) Interceptor binding added on an interceptor class at ProcessAnnotatedType phase is not considered

     [ https://issues.apache.org/jira/browse/OWB-593?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kevin Pollet reopened OWB-593:
------------------------------


> Interceptor binding added on an interceptor class at ProcessAnnotatedType phase is not considered
> -------------------------------------------------------------------------------------------------
>
>                 Key: OWB-593
>                 URL: https://issues.apache.org/jira/browse/OWB-593
>             Project: OpenWebBeans
>          Issue Type: Bug
>          Components: Interceptor and Decorators
>    Affects Versions: 1.0.0
>            Reporter: Kevin Pollet
>            Assignee: Mark Struberg
>             Fix For: 1.1.1
>
>         Attachments: openwebbeans-sample.zip
>
>
> I have an annotation only allowed on methods (not annotated with @InterceptorBinding). I want to add this annotation as an interceptor binding and register the corresponding interceptor programmatically (the interceptor class cannot be annotated with the "new" interceptor binding annotation). For that I've created the following extension and interceptor:
> public class FooExtension implements Extension {
>    void registerInterceptorBinding(@Observes BeforeBeanDiscovery event) {
>       event.addInterceptorBinding(Foo.class);
>    }
>    void processFooInterceptorAnnotatedType(@Observes ProcessAnnotatedType<FooInterceptor> event) {
>       AnnotatedType<FooInterceptor> annotatedType = new AnnotatedTypeBuilder<FooInterceptor>()
>             .readFromType(event.getAnnotatedType())
>             .addToClass(new AnnotationLiteral<Foo>() {})
>             .create();
>       event.setAnnotatedType(annotatedType);
>    }
> }
> @Interceptor
> public class FooInterceptor {
>    @AroundInvoke
>    public Object intercept(InvocationContext context) throws Exception {
>          return "Foo interceptor called";
>    }
> }
> With the code above I have the following exception at startup:
> org.apache.webbeans.exception.WebBeansConfigurationException: WebBeans XML configuration defined in /beans.xml is failed. Reason is : Interceptor class : com.github.kevinpollet.sample.cdi.interceptor.FooInterceptor must have at least one @InterceptorBindingType
> If I use AfterBeanDiscovery#addBean() all works fine but it's not as neat as the previous approach and I've seen nothing in the spec that disallows it. FYI, this approach works fine with Weld.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira