Top Description Methods
org.glassfish.hk2.api

public Interface InterceptionService

Annotations
@Contract
Imports
java.lang.reflect.Constructor, .Method, java.util.List, org.aopalliance.intercept.ConstructorInterceptor, .MethodInterceptor, org.jvnet.hk2.annotations.Contract

This service is implemented in order to configure interceptors on methods or constructors provided by hk2 services. All implementations must be in the jakarta.inject.Singleton scope. Only services that are created by HK2 are candidates for interception. In particular services created by the provide method of the Factory interface can not be intercepted.

An implementation of InterceptionService must be in the Singleton scope. Implementations of InterceptionService will be instantiated as soon as they are added to HK2 in order to avoid deadlocks and circular references. Therefore it is recommended that implementations of InterceptionService make liberal use of jakarta.inject.Provider or IterableProvider when injecting dependent services so that these services are not instantiated when the InterceptionService is created

Author
jwells

Method Summary

Modifier and TypeMethod and Description
public List<ConstructorInterceptor>

Returns:

if null (or an empty list) then this constructor should NOT be intercepted. Otherwise the list of interceptors to apply to this method
getConstructorInterceptors
(Constructor<?>
A constructor that may be intercepted
constructor
)

The single chosen constructor of a service that passes the getDescriptorFilter method will be passed to this method to determine if it will intercepted

public Filter

Returns:

The filter that will be applied to a descriptor to determine if it is to be intercepted. Should not return null
getDescriptorFilter
()

If the returned filter returns true then the methods of the service will be passed to getMethodInterceptors(Method) to determine if a method should be intercepted and the constructor of the service will be passed to getConstructorInterceptors(Constructor) to determine if the constructor should be intercepted

public List<MethodInterceptor>

Returns:

if null (or an empty list) then this method should NOT be intercepted. Otherwise the list of interceptors to apply to this method
getMethodInterceptors
(Method
A non-final method that may be intercepted
method
)

Each non-final method of a service that passes the getDescriptorFilter method will be passed to this method to determine if it will intercepted

Method Detail

getConstructorInterceptorsback to summary
public List<ConstructorInterceptor> getConstructorInterceptors(Constructor<?> constructor)

The single chosen constructor of a service that passes the getDescriptorFilter method will be passed to this method to determine if it will intercepted

Parameters
constructor:Constructor<?>

A constructor that may be intercepted

Returns:List<ConstructorInterceptor>

if null (or an empty list) then this constructor should NOT be intercepted. Otherwise the list of interceptors to apply to this method

getDescriptorFilterback to summary
public Filter getDescriptorFilter()

If the returned filter returns true then the methods of the service will be passed to getMethodInterceptors(Method) to determine if a method should be intercepted and the constructor of the service will be passed to getConstructorInterceptors(Constructor) to determine if the constructor should be intercepted

Returns:Filter

The filter that will be applied to a descriptor to determine if it is to be intercepted. Should not return null

getMethodInterceptorsback to summary
public List<MethodInterceptor> getMethodInterceptors(Method method)

Each non-final method of a service that passes the getDescriptorFilter method will be passed to this method to determine if it will intercepted

Parameters
method:Method

A non-final method that may be intercepted

Returns:List<MethodInterceptor>

if null (or an empty list) then this method should NOT be intercepted. Otherwise the list of interceptors to apply to this method