openwebbeans-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kevin Pollet (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (OWB-593) Interceptor binding added on an interceptor class at ProcessAnnotatedType phase is not considered
Date Wed, 20 Jul 2011 09:50:58 GMT

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

Kevin Pollet updated OWB-593:
-----------------------------

    Attachment: openwebbeans-sample.zip

You can run it with the following command mvn clean compile exec:java

> 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

        

Mime
View raw message