Interface BabelProtocolHolder
- All Known Implementing Classes:
AbstractBabelProtocolHolder, DedicatedExecutorProtocolHolder, NettyExecutorProtocolHolder, SharedExecutorProtocolHolder
public interface BabelProtocolHolder
Wraps a
BabelProtocol and manages its execution environment, event delivery,
and dispatching of messages and events.
Implementations of this interface manage how events are scheduled and executed
(for instance, via a shared thread pool or a dedicated single-threaded executor),
and hold the compiled lambda invocations generated from handler annotations such as
UponBabelEvent and
UponMessageIn.
-
Method Summary
Modifier and TypeMethodDescription<T> TcreateHandler(Method method, MethodHandles.Lookup lookup, Class<? extends BabelProtocol> protocolClass, Class<T> handlerInterface, String handlerMethodName, Class<?>[] erasedParamType, Class<?>[] actualParamType) Creates a typed functional handler instance by binding the specified protocol method viaLambdaMetafactory.voiddeliverEvent(BabelEvent event) Enqueues or delivers an event to the underlying protocol.Map<Class<? extends ProtocolEvent>, EventHandler<? extends ProtocolEvent>> Returns the mapping of handledProtocolEventclasses to their compiled event handlers.Returns the underlying protocol instance managed by this holder.booleanholdsProtocol(Class<? extends BabelProtocol> protocolClass) Returns whether this holder manages a protocol that is an instance of or assignable to the given protocol class.Set<Class<? extends ProtocolEvent>> Returns the set ofProtocolEventclasses that this protocol has registered interest in.Set<Class<? extends BabelMessage>> Returns the set ofBabelMessageclasses that this protocol is interested in receiving.Set<Class<? extends BabelMessage>> Returns the set ofBabelMessageclasses for which this protocol handles delivery failure.Set<Class<? extends BabelMessage>> Returns the set ofBabelMessageclasses for which this protocol handles successful delivery.
-
Method Details
-
deliverEvent
Enqueues or delivers an event to the underlying protocol.- Parameters:
event- the event to deliver
-
holdsProtocol
Returns whether this holder manages a protocol that is an instance of or assignable to the given protocol class.- Parameters:
protocolClass- the protocol class to check- Returns:
trueif this holder manages a matching protocol,falseotherwise
-
createHandler
<T> T createHandler(Method method, MethodHandles.Lookup lookup, Class<? extends BabelProtocol> protocolClass, Class<T> handlerInterface, String handlerMethodName, Class<?>[] erasedParamType, Class<?>[] actualParamType) Creates a typed functional handler instance by binding the specified protocol method viaLambdaMetafactory.- Type Parameters:
T- the handler interface type- Parameters:
method- the target method on the protocollookup- the method handles lookup contextprotocolClass- the concrete protocol classhandlerInterface- the functional interface class to implementhandlerMethodName- the name of the single abstract method on the interfaceerasedParamType- the parameter types in the erased method signatureactualParamType- the actual specialized parameter types- Returns:
- an instance of
Tthat invokes the target method
-
getInnerProtocol
BabelProtocol getInnerProtocol()Returns the underlying protocol instance managed by this holder.- Returns:
- the managed
BabelProtocol
-
interestedEvents
Set<Class<? extends ProtocolEvent>> interestedEvents()Returns the set ofProtocolEventclasses that this protocol has registered interest in.- Returns:
- set of handled event classes
-
interestedInMessages
Set<Class<? extends BabelMessage>> interestedInMessages()Returns the set ofBabelMessageclasses that this protocol is interested in receiving.- Returns:
- set of handled inbound message classes
-
interestedOutSuccessMessages
Set<Class<? extends BabelMessage>> interestedOutSuccessMessages()Returns the set ofBabelMessageclasses for which this protocol handles successful delivery.- Returns:
- set of message classes with outbound success handlers
-
interestedOutFailedMessages
Set<Class<? extends BabelMessage>> interestedOutFailedMessages()Returns the set ofBabelMessageclasses for which this protocol handles delivery failure.- Returns:
- set of message classes with outbound failure handlers
-
eventHandlers
Map<Class<? extends ProtocolEvent>, EventHandler<? extends ProtocolEvent>> eventHandlers()Returns the mapping of handledProtocolEventclasses to their compiled event handlers.- Returns:
- map of event types to handlers
-