[cdi-dev] Lifecycle Callback Interceptor and @Target "METHOD"

Martin Kouba mkouba at redhat.com
Tue Jun 11 09:56:49 EDT 2013


Hi Radim,

no, adding @AroundConstruct callback does not help. The statement Jozef
is referencing means: An interceptor for @PostConstruct and @PreDestroy
lifecycle callbacks may only declare interceptor binding types that are
defined as Target(TYPE). The PerformanceInterceptor declares
@PostConstruct callback and that's why the @Measure interceptor binding
has to defined as Target(TYPE).

Martin

Dne 11.6.2013 14:01, Radim Hanuš napsal(a):
> Hi,
> 
> I just went through this thread and corresponding issue WELD-1416
> <https://issues.jboss.org/browse/WELD-1416> and still not clear for me
> 
> Josef Hartinger referenced a statement from the current version of spec:
> "With the exception of AroundConstruct lifecycle callback interceptors,
> an interceptor for lifecycle callbacks may only declare interceptor
> binding types that are defined as Target(TYPE)."
> 
> but does it mean that adding @AroundConstruct callback interceptor into
> class PerformanceInterceptor prevents from DefinitionException ?
> or in such case there should be only @AroundConstruct defined and none
> of both @PostConstruct and @PreDestroy ?
> 
> enhanced sample of Jens Schumann:
> 
> @Interceptor
> @Measure
> public class PerformanceInterceptor implements Serializable {
> 
> @AroundInvoke
> public Object measure(InvocationContext ctx) throws Exception { ... }
> 
> @PostConstruct
> public void measureCreate(InvocationContext ctx) { ... }
> 
> *@AroundConstruct*
> Object onAroundConstruct(InvocationContext ctx) throws Exception {...}
> }
> 
> @InterceptorBinding
> @Target({*ElementType.METHOD*, ElementType.TYPE})
> @Retention(RetentionPolicy.RUNTIME)
> @Inherited
> public @interface Measure {
> }
> 
> 
> thanx for clarification,
> Radim
> 
> 
> _______________________________________________
> cdi-dev mailing list
> cdi-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/cdi-dev
> 


More information about the cdi-dev mailing list