Annotation Interface CommandHandlerInterceptor
AggregateMember. Command handler interceptor may intercept multiple
commands depending on inheritance hierarchy of commands or on command name pattern provided. Any incoming command
that matches the signature of the annotated method and the commandNamePattern() will be intercepted by
the annotated method.
It is possible to specify InterceptorChain parameter as part of command handler
interceptor signature. If this parameter is not specified, command handler will be executed automatically, as if
the InterceptorChain.proceed() was invoked as the last instruction.
If a parameter of type InterceptorChain is defined, it must be called to have the command handler invoked.
It may choose to return the result of the InterceptorChain.proceed() call directly, change it, or even
discard it.
Annotated methods that do not declare an InterceptorChain parameter must declare a void return type,
as they cannot alter the result of an invocation, other than by throwing an exception.
There are two ways to prevent command handler of specified command to be executed:
- Throwing an exception
- Specifying
InterceptorChainparameter and not callingInterceptorChain.proceed()method on it
It is possible to have multiple interceptors for the same command. In that case, if there are interceptors in both parent and child entity, the method in the parent entity will be invoked first. The order of invocation of interceptors within the same entity is not specified.
- Since:
- 3.3
- Author:
- Milan Savic
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionWill filter commands which names match this pattern and invoke handler only with those commands.Class<?> Specifies the type of message payload that can be handled by the member method.
-
Element Details
-
commandNamePattern
String commandNamePatternWill filter commands which names match this pattern and invoke handler only with those commands.- Returns:
- pattern used to filter command names
- Default:
".*"
-
payloadType
Class<?> payloadTypeSpecifies the type of message payload that can be handled by the member method. The payload of the message should be assignable to this type. Defaults to anyObject.- Default:
java.lang.Object.class
-