public class AnnotationCommandHandlerAdapter<T> extends Object implements CommandMessageHandler
@CommandHandler
annotated bean into a MessageHandler
implementation. Each annotated method is subscribed as a Command Handler at the CommandBus
for the command
type specified by the parameter of that method.CommandHandler
Constructor and Description |
---|
AnnotationCommandHandlerAdapter(T annotatedCommandHandler)
Wraps the given
annotatedCommandHandler , allowing it to be subscribed to a Command Bus. |
AnnotationCommandHandlerAdapter(T annotatedCommandHandler,
ParameterResolverFactory parameterResolverFactory)
Wraps the given
annotatedCommandHandler , allowing it to be subscribed to a Command Bus. |
AnnotationCommandHandlerAdapter(T annotatedCommandHandler,
ParameterResolverFactory parameterResolverFactory,
HandlerDefinition handlerDefinition)
Wraps the given
annotatedCommandHandler , allowing it to be subscribed to a Command Bus. |
Modifier and Type | Method and Description |
---|---|
boolean |
canHandle(CommandMessage<?> message)
Indicates whether this handler can handle the given message
|
Object |
handle(CommandMessage<?> command)
Invokes the
@CommandHandler annotated method that accepts the given
command . |
Registration |
subscribe(CommandBus commandBus)
Subscribe this command handler to the given
commandBus . |
Set<String> |
supportedCommandNames()
Returns the set of command names this handler supports.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
canHandleType, getTargetType
public AnnotationCommandHandlerAdapter(T annotatedCommandHandler)
annotatedCommandHandler
, allowing it to be subscribed to a Command Bus.annotatedCommandHandler
- The object containing the @CommandHandler annotated methodspublic AnnotationCommandHandlerAdapter(T 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 AnnotationCommandHandlerAdapter(T annotatedCommandHandler, ParameterResolverFactory parameterResolverFactory, HandlerDefinition handlerDefinition)
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 valueshandlerDefinition
- The handler definition used to create concrete handlerspublic Registration subscribe(CommandBus commandBus)
commandBus
. The command handler will be subscribed for each
of the supported commands.commandBus
- The command bus instance to subscribe topublic Object handle(CommandMessage<?> command) throws Exception
@CommandHandler
annotated method that accepts the given
command
.handle
in interface MessageHandler<CommandMessage<?>>
command
- The command to handle.null
when the annotated handler has a void
return
value.NoHandlerForCommandException
- When no handler is found for given command
.Exception
- Any exception occurring while handling the command.public boolean canHandle(CommandMessage<?> message)
MessageHandler
canHandle
in interface MessageHandler<CommandMessage<?>>
message
- The message to verifytrue
if this handler can handle the message, otherwise false
public Set<String> supportedCommandNames()
CommandMessageHandler
supportedCommandNames
in interface CommandMessageHandler
Copyright © 2010–2024. All rights reserved.