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 the 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 Provider or IterableProvider when injecting dependent services so that these services are not instantiated when the InterceptionService is created

    • Method Detail

      • getDescriptorFilter

        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:
        The filter that will be applied to a descriptor to determine if it is to be intercepted. Should not return null
      • getMethodInterceptors

        java.util.List<org.aopalliance.intercept.MethodInterceptor> getMethodInterceptors​(java.lang.reflect.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 - 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

        java.util.List<org.aopalliance.intercept.ConstructorInterceptor> getConstructorInterceptors​(java.lang.reflect.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 - 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