Interface InterceptorOrderingService


@Contract public interface InterceptorOrderingService
This service can be used to modify, add or remove interceptors to the set of interceptors that will be called on a Method or Constructor in the default implementation of the interception service. If there are multiple implementations of this service then they will be called in the natural hk2 ordering of services with the result of the method being fed into the next service.
  • Method Summary

    Modifier and Type
    Method
    Description
    List<ServiceHandle<org.aopalliance.intercept.ConstructorInterceptor>>
    modifyConstructorInterceptors(Constructor<?> constructor, List<ServiceHandle<org.aopalliance.intercept.ConstructorInterceptor>> currentList)
    This method is called for each constructor that may be intercepted by the default interception service.
    List<ServiceHandle<org.aopalliance.intercept.MethodInterceptor>>
    modifyMethodInterceptors(Method method, List<ServiceHandle<org.aopalliance.intercept.MethodInterceptor>> currentList)
    This method is called for each method that may be intercepted by the default interception service.
  • Method Details

    • modifyMethodInterceptors

      List<ServiceHandle<org.aopalliance.intercept.MethodInterceptor>> modifyMethodInterceptors(Method method, List<ServiceHandle<org.aopalliance.intercept.MethodInterceptor>> currentList)
      This method is called for each method that may be intercepted by the default interception service. The incoming list is not modifiable. If this method returns null then the original list (the list passed in) will be used as-is. If this method does NOT return null then the list returned will be the list that will be used to intercept the given method. This means that the interceptors can be removed (if an empty list is returned) or modified. Modifications can include changes of order, additions and/or removals of the interceptors passed into the method. If this method throws an exception the exception will be ignored and the interceptor list passed in will be used.

      If the implementation would like to return MethodInterceptors that are not hk2 services it is recommended that they use BuilderHelper.createConstantServiceHandle(Object) to create ServiceHandles representing their MethodInterceptors.

      Parameters:
      method - The method that is to be intercepted
      currentList - The list that will be used to intercept the method if this service returns null
      Returns:
      A non-null list of interceptors to use when intercepting this method. The returned list must be ordered. If this method returns null then the list passed in will be used
    • modifyConstructorInterceptors

      List<ServiceHandle<org.aopalliance.intercept.ConstructorInterceptor>> modifyConstructorInterceptors(Constructor<?> constructor, List<ServiceHandle<org.aopalliance.intercept.ConstructorInterceptor>> currentList)
      This method is called for each constructor that may be intercepted by the default interception service. The incoming list is not modifiable. If this method returns null then the original list (the list passed in) will be used as-is. If this method does NOT return null then the list returned will be the list that will be used to intercept the given constructor. This means that the interceptors can be removed (if an empty list is returned) or modified. Modifications can include changes of order, additions and/or removals of the interceptors passed into the method. If this method throws an exception the exception will be ignored and the interceptor list passed in will be used.

      If the implementation would like to return ConstructorInterceptors that are not hk2 services it is recommended that they use BuilderHelper.createConstantServiceHandle(Object) to create ServiceHandles representing their ConstructorInterceptors.

      Parameters:
      constructor - The constructor that is to be intercepted
      currentList - The list that will be used to intercept the constructor if this service returns null
      Returns:
      A non-null list of interceptors to use when intercepting this constructor. The returned list must be ordered. If this method returns null then the list passed in will be used