org.axonframework.common.annotation
Class MethodMessageHandlerInspector

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

public final class MethodMessageHandlerInspector
extends Object

Utility class that inspects handler methods for a given class and handler definition. For each handler method, it keeps track of a MethodMessageHandler that describes the capabilities of that method (in terms of supported messages).

Since:
2.0
Author:
Allard Buijze

Method Summary
static void clearCache()
          Clears the cached message handlers.
 MethodMessageHandler findHandlerMethod(Message message)
          Returns the handler method that handles objects of the given parameterType.
 List<MethodMessageHandler> getHandlers()
          Returns the list of handlers found on target type.
static
<T extends Annotation>
MethodMessageHandlerInspector
getInstance(Class<?> handlerClass, Class<T> annotationType, ParameterResolverFactory parameterResolverFactory, boolean allowDuplicates)
          Returns a MethodMessageHandlerInspector for the given handlerClass that contains handler methods annotated with the given annotationType.
static MethodMessageHandlerInspector getInstance(Class<?> handlerClass, ParameterResolverFactory parameterResolverFactory, boolean allowDuplicates, HandlerDefinition<? super Method> handlerDefinition)
          Returns a MethodMessageHandlerInspector for the given handlerClass that contains handler methods annotated with the given annotationType.
 Class<?> getTargetType()
          Returns the targetType on which handler methods are invoked.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static <T extends Annotation> MethodMessageHandlerInspector getInstance(Class<?> handlerClass,
                                                                               Class<T> annotationType,
                                                                               ParameterResolverFactory parameterResolverFactory,
                                                                               boolean allowDuplicates)
Returns a MethodMessageHandlerInspector for the given handlerClass that contains handler methods annotated with the given annotationType. The allowDuplicates will indicate whether it is acceptable to have multiple handlers listening to Messages with the same payload type. Basically, this should always be false, unless some a property other than the payload of the Message is used to route the Message to a handler.

Type Parameters:
T - The type of annotation used to mark handler methods
Parameters:
handlerClass - The Class containing the handler methods to evaluate
annotationType - The annotation marking handler methods
parameterResolverFactory - The strategy for resolving parameter value for handler methods
allowDuplicates - Indicates whether to accept multiple handlers listening to Messages with the same payload type
Returns:
a MethodMessageHandlerInspector providing access to the handler methods

getInstance

public static MethodMessageHandlerInspector getInstance(Class<?> handlerClass,
                                                        ParameterResolverFactory parameterResolverFactory,
                                                        boolean allowDuplicates,
                                                        HandlerDefinition<? super Method> handlerDefinition)
Returns a MethodMessageHandlerInspector for the given handlerClass that contains handler methods annotated with the given annotationType. The allowDuplicates will indicate whether it is acceptable to have multiple handlers listening to Messages with the same payload type. Basically, this should always be false, unless some a property other than the payload of the Message is used to route the Message to a handler.

This method attempts to return an existing inspector instance. It will do so when it detects an instance for the same handler class and for the same annotation type, that uses the same parameterResolverFactory.

Parameters:
handlerClass - The Class containing the handler methods to evaluate
parameterResolverFactory - The strategy for resolving parameter value for handler methods
allowDuplicates - Indicates whether to accept multiple handlers listening to Messages with the same payload type
handlerDefinition - The definition indicating which methods are message handlers
Returns:
a MethodMessageHandlerInspector providing access to the handler methods

clearCache

public static void clearCache()
Clears the cached message handlers. This method needs to be called if the underlying inspectors change for this VM. This may happen when running multiple test cases in the same JVM, since each test case may be using new implementations, for instance a new spring context per-test.


findHandlerMethod

public MethodMessageHandler findHandlerMethod(Message message)
Returns the handler method that handles objects of the given parameterType. Returns null is no such method is found.

Parameters:
message - The message to find a handler for
Returns:
the handler method for the given parameterType

getHandlers

public List<MethodMessageHandler> getHandlers()
Returns the list of handlers found on target type.

Returns:
the list of handlers found on target type

getTargetType

public Class<?> getTargetType()
Returns the targetType on which handler methods are invoked.

Returns:
the targetType on which handler methods are invoked


Copyright © 2010-2016. All Rights Reserved.