I
- the type of IDs of entities that handle the commands dispatched by the delegate@Internal
public interface CommandDispatcherDelegate<I>
CommandDispatcher
.
A typical example of a CommandDispatcherDelegate
usage is a routine, which
simultaneously dispatches different types of messages
in addition to Command
s.
In this case such a class would have to implement several
MessageDispatcher
child interfaces
(such as CommandDispatcher
or
EventDispatcher
). However, it is impossible
to implement the same getMessageClasses()
method several times with the different types of MessageClass
es
returned.
The same interference takes place in attempt to implement
UnicastDispatcher.dispatch(MessageEnvelope)
method with the different types of
MessageEnvelope
s dispatches simultaneously.
That's why unlike MessageDispatcher,
this interface defines its own contract for declaring the dispatched
command classes, which does not interfere with the
MessageDispatcher
API.
DelegatingCommandDispatcher
Modifier and Type | Method and Description |
---|---|
I |
dispatchCommand(io.spine.core.CommandEnvelope envelope) |
default boolean |
dispatchesCommands()
Verifies if this instance dispatches at least one command.
|
java.util.Set<io.spine.core.CommandClass> |
getCommandClasses() |
void |
onError(io.spine.core.CommandEnvelope envelope,
java.lang.RuntimeException exception)
Handles an error occurred during command dispatching.
|
java.util.Set<io.spine.core.CommandClass> getCommandClasses()
I dispatchCommand(io.spine.core.CommandEnvelope envelope)
void onError(io.spine.core.CommandEnvelope envelope, java.lang.RuntimeException exception)
envelope
- the event which caused the errorexception
- the errordefault boolean dispatchesCommands()