T
- The type of entity to which the message handler will delegate the actual handling of the messagepublic interface MessageHandlingMember<T>
Modifier and Type | Method and Description |
---|---|
Optional<Map<String,Object>> |
annotationAttributes(Class<? extends Annotation> annotationType)
Get the attributes of an annotation of given
annotationType on the method of the target entity. |
boolean |
canHandle(Message<?> message)
Checks if this handler is capable of handling the given
message . |
default boolean |
canHandleType(Class<?> payloadType)
Checks if this handler is capable of handling messages with the given
payloadType . |
default Class<?> |
declaringClass()
Gets the declaring class of this Message Handling Member.
|
Object |
handle(Message<?> message,
T target)
Handles the given
message by invoking the appropriate method on given target . |
boolean |
hasAnnotation(Class<? extends Annotation> annotationType)
Checks whether the method of the target entity contains the given
annotationType . |
Class<?> |
payloadType()
Returns the payload type of messages that can be processed by this handler.
|
default int |
priority()
Returns a number representing the priority of this handler over other handlers capable of processing the same
message.
|
<HT> Optional<HT> |
unwrap(Class<HT> handlerType)
Returns the wrapped handler object if its type is an instance of the given
handlerType . |
Class<?> payloadType()
default int priority()
In general, a handler with a higher priority will receive the message before (or instead of) handlers with a lower priority. However, the priority value may not be the only indicator that is used to determine the order of invocation. For instance, a message processor may decide to ignore the priority value if one message handler is a more specific handler of the message than another handler.
boolean canHandle(Message<?> message)
message
.message
- The message that is to be handledtrue
if the handler is capable of handling the message, false
otherwisedefault boolean canHandleType(Class<?> payloadType)
payloadType
.payloadType
- The payloadType of a message that is to be handledtrue
if the handler is capable of handling the message with given type, false
otherwiseObject handle(Message<?> message, T target) throws Exception
message
by invoking the appropriate method on given target
. This may result in
an exception if the given target is not capable of handling the message or if an exception is thrown during
invocation of the method.message
- The message to handletarget
- The target to handle the messageException
- when there was a problem that prevented invocation of the method or if an exception was thrown
from the invoked method<HT> Optional<HT> unwrap(Class<HT> handlerType)
handlerType
. For instance, if
this method is invoked with Executable
and the message is handled by a method of the
target entity, then this method will return the method handle as a Method
.HT
- The wrapped handler typehandlerType
- The expected type of the wrapped handlerdefault Class<?> declaringClass()
boolean hasAnnotation(Class<? extends Annotation> annotationType)
annotationType
.annotationType
- Annotation to check for on the target methodtrue
if the annotation is present on the target method, false
otherwiseOptional<Map<String,Object>> annotationAttributes(Class<? extends Annotation> annotationType)
annotationType
on the method of the target entity. If the
annotation is present on the target method an Optional is returned containing the properties mapped by their
name. If the annotation is not present an empty Optional is returned.annotationType
- The annotation to check for on the target methodCopyright © 2010–2020. All rights reserved.