|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.axonframework.commandhandling.SimpleCommandBus
public class SimpleCommandBus
Implementation of the CommandBus that dispatches commands to the handlers subscribed to that specific type of command. Interceptors may be configured to add processing to commands regardless of their type, for example logging, security (authorization), sla monitoring, etc.
This class can be monitored as the implementation of theStatisticsProvider interface indicates.
| Constructor Summary | |
|---|---|
SimpleCommandBus()
Initializes the SimpleCommandBus and registers the mbeans for management information. |
|
SimpleCommandBus(boolean registerMBeans)
Initiates the SimpleCommandBus and makes the registration of mbeans for management information optional. |
|
| Method Summary | ||
|---|---|---|
void |
dispatch(Object command)
Dispatch the given command to the CommandHandler subscribed to that type of command. |
|
|
dispatch(Object command,
CommandCallback<R> callback)
Dispatch the given command to the CommandHandler subscribed to that type of command. |
|
void |
setInterceptors(List<? extends CommandHandlerInterceptor> interceptors)
Registers the given list of interceptors to the command bus. |
|
void |
setSubscriptions(Map<?,?> handlers)
Convenience method that allows you to register command handlers using a Dependency Injection framework. |
|
void |
setUnitOfWorkFactory(UnitOfWorkFactory unitOfWorkFactory)
Sets the UnitOfWorkFactory that provides the UnitOfWork instances for handling incoming commands. |
|
|
subscribe(Class<T> commandType,
CommandHandler<? super T> handler)
Subscribe the given handler to commands of type commandType. |
|
|
unsubscribe(Class<T> commandType,
CommandHandler<? super T> handler)
Unsubscribe the given handler to commands of type commandType. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SimpleCommandBus()
public SimpleCommandBus(boolean registerMBeans)
registerMBeans - true to register the mbeans, false for not registering them.| Method Detail |
|---|
public void dispatch(Object command)
CommandBuscommand to the CommandHandler subscribed to that type of command. No
feedback is given about the status of the dispatching process. Implementations may return immediately after
asserting a valid handler is registered for the given command.
dispatch in interface CommandBuscommand - The Command to dispatch
public <R> void dispatch(Object command,
CommandCallback<R> callback)
CommandBuscommand to the CommandHandler subscribed to that type of command.
When the command is processed, on of the callback methods is called, depending on the result of the processing.
When the method returns, the only guarantee provided by the CommandBus implementation, is that the command has
been successfully received. Implementations are highly recommended to perform basic validation of the command
before returning from this method call.
Implementations must start a UnitOfWork when before dispatching the command, and either commit or rollback after
a successful or failed execution, respectively.
dispatch in interface CommandBusR - The type of the expected resultcommand - The Command to dispatchcallback - The callback to invoke when command processing is complete
public <T> void subscribe(Class<T> commandType,
CommandHandler<? super T> handler)
handler to commands of type commandType. If a subscription already
exists for the given type, then the new handler takes over the subscription.
subscribe in interface CommandBusT - The Type of commandcommandType - The type of command to subscribe the handler tohandler - The handler instance that handles the given type of command
public <T> void unsubscribe(Class<T> commandType,
CommandHandler<? super T> handler)
handler to commands of type commandType. If the handler is not
currently assigned to that type of command, no action is taken.
unsubscribe in interface CommandBusT - The Type of commandcommandType - The type of command the handler is subscribed tohandler - The handler instance to unsubscribe from the CommandBuspublic void setInterceptors(List<? extends CommandHandlerInterceptor> interceptors)
afterCommandHandling methods are invoked on the interceptors in the reverse order.
interceptors - The interceptors to invoke when commands are dispatchedpublic void setSubscriptions(Map<?,?> handlers)
Map<Class<T>, CommandHandler<? super T>>. The key
represents the type of command to register the handler for, the value is the actual handler.
handlers - The handlers to subscribe in the form of a Map of Class - CommandHandler entries.public void setUnitOfWorkFactory(UnitOfWorkFactory unitOfWorkFactory)
DefaultUnitOfWorkFactory.
unitOfWorkFactory - The UnitOfWorkFactory providing UoW instances for this Command Bus.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||