public class AnnotationCommandHandlerAdapter extends Object implements CommandHandler<Object>, Subscribable
@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 and Description |
|---|
AnnotationCommandHandlerAdapter(Object annotatedCommandHandler)
Wraps the given
annotatedCommandHandler, allowing it to be subscribed to a Command Bus. |
AnnotationCommandHandlerAdapter(Object target,
CommandBus commandBus)
Deprecated.
Use
AnnotationCommandHandlerAdapter(Object) and subscribe the handler to the command bus
using CommandBus.subscribe(String,
org.axonframework.commandhandling.CommandHandler). |
AnnotationCommandHandlerAdapter(Object annotatedCommandHandler,
ParameterResolverFactory parameterResolverFactory)
Wraps the given
annotatedCommandHandler, allowing it to be subscribed to a Command Bus. |
| Modifier and Type | Method and Description |
|---|---|
Object |
handle(CommandMessage<Object> command,
UnitOfWork unitOfWork)
Invokes the @CommandHandler annotated method that accepts the given
command. |
void |
subscribe()
Deprecated.
Instead, subscribe this instance using
CommandBus.subscribe(String,
org.axonframework.commandhandling.CommandHandler), using supportedCommands() to retrieve
the commands the annotated handler supports. |
static AnnotationCommandHandlerAdapter |
subscribe(Object annotatedCommandHandler,
CommandBus commandBus)
Subscribe the annotated command handler to the given command bus.
|
Set<String> |
supportedCommands()
Returns the set of commands supported by the annotated command handler managed by this adapter.
|
void |
unsubscribe()
Deprecated.
Instead, subscribe this instance using
CommandBus.subscribe(String,
org.axonframework.commandhandling.CommandHandler), using supportedCommands() to retrieve
the commands the annotated handler supports. |
@Deprecated public AnnotationCommandHandlerAdapter(Object target, CommandBus commandBus)
AnnotationCommandHandlerAdapter(Object) and subscribe the handler to the command bus
using CommandBus.subscribe(String,
org.axonframework.commandhandling.CommandHandler).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 subscribedpublic AnnotationCommandHandlerAdapter(Object annotatedCommandHandler)
annotatedCommandHandler, allowing it to be subscribed to a Command Bus.annotatedCommandHandler - The object containing the @CommandHandler annotated methodspublic AnnotationCommandHandlerAdapter(Object annotatedCommandHandler, ParameterResolverFactory parameterResolverFactory)
annotatedCommandHandler, allowing it to be subscribed to a Command Bus.annotatedCommandHandler - The object containing the @CommandHandler annotated methodsparameterResolverFactory - The strategy for resolving handler method parameter valuespublic 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 subscriptionpublic 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 innull 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 @Deprecated public void subscribe()
CommandBus.subscribe(String,
org.axonframework.commandhandling.CommandHandler), using supportedCommands() to retrieve
the commands the annotated handler supports.subscribe in interface Subscribable@PreDestroy @Deprecated public void unsubscribe()
CommandBus.subscribe(String,
org.axonframework.commandhandling.CommandHandler), using supportedCommands() to retrieve
the commands the annotated handler supports.unsubscribe in interface SubscribableCopyright © 2010-2014. All Rights Reserved.