Class ValidatingInterceptor

java.lang.Object
io.fluxzero.sdk.tracking.handling.validation.ValidatingInterceptor
All Implemented Interfaces:
HandlerDecorator, HandlerInterceptor

public class ValidatingInterceptor extends Object implements 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.
  • Constructor Details

    • ValidatingInterceptor

      public ValidatingInterceptor()
      Creates an interceptor backed by the default validator.
    • ValidatingInterceptor

      public ValidatingInterceptor(Validator validator)
      Creates an interceptor backed by the supplied validator.
      Parameters:
      validator - the validator to use for payload and return value validation
    • ValidatingInterceptor

      public ValidatingInterceptor(Validator validator, boolean validatePayload)
      Creates an interceptor backed by the supplied validator.
      Parameters:
      validator - the validator to use for validation
      validatePayload - 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:
      interceptHandling in interface HandlerInterceptor
      Parameters:
      function - handler invocation function
      invoker - handler metadata and invocation context
      Returns:
      a validating handler invocation function