Module jakarta.cdi

Interface Interceptor<T>

  • Type Parameters:
    T - the interceptor bean class
    All Superinterfaces:
    Bean<T>, BeanAttributes<T>, Contextual<T>

    public interface Interceptor<T>
    extends Bean<T>

    Represents an enabled interceptor.

    Since CDI 2.0, an implementation of this interface may implement Prioritized in order to enable the interceptor with given priority value for entire application.

    Author:
    Gavin King, Pete Muir, David Allen
    • Method Detail

      • getInterceptorBindings

        java.util.Set<java.lang.annotation.Annotation> getInterceptorBindings()

        Obtains the interceptor bindings of the interceptor.

        Returns:
        the set of interceptor bindings
      • intercept

        java.lang.Object intercept​(InterceptionType type,
                                   T instance,
                                   jakarta.interceptor.InvocationContext ctx)
                            throws java.lang.Exception

        Invokes the specified kind of lifecycle callback or method invocation interception upon the given interceptor instance.

        Parameters:
        type - the kind of interception
        instance - the interceptor instance to invoke
        ctx - the context for the invocation
        Returns:
        the invocation return value
        Throws:
        java.lang.Exception - thrown by the target method and/or the following interceptors in the chain