Class ValidatingInterceptor
java.lang.Object
io.fluxzero.sdk.tracking.handling.validation.ValidatingInterceptor
- All Implemented Interfaces:
HandlerDecorator, HandlerInterceptor
A
HandlerInterceptor that validates the payload of messages before they are handled. When the supplied
validator supports contextual method constraints, the current message context can be used to resolve constrained
method parameters.-
Nested Class Summary
Nested classes/interfaces inherited from interface HandlerDecorator
HandlerDecorator.MergedDecoratorNested classes/interfaces inherited from interface HandlerInterceptor
HandlerInterceptor.InterceptedHandler -
Field Summary
Fields inherited from interface HandlerDecorator
noOpFields inherited from interface HandlerInterceptor
defaultInterceptors -
Constructor Summary
ConstructorsConstructorDescriptionCreates an interceptor backed by the default validator.ValidatingInterceptor(Validator validator) Creates an interceptor backed by the supplied validator.ValidatingInterceptor(Validator validator, boolean validatePayload) Creates an interceptor backed by the supplied validator. -
Method Summary
Modifier and TypeMethodDescriptioninterceptHandling(Function<DeserializingMessage, Object> function, HandlerInvoker invoker) Wraps handler invocation with payload validation before invocation.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface HandlerDecorator
andThenMethods inherited from interface HandlerInterceptor
wrap
-
Constructor Details
-
ValidatingInterceptor
public ValidatingInterceptor()Creates an interceptor backed by the default validator. -
ValidatingInterceptor
Creates an interceptor backed by the supplied validator.- Parameters:
validator- the validator to use for payload and return value validation
-
ValidatingInterceptor
Creates an interceptor backed by the supplied validator.- Parameters:
validator- the validator to use for validationvalidatePayload- whether incoming message payloads should be validated before handler invocation
-
-
Method Details
-
interceptHandling
public Function<DeserializingMessage, Object> interceptHandling(Function<DeserializingMessage, Object> function, HandlerInvoker invoker) Wraps handler invocation with payload validation before invocation. Non-passive request handlers with a method annotation also get return value validation when the handler method declares return constraints.- Specified by:
interceptHandlingin interfaceHandlerInterceptor- Parameters:
function- handler invocation functioninvoker- handler metadata and invocation context- Returns:
- a validating handler invocation function
-