org.axonframework.util
Class AbstractHandlerInvoker

java.lang.Object
  extended by org.axonframework.util.AbstractHandlerInspector
      extended by org.axonframework.util.AbstractHandlerInvoker
Direct Known Subclasses:
AnnotationCommandHandlerAdapter, AnnotationEventHandlerInvoker

public abstract class AbstractHandlerInvoker
extends AbstractHandlerInspector

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

Since:
0.6
Author:
Allard Buijze

Constructor Summary
AbstractHandlerInvoker(Object target, Class<? extends Annotation> annotationType)
          Initialize a handler invoker for the given target object that has handler method annotated with given annotationType.
 
Method Summary
 Object getTarget()
          Returns the target on which handler methods are invoked.
protected  Object invokeHandlerMethod(Object parameter)
          Invoke the handler demarcated with the given annotationClass on the target for the given event.
protected  Object invokeHandlerMethod(Object parameter, Object secondHandlerParameter)
          Invoke the handler demarcated with the given annotationClass on the target for the given event and an optional secondHandlerParameter.
protected  Object onNoMethodFound(Class<?> parameterType)
          Indicates what needs to happen when no handler is found for a given parameter.
 
Methods inherited from class org.axonframework.util.AbstractHandlerInspector
findHandlerMethod
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractHandlerInvoker

public AbstractHandlerInvoker(Object target,
                              Class<? extends Annotation> annotationType)
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
annotationType - The type of annotation used to demarcate the handler methods
Method Detail

invokeHandlerMethod

protected Object invokeHandlerMethod(Object parameter)
                              throws InvocationTargetException,
                                     IllegalAccessException
Invoke the handler demarcated with the given annotationClass on the target for the given event.

Parameters:
parameter - the event to handle
Returns:
the return value of the invocation
Throws:
IllegalAccessException - When a security policy prevents invocation using reflection
InvocationTargetException - If the handler method threw an exception

invokeHandlerMethod

protected Object invokeHandlerMethod(Object parameter,
                                     Object secondHandlerParameter)
                              throws InvocationTargetException,
                                     IllegalAccessException
Invoke the handler demarcated with the given annotationClass on the target for the given event and an optional secondHandlerParameter.

Parameters:
parameter - the event to handle
secondHandlerParameter - An optional second parameter allowed on the annotated method
Returns:
the return value of the invocation
Throws:
IllegalAccessException - When a security policy prevents invocation using reflection
InvocationTargetException - If the handler method threw an exception

onNoMethodFound

protected Object onNoMethodFound(Class<?> parameterType)
Indicates what needs to happen when no handler is found for a given parameter. The default behavior is to return Void.TYPE.

Parameters:
parameterType - The type of parameter for which no handler could be found
Returns:
the value to return when no handler method is found. Defaults to Void.TYPE.

getTarget

public Object getTarget()
Returns the target on which handler methods are invoked.

Returns:
the target on which handler methods are invoked


Copyright © 2011. All Rights Reserved.