C
- the type of the class of dispatched messagesD
- the type of the message dispatcherspublic abstract class DispatcherRegistry<C extends io.spine.type.MessageClass<? extends com.google.protobuf.Message>,E extends MessageEnvelope<?,?,?>,D extends MessageDispatcher<C,E>>
extends java.lang.Object
Constructor and Description |
---|
DispatcherRegistry() |
Modifier and Type | Method and Description |
---|---|
protected java.util.function.BiPredicate<E,D> |
attributeFilter()
Returns a filter allowing to tell whether the attributes of the envelope match
the dispatcher requirements.
|
protected void |
checkDispatcher(D dispatcher)
Ensures that the passed dispatcher is valid.
|
protected java.util.Optional<D> |
dispatcherOf(E envelope)
Obtains a single dispatcher (if available) for the passed message.
|
protected java.util.Set<D> |
dispatchersOf(C messageClass)
Obtains all the dispatchers for the passed message class.
|
protected java.util.Optional<? extends D> |
getDispatcherForType(C messageClass)
Obtains a single dispatcher (if available) for the passed message.
|
void |
register(D dispatcher) |
protected java.util.Set<C> |
registeredMessageClasses()
Obtains message classes from all registered dispatchers.
|
void |
unregister(D dispatcher) |
protected void |
unregisterAll()
Unregisters all dispatchers.
|
public void register(D dispatcher)
public void unregister(D dispatcher)
protected void unregisterAll()
protected java.util.Set<C> registeredMessageClasses()
protected java.util.function.BiPredicate<E,D> attributeFilter()
protected java.util.Optional<D> dispatcherOf(E envelope)
envelope
- the message to find a dispatcher forjava.lang.IllegalStateException
- if more than one dispatcher is foundUnicastBus
es.protected java.util.Set<D> dispatchersOf(C messageClass)
messageClass
- the target message classprotected java.util.Optional<? extends D> getDispatcherForType(C messageClass)
messageClass
- the class of the message to find a dispatcher forjava.lang.IllegalStateException
- if more than one dispatcher is foundprotected void checkDispatcher(D dispatcher) throws java.lang.IllegalArgumentException
The passed dispatcher must expose at least one message class.
dispatcher
- the dispatcher to checkjava.lang.IllegalArgumentException
- if the check is failed