@Documented @Retention(value=RUNTIME) @Target(value={METHOD,ANNOTATION_TYPE}) public @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:
InterceptorChain
parameter and not calling InterceptorChain.proceed()
method on itIt 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.
Modifier and Type | Optional Element and Description |
---|---|
String |
commandNamePattern
Will filter commands which names match this pattern and invoke handler only with those commands.
|
Class<?> |
payloadType
Specifies the type of message payload that can be handled by the member method.
|
public abstract String commandNamePattern
Copyright © 2010–2022. All rights reserved.