|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.axonframework.util.AbstractHandlerInspector
org.axonframework.util.AbstractHandlerInvoker
org.axonframework.commandhandling.annotation.AnnotationCommandHandlerAdapter
public class AnnotationCommandHandlerAdapter
Adapter that turns any @CommandHandler annotated bean into a CommandHandler implementation. Each annotated method is subscribed
as a CommandHandler at the CommandBus for the command type specified by the parameter of that method.
CommandHandler| Constructor Summary | |
|---|---|
AnnotationCommandHandlerAdapter(Object target,
CommandBus commandBus)
Initialize the command handler adapter for the given target which is to be subscribed with the given
commandBus. |
|
| Method Summary | |
|---|---|
Method |
findCommandHandlerMethodFor(Object command)
Returns the method that will be called to handle the given command. |
Object |
handle(Object command,
UnitOfWork unitOfWork)
Invokes the @CommandHandler annotated method that accepts the given command. |
protected Object |
onNoMethodFound(Class<?> parameterType)
Indicates what needs to happen when no handler is found for a given parameter. |
void |
subscribe()
Subscribe the command handlers to the command bus assigned during the initialization. |
void |
unsubscribe()
Unsubscribe the command handlers from the command bus assigned during the initialization. |
| Methods inherited from class org.axonframework.util.AbstractHandlerInvoker |
|---|
getTarget, invokeHandlerMethod, invokeHandlerMethod |
| 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 |
|---|
public AnnotationCommandHandlerAdapter(Object target,
CommandBus commandBus)
target which is to be subscribed with the given
commandBus.
Note that you need to call subscribe() to actually subscribe the command handlers to the command bus.
target - The object containing the @CommandHandler annotated methodscommandBus - The command bus to which the handlers must be subscribed| Method Detail |
|---|
public Object handle(Object command,
UnitOfWork unitOfWork)
throws Throwable
command.
handle in interface CommandHandler<Object>command - The command to handleunitOfWork - The UnitOfWork the command is processed in
Void.TYPE when the annotated handler has a
void return value.
NoHandlerForCommandException - when no handler is found for given command.
Throwable - any exception occurring while handling the command@PostConstruct public void subscribe()
subscribe in interface Subscribable@PreDestroy public void unsubscribe()
unsubscribe in interface Subscribableprotected Object onNoMethodFound(Class<?> parameterType)
AbstractHandlerInvokerVoid.TYPE.
onNoMethodFound in class AbstractHandlerInvokerparameterType - The type of parameter for which no handler could be found
Void.TYPE.public Method findCommandHandlerMethodFor(Object command)
null is no such method
is found.
command - The command to find the handler method for
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||