Class BeanValidationInterceptor<T extends Message<?>>

java.lang.Object
org.axonframework.messaging.interceptors.legacyvalidation.BeanValidationInterceptor<T>
All Implemented Interfaces:
MessageDispatchInterceptor<T>, MessageHandlerInterceptor<T>

@Deprecated public class BeanValidationInterceptor<T extends Message<?>> extends Object implements MessageHandlerInterceptor<T>, MessageDispatchInterceptor<T>
Deprecated.
in favor of using BeanValidationInterceptor which moved to jakarta.
Interceptor that applies JSR303 bean validation on incoming Messages. When validation on a message fails, a JSR303ViolationException is thrown, holding the constraint violations. This interceptor can either be used as a MessageHandlerInterceptor or as a MessageDispatchInterceptor.
Since:
1.1
Author:
Allard Buijze
  • Constructor Details

    • BeanValidationInterceptor

      public BeanValidationInterceptor()
      Deprecated.
      Initializes a validation interceptor using a default ValidatorFactory.
      See Also:
      • Validation.buildDefaultValidatorFactory()
    • BeanValidationInterceptor

      public BeanValidationInterceptor(javax.validation.ValidatorFactory validatorFactory)
      Deprecated.
      Initializes a validation interceptor using the given ValidatorFactory.
      Parameters:
      validatorFactory - the factory providing Validator instances for this interceptor
  • Method Details

    • handle

      public Object handle(@Nonnull UnitOfWork<? extends T> unitOfWork, @Nonnull InterceptorChain interceptorChain) throws Exception
      Deprecated.
      Description copied from interface: MessageHandlerInterceptor
      Invoked before a Message is handled by a designated MessageHandler.

      The interceptor is responsible for the continuation of the handling process by invoking the InterceptorChain.proceed() method on the given interceptorChain.

      The given unitOfWork contains contextual information. Any information gathered by interceptors may be attached to the unitOfWork.

      Interceptors are highly recommended not to change the type of the message handling result, as the dispatching component might expect a result of a specific type.

      Specified by:
      handle in interface MessageHandlerInterceptor<T extends Message<?>>
      Parameters:
      unitOfWork - The UnitOfWork that is processing the message
      interceptorChain - The interceptor chain that allows this interceptor to proceed the dispatch process
      Returns:
      the result of the message handler. May have been modified by interceptors.
      Throws:
      Exception - any exception that occurs while handling the message
    • handle

      @Nonnull public BiFunction<Integer,T,T> handle(@Nonnull List<? extends T> messages)
      Deprecated.
      Description copied from interface: MessageDispatchInterceptor
      Apply this interceptor to the given list of messages. This method returns a function that can be invoked to obtain a modified version of messages at each position in the list.
      Specified by:
      handle in interface MessageDispatchInterceptor<T extends Message<?>>
      Parameters:
      messages - The Messages to pre-process
      Returns:
      a function that processes messages based on their position in the list
    • validateMessage

      protected Set<javax.validation.ConstraintViolation<Object>> validateMessage(Object message, javax.validation.Validator validator)
      Deprecated.
      Validate the given message using the given validator. The default implementation merely calls validator.validate(message).

      Subclasses may override this method to alter the validation behavior in specific cases. Although the null is accepted as return value to indicate that there are no constraint violations, implementations are encouraged to return an empty Set instead.

      Parameters:
      message - the message to validate
      validator - the validator provided by the validator factory
      Returns:
      a set of ConstraintViolations. May also return null