org.axonframework.common.annotation
Class MethodMessageHandler

java.lang.Object
  extended by org.axonframework.common.annotation.AbstractMessageHandler
      extended by org.axonframework.common.annotation.MethodMessageHandler
All Implemented Interfaces:
Comparable<AbstractMessageHandler>

public final class MethodMessageHandler
extends AbstractMessageHandler

Represents a method recognized as a handler by the handler inspector (see MethodMessageHandlerInspector).

Since:
2.0
Author:
Allard Buijze

Method Summary
static MethodMessageHandler createFor(Method method, Class<?> explicitPayloadType, ParameterResolverFactory parameterResolverFactory)
          Creates a MethodMessageHandler for the given method, using given explicitPayloadType (if not null) defining the payload of the message it supports.
 boolean equals(Object o)
           
<T extends Annotation>
T
getAnnotation(Class<T> annotationType)
          Returns the member-level annotation of given annotationType, or null if no such annotation is present.
 Method getMethod()
          Returns the Method backing this handler.
 String getMethodName()
          Returns the name of the method backing this handler.
 int hashCode()
           
 Object invoke(Object target, Message message)
          Invokes this handler for the given target instance, using the given message as source object to provide parameter values.
 String toString()
           
 
Methods inherited from class org.axonframework.common.annotation.AbstractMessageHandler
compareTo, findResolvers, getParameterValueResolvers, getPayloadType, matches
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

createFor

public static MethodMessageHandler createFor(Method method,
                                             Class<?> explicitPayloadType,
                                             ParameterResolverFactory parameterResolverFactory)
Creates a MethodMessageHandler for the given method, using given explicitPayloadType (if not null) defining the payload of the message it supports. If null, the payload type is deducted from the first parameter of the method.

Parameters:
method - The method to create a Handler for
explicitPayloadType - The payload type explicitly defined on the method, or null
parameterResolverFactory - The strategy for resolving parameter values of handler methods
Returns:
The MethodMessageHandler implementation for the given method.
Throws:
UnsupportedHandlerException - if the given method is not suitable as a Handler

invoke

public Object invoke(Object target,
                     Message message)
              throws InvocationTargetException,
                     IllegalAccessException
Description copied from class: AbstractMessageHandler
Invokes this handler for the given target instance, using the given message as source object to provide parameter values.

Specified by:
invoke in class AbstractMessageHandler
Parameters:
target - The target instance to invoke the Handler on.
message - The message providing parameter values
Returns:
The result of the handler invocation
Throws:
InvocationTargetException - when the handler throws a checked exception
IllegalAccessException - if the SecurityManager refuses the handler invocation

getAnnotation

public <T extends Annotation> T getAnnotation(Class<T> annotationType)
Description copied from class: AbstractMessageHandler
Returns the member-level annotation of given annotationType, or null if no such annotation is present.

Specified by:
getAnnotation in class AbstractMessageHandler
Type Parameters:
T - The type of annotation to retrieve
Parameters:
annotationType - The type of annotation to retrieve
Returns:
the annotation instance, or null if no such annotation is present.

getMethodName

public String getMethodName()
Returns the name of the method backing this handler.

Returns:
the name of the method backing this handler

getMethod

public Method getMethod()
Returns the Method backing this handler.

Returns:
the Method backing this handler

toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object o)
Overrides:
equals in class AbstractMessageHandler

hashCode

public int hashCode()
Overrides:
hashCode in class AbstractMessageHandler


Copyright © 2010-2016. All Rights Reserved.