Interface InterceptorChain<OPERATION,RESULT,INTERCEPTOR_TYPE extends Interceptor>
-
- Type Parameters:
OPERATION- the type of operation to intercept, aka. the argument to the interceptorRESULT- the result of the operationINTERCEPTOR_TYPE- The type of interceptor
- All Known Implementing Classes:
DefaultInterceptorChain
public interface InterceptorChain<OPERATION,RESULT,INTERCEPTOR_TYPE extends Interceptor>Generic interceptor chain concept that supports intercepting concreteInterceptoroperations to modify the behaviour or add to the default behaviour
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static <OPERATION,RESULT,INTERCEPTOR_TYPE extends Interceptor>
InterceptorChain<OPERATION,RESULT,INTERCEPTOR_TYPE>newInterceptorChainForOperation(OPERATION operation, List<INTERCEPTOR_TYPE> interceptors, BiFunction<INTERCEPTOR_TYPE,InterceptorChain<OPERATION,RESULT,INTERCEPTOR_TYPE>,RESULT> interceptorMethodInvoker, Supplier<RESULT> defaultBehaviour)Create a newInterceptorChaininstance for the providedoperationinstance
InterceptorChaininstances are not reusable across different operation instances.
Example:OPERATIONoperation()The operation detailsRESULTproceed()To continue the processing aInterceptorwill call this method, which in turn will call otherInterceptor's (if more interceptors are configured) and finally the default implementation will be called.
If theInterceptorcan provide a result without calling the default behaviour then it can just return its (e.g.
-
-
-
Method Detail
-
proceed
RESULT proceed()
To continue the processing aInterceptorwill call this method, which in turn will call otherInterceptor's (if more interceptors are configured) and finally the default implementation will be called.
If theInterceptorcan provide a result without calling the default behaviour then it can just return its (e.g. cached) result and not callproceed()- Returns:
- the result of the operation
-
operation
OPERATION operation()
The operation details- Returns:
- the operation details
-
newInterceptorChainForOperation
static <OPERATION,RESULT,INTERCEPTOR_TYPE extends Interceptor> InterceptorChain<OPERATION,RESULT,INTERCEPTOR_TYPE> newInterceptorChainForOperation(OPERATION operation, List<INTERCEPTOR_TYPE> interceptors, BiFunction<INTERCEPTOR_TYPE,InterceptorChain<OPERATION,RESULT,INTERCEPTOR_TYPE>,RESULT> interceptorMethodInvoker, Supplier<RESULT> defaultBehaviour)
Create a newInterceptorChaininstance for the providedoperationinstance
InterceptorChaininstances are not reusable across different operation instances.
Example:var result = newInterceptorChainForOperation(operation, allInterceptorsConfigured, (interceptor, interceptorChain) -> interceptorChain.intercept(operation, interceptorChain), () -> performDefaultBehaviorForOperation(operation) ).proceed();- Type Parameters:
OPERATION- the type of operation to intercept, aka. the argument to the interceptorRESULT- the result of the operation- Parameters:
operation- the operation to intercept, aka. the argument to the interceptorinterceptors- theInterceptor's (can be an empty List if no interceptors have been configured)interceptorMethodInvoker- the function that's responsible for invoking the matchingInterceptormethoddefaultBehaviour- the default behaviour for the givenoperationin case none of the interceptors provided a different result and stopped the interceptor chain- Returns:
- a new
InterceptorChaininstance for the providedoperation
-
-