I have an interceptor binding, which is parameterized:
@InterceptorBinding
@Target({ ElementType.METHOD, ElementType.TYPE })
@Retention(RetentionPolicy.RUNTIME)
public @interface Traced {
@Nonbinding
boolean traceFull() default true;
}
Then I define an interceptor implementation
@Interceptor
@Traced
public class TracingInterceptor implements Serializable { ... }
In the implementation I want to check which value is set to the traceFull-parameter.
(I do not want to implement three interceptor implementations for true, false and null)
So my implementation checks the Interceptor-Binding-Annotation of the intercepted method:
Traced traceAnnotation = context.getMethod().getAnnotation(Traced.class);
if (traceAnnotation != null && traceAnnotation.traceFull()) { ... }
This works fine but if I use a Stereotype or a nested interceptor binding then I don’t get the @Traced annotatopn of the method and I cannot check the value which is set.
So my question is: How can I get the ‘calling’ binding within my interceptor implementation?
This is not possible in CDI 1.0, but should be in CDI 1.1