Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.0.0
-
None
Description
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
}
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.
Attachments
Attachments
Issue Links
- relates to
-
OPENEJB-1993 Interceptor binding through extension is not considered
- Open