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 theInterceptorChain. It's recommended to useInterceptorChain.newInterceptorChainForOperation(Object, List, BiFunction, Supplier)to create a new chain instance for a given operation
-
-
Constructor Summary
Constructors Constructor Description 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
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.StringtoString()
-
-
-
Constructor Detail
-
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 Detail
-
proceed
public RESULT 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
public OPERATION operation()
Description copied from interface:InterceptorChainThe operation details- Specified by:
operationin interfaceInterceptorChain<OPERATION,RESULT,INTERCEPTOR_TYPE extends Interceptor>- Returns:
- the operation details
-
-