Package javax.enterprise.inject.spi
Interface Interceptor<T>
-
- Type Parameters:
T
-
- All Superinterfaces:
Bean<T>
,BeanAttributes<T>
,Contextual<T>
public interface Interceptor<T> extends Bean<T>
A Bean for creating and using an interceptor. A CDI interceptor is always a separate dependent instance for each intercepted class. It will get created when the intercepted bean gets created and destroyed when the intercepted bean gets destroyed.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.Set<java.lang.annotation.Annotation>
getInterceptorBindings()
Usually a single Interceptorjava.lang.Object
intercept(InterceptionType type, T instance, javax.interceptor.InvocationContext ctx)
Perform the interception.boolean
intercepts(InterceptionType type)
-
Methods inherited from interface javax.enterprise.inject.spi.Bean
getBeanClass, getInjectionPoints, isNullable
-
Methods inherited from interface javax.enterprise.inject.spi.BeanAttributes
getName, getQualifiers, getScope, getStereotypes, getTypes, isAlternative
-
Methods inherited from interface javax.enterprise.context.spi.Contextual
create, destroy
-
-
-
-
Method Detail
-
getInterceptorBindings
java.util.Set<java.lang.annotation.Annotation> getInterceptorBindings()
Usually a single Interceptor- Returns:
- all
InterceptorBinding
s handled by this interceptor.
-
intercepts
boolean intercepts(InterceptionType type)
- Parameters:
type
- InterceptionType in question- Returns:
true
if this interceptor handles the given InterceptionType,false
otherwise
-
intercept
java.lang.Object intercept(InterceptionType type, T instance, javax.interceptor.InvocationContext ctx) throws java.lang.Exception
Perform the interception. This will e.g. invoke the @AroundInvoke annotated method on the given instance of T.- Parameters:
type
- the InterceptionType. This is important if an interceptor has multiple interceptor methods e.g. one @AroundInvoke and one @PostConstruct;instance
- the interceptor instancectx
- the InvocationContext contains all the interceptor chain state for a single invocation.- Returns:
- the object or wrapper type returned by the intercepted instance or the previous interceptor (if this is not the last interceptor in the chain)
- Throws:
java.lang.Exception
- wrapped from the intercepted instance. See CDI-115
-
-