|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object 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 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. |
Method Summary | |
---|---|
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 void |
subscribe(AnnotationCommandHandlerAdapter annotationCommandHandler,
CommandBus commandBus)
Subscribe the given annotationCommandHandler to the given commandBus . |
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
@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 valuesMethod 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 static void subscribe(AnnotationCommandHandlerAdapter annotationCommandHandler, CommandBus commandBus)
annotationCommandHandler
to the given commandBus
. The
command handler will be subscribed for each of the supported commands.
annotationCommandHandler
- The fully configured AnnotationCommandHandlerAdapter instance to subscribecommandBus
- The command bus instance to subscribe topublic 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 @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 Subscribable
public Set<String> supportedCommands()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |