org.axonframework.common.annotation
Class MessageHandlerInvoker

java.lang.Object
  extended by org.axonframework.common.annotation.MessageHandlerInvoker

public final class MessageHandlerInvoker
extends Object

Abstract class to support implementations that need to invoke methods based on an annotation.

Since:
0.6
Author:
Allard Buijze

Constructor Summary
MessageHandlerInvoker(Object target, ParameterResolverFactory parameterResolverFactory, boolean allowDuplicates, HandlerDefinition<? super Method> handlerDefinition)
          Initialize a handler invoker for the given target object that has handler method annotated with given annotationType.
 
Method Summary
 MethodMessageHandler findHandlerMethod(Message message)
          Finds the handler method that can handle the given message, or null if no such handler exists.
 Class getTargetType()
          Returns the targetType on which handler methods are invoked.
 Object invokeHandlerMethod(Message parameter)
          Invoke the handler demarcated with the given annotationClass on the target for the given event.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageHandlerInvoker

public MessageHandlerInvoker(Object target,
                             ParameterResolverFactory parameterResolverFactory,
                             boolean allowDuplicates,
                             HandlerDefinition<? super Method> handlerDefinition)
Initialize a handler invoker for the given target object that has handler method annotated with given annotationType.

Parameters:
target - The target to invoke methods on
parameterResolverFactory - The factory to create ParameterResolvers with
allowDuplicates - Whether or not to accept multiple message handlers with the same payload type
handlerDefinition - The definition indicating which methods are message handlers
Method Detail

invokeHandlerMethod

public Object invokeHandlerMethod(Message parameter)
Invoke the handler demarcated with the given annotationClass on the target for the given event. Returns the result of the execution of the handler method, or null if no suitable handler was found.

Parameters:
parameter - the event to handle
Returns:
the return value of the invocation
Throws:
MessageHandlerInvocationException - when a checked exception is thrown by the handler method

findHandlerMethod

public MethodMessageHandler findHandlerMethod(Message message)
Finds the handler method that can handle the given message, or null if no such handler exists.

Parameters:
message - The message to find a handler for
Returns:
The handler for the given message, or null if none exists

getTargetType

public Class getTargetType()
Returns the targetType on which handler methods are invoked. This is the runtime type of the object that contains the method that handles the messages (not per se the Class that declares the method).

Returns:
the targetType on which handler methods are invoked


Copyright © 2010-2016. All Rights Reserved.