CommandRoutertypes must implement this protocol:
void route(final RoutableCommand command)
CommandRoutermust implement the
Pis the type name of the protocol to which the command will be sent. The
Cis the type name of this command type, which must be a subclass of
Ais the answer type to be provided by the command, and is normally a
Tis the type to be answered asynchronously.
CommandRouter. This is a standard container for a concrete command type. In other words, create a command type, such as
Rename, that implements the protocol
CommandDispatcherand instantiate a new
Renamecommand inside. The
RoutableCommandis sent through the
Renamecommand internally knows how to send a message to its
Pgeneric protocol type parameter.
SchemaCommandswhere are a number of concrete command types. The
SchemaCommandsis a factory that instantiates all the concrete command types as needed. See the main source for full details, such as all necessary imports, etc.
SchemaCommandsparent is instantiated with the
Stageand the number of
routeesto be create for the router. The constructor creates a new
CommandRouterthat is the type used for
SchemaCommandsinstance exists, it can be used to instantiate individual command instances. The first factory used is
categorizeAs()that instantiates a
CategorizeAsthat is wrapped in a
RoutableCommandgeneric type parameters are as follows:
Pprotocol is the
Schemadomain model interface.
Ccommand type is
SchemaState, which is the type used to hold and transfer the
Schematype's immutable state data.
Category. First the
CategorizeAsconcrete command type itself is instantiated with the two parameters. Next the instance of
CategorizeAsis wrapped by a new
RoutableCommand, and it is then routed. Finally the
RoutableCommandis answered from the factory.
RoutableCommandanswer is used to receive the
SchemaStateinstance when it arrives by way of the
Completes<SchemaState>. The REST resource handler type
SchemaResourceinitially received an HTTP
PATCHrequest and used the
categorizeAs()in order to create the
RoutableCommand. Once the
RoutableCommandis returned to the
SchemaResourcerequest handler, the request handler registers a function on the
Completes<SchemaState>that will deliver the eventual outcome when it arrives.
CategorizeAscommand type itself plays and important role beyond carrying a parameter payload. When the router is ready to delivery the command, it uses the command itself to perform the dispatching.
CategorizeAscommand to its destination, the router uses the
CommandDispatcher, a Java functional interface, to do so. The
accept()method sends the
categorizeAs()message and parameters to the
SchemaEntityactor through its registered protocol.