Package org.glassfish.hk2.api
Interface InterceptionService
-
- All Known Implementing Classes:
DefaultInterceptionService
@Contract public interface InterceptionService
This service is implemented in order to configure interceptors on methods or constructors provided by hk2 services. All implementations must be in theSingleton
scope. Only services that are created by HK2 are candidates for interception. In particular services created by the provide method of theFactory
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
Provider
orIterableProvider
when injecting dependent services so that these services are not instantiated when the InterceptionService is created- Author:
- jwells
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description List<org.aopalliance.intercept.ConstructorInterceptor>
getConstructorInterceptors(Constructor<?> constructor)
The single chosen constructor of a service that passes thegetDescriptorFilter()
method will be passed to this method to determine if it will interceptedFilter
getDescriptorFilter()
If the returned filter returns true then the methods of the service will be passed togetMethodInterceptors(Method)
to determine if a method should be intercepted and the constructor of the service will be passed togetConstructorInterceptors(Constructor)
to determine if the constructor should be interceptedList<org.aopalliance.intercept.MethodInterceptor>
getMethodInterceptors(Method method)
Each non-final method of a service that passes thegetDescriptorFilter()
method will be passed to this method to determine if it will intercepted
-
-
-
Method Detail
-
getDescriptorFilter
Filter getDescriptorFilter()
If the returned filter returns true then the methods of the service will be passed togetMethodInterceptors(Method)
to determine if a method should be intercepted and the constructor of the service will be passed togetConstructorInterceptors(Constructor)
to determine if the constructor should be intercepted- Returns:
- The filter that will be applied to a descriptor to determine if it is to be intercepted. Should not return null
-
getMethodInterceptors
List<org.aopalliance.intercept.MethodInterceptor> getMethodInterceptors(Method method)
Each non-final method of a service that passes thegetDescriptorFilter()
method will be passed to this method to determine if it will intercepted- Parameters:
method
- A non-final method that may be intercepted- Returns:
- if null (or an empty list) then this method should NOT be intercepted. Otherwise the list of interceptors to apply to this method
-
getConstructorInterceptors
List<org.aopalliance.intercept.ConstructorInterceptor> getConstructorInterceptors(Constructor<?> constructor)
The single chosen constructor of a service that passes thegetDescriptorFilter()
method will be passed to this method to determine if it will intercepted- Parameters:
constructor
- A constructor that may be intercepted- Returns:
- if null (or an empty list) then this constructor should NOT be intercepted. Otherwise the list of interceptors to apply to this method
-
-