Class DefaultInterceptorChain<OPERATION,RESULT,INTERCEPTOR_TYPE extends Interceptor>
java.lang.Object
dk.cloudcreate.essentials.shared.interceptor.DefaultInterceptorChain<OPERATION,RESULT,INTERCEPTOR_TYPE>
- Type Parameters:
OPERATION- the type of operation to intercept, aka. the argument to the interceptorRESULT- the result of the operation
- All Implemented Interfaces:
InterceptorChain<OPERATION,RESULT, INTERCEPTOR_TYPE>
public class DefaultInterceptorChain<OPERATION,RESULT,INTERCEPTOR_TYPE extends Interceptor>
extends Object
implements InterceptorChain<OPERATION,RESULT,INTERCEPTOR_TYPE>
Default implementation for the
InterceptorChain. It's recommended to use
InterceptorChain.newInterceptorChainForOperation(Object, List, BiFunction, Supplier) to create a new chain
instance for a given operation-
Constructor Summary
ConstructorsConstructorDescriptionDefaultInterceptorChain(OPERATION operation, List<INTERCEPTOR_TYPE> interceptors, BiFunction<INTERCEPTOR_TYPE, InterceptorChain<OPERATION, RESULT, INTERCEPTOR_TYPE>, RESULT> interceptorMethodInvoker, Supplier<RESULT> defaultBehaviour) Create a newInterceptorChaininstance for the providedoperation -
Method Summary
Modifier and TypeMethodDescriptionThe operation detailsproceed()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.toString()
-
Constructor Details
-
DefaultInterceptorChain
public DefaultInterceptorChain(OPERATION operation, List<INTERCEPTOR_TYPE> interceptors, BiFunction<INTERCEPTOR_TYPE, InterceptorChain<OPERATION, RESULT, INTERCEPTOR_TYPE>, RESULT> interceptorMethodInvoker, Supplier<RESULT> defaultBehaviour) Create a newInterceptorChaininstance for the providedoperation- 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
-
-
Method Details
-
proceed
Description copied from interface:InterceptorChainTo 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 callInterceptorChain.proceed()- Specified by:
proceedin interfaceInterceptorChain<OPERATION,RESULT, INTERCEPTOR_TYPE extends Interceptor> - Returns:
- the result of the operation
-
operation
Description copied from interface:InterceptorChainThe operation details- Specified by:
operationin interfaceInterceptorChain<OPERATION,RESULT, INTERCEPTOR_TYPE extends Interceptor> - Returns:
- the operation details
-
toString
-