Class DefaultInterceptionService
- java.lang.Object
-
- org.glassfish.hk2.extras.interception.internal.DefaultInterceptionService
-
- All Implemented Interfaces:
InterceptionService
@Singleton @Visibility(LOCAL) public class DefaultInterceptionService extends java.lang.Object implements InterceptionService
A default implementation of the interception service using annotation to denote services that are to be intercepted and other annotations to match methods or constructors to interceptors
-
-
Field Summary
Fields Modifier and Type Field Description private static IndexedFilter
CONSTRUCTOR_FILTER
private ServiceLocator
locator
private static IndexedFilter
METHOD_FILTER
private IterableProvider<InterceptorOrderingService>
orderers
-
Constructor Summary
Constructors Constructor Description DefaultInterceptionService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<org.aopalliance.intercept.ConstructorInterceptor>
getConstructorInterceptors(java.lang.reflect.Constructor<?> constructor)
The single chosen constructor of a service that passes theInterceptionService.getDescriptorFilter()
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 toInterceptionService.getMethodInterceptors(Method)
to determine if a method should be intercepted and the constructor of the service will be passed toInterceptionService.getConstructorInterceptors(Constructor)
to determine if the constructor should be interceptedjava.util.List<org.aopalliance.intercept.MethodInterceptor>
getMethodInterceptors(java.lang.reflect.Method method)
Each non-final method of a service that passes theInterceptionService.getDescriptorFilter()
method will be passed to this method to determine if it will interceptedprivate java.util.List<ServiceHandle<org.aopalliance.intercept.ConstructorInterceptor>>
orderConstructors(java.lang.reflect.Constructor<?> constructor, java.util.List<ServiceHandle<org.aopalliance.intercept.ConstructorInterceptor>> current)
private java.util.List<ServiceHandle<org.aopalliance.intercept.MethodInterceptor>>
orderMethods(java.lang.reflect.Method method, java.util.List<ServiceHandle<org.aopalliance.intercept.MethodInterceptor>> current)
-
-
-
Field Detail
-
METHOD_FILTER
private static final IndexedFilter METHOD_FILTER
-
CONSTRUCTOR_FILTER
private static final IndexedFilter CONSTRUCTOR_FILTER
-
locator
@Inject private ServiceLocator locator
-
orderers
@Inject private IterableProvider<InterceptorOrderingService> orderers
-
-
Method Detail
-
getDescriptorFilter
public Filter getDescriptorFilter()
Description copied from interface:InterceptionService
If the returned filter returns true then the methods of the service will be passed toInterceptionService.getMethodInterceptors(Method)
to determine if a method should be intercepted and the constructor of the service will be passed toInterceptionService.getConstructorInterceptors(Constructor)
to determine if the constructor should be intercepted- Specified by:
getDescriptorFilter
in interfaceInterceptionService
- Returns:
- The filter that will be applied to a descriptor to determine if it is to be intercepted. Should not return null
-
orderMethods
private java.util.List<ServiceHandle<org.aopalliance.intercept.MethodInterceptor>> orderMethods(java.lang.reflect.Method method, java.util.List<ServiceHandle<org.aopalliance.intercept.MethodInterceptor>> current)
-
orderConstructors
private java.util.List<ServiceHandle<org.aopalliance.intercept.ConstructorInterceptor>> orderConstructors(java.lang.reflect.Constructor<?> constructor, java.util.List<ServiceHandle<org.aopalliance.intercept.ConstructorInterceptor>> current)
-
getMethodInterceptors
public java.util.List<org.aopalliance.intercept.MethodInterceptor> getMethodInterceptors(java.lang.reflect.Method method)
Description copied from interface:InterceptionService
Each non-final method of a service that passes theInterceptionService.getDescriptorFilter()
method will be passed to this method to determine if it will intercepted- Specified by:
getMethodInterceptors
in interfaceInterceptionService
- 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
public java.util.List<org.aopalliance.intercept.ConstructorInterceptor> getConstructorInterceptors(java.lang.reflect.Constructor<?> constructor)
Description copied from interface:InterceptionService
The single chosen constructor of a service that passes theInterceptionService.getDescriptorFilter()
method will be passed to this method to determine if it will intercepted- Specified by:
getConstructorInterceptors
in interfaceInterceptionService
- 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
-
-