Interface Interceptor
public interface Interceptor
Each interceptor, configured on the method allows you to perform before, after or around interceptor logic according to your needs.
The
The
Interceptor is built around supporting Intercepting specific Operations, where an Operation is determined
by the user of the Interceptor. In the case of the EventStore examples of Operations are: AppendToStream, LoadLastPersistedEventRelatedTo,
LoadEvent, FetchStream, etc.
Recommendation:
Your concrete Interceptor should provide a method for each Concrete Operation following this pattern:
default <RESULT> intercept(ConcreteOperation operation, InterceptorChain<ConcreteOperation, RESULT> interceptorChain) {
return interceptorChain.proceed();
}
which allows concrete Interceptors to only override the Operations that it's concerned with
Example of using the InterceptorChain:
var result = InterceptorChain.newInterceptorChainForOperation(operation,
allInterceptorsConfigured,
(interceptor, interceptorChain) -> interceptorChain.intercept(operation, interceptorChain),
() -> performDefaultBehaviorForOperation(operation))
.proceed();
- See Also: