|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.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 | |
|---|---|
Object |
handle(CommandMessage<Object> command,
UnitOfWork unitOfWork)
Invokes the @CommandHandler annotated method that accepts the given command. |
void |
subscribe()
Subscribe the command handlers to the command bus assigned during the initialization. |
static AnnotationCommandHandlerAdapter |
subscribe(Object annotatedCommandHandler,
CommandBus commandBus)
Subscribe the annotated command handler to the given command bus. |
void |
unsubscribe()
Unsubscribe the command handlers from the command bus assigned during the initialization. |
| 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 static AnnotationCommandHandlerAdapter subscribe(Object annotatedCommandHandler,
CommandBus commandBus)
annotatedCommandHandler - The annotated command handler that is to be subscribed to the command buscommandBus - The command bus that gets the handler's subscription
public Object handle(CommandMessage<Object> command,
UnitOfWork unitOfWork)
throws Throwable
command.
handle in interface CommandHandler<Object>command - The command to handleunitOfWork - The UnitOfWork the command is processed in
null 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 Subscribable
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||