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 Details

    • deliverEvent

      void deliverEvent(BabelEvent event)
      Enqueues or delivers an event to the underlying protocol.
      Parameters:
      event - the event to deliver
    • holdsProtocol

      boolean holdsProtocol(Class<? extends BabelProtocol> protocolClass)
      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:
      true if this holder manages a matching protocol, false otherwise
    • 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 via LambdaMetafactory.
      Type Parameters:
      T - the handler interface type
      Parameters:
      method - the target method on the protocol
      lookup - the method handles lookup context
      protocolClass - the concrete protocol class
      handlerInterface - the functional interface class to implement
      handlerMethodName - the name of the single abstract method on the interface
      erasedParamType - the parameter types in the erased method signature
      actualParamType - the actual specialized parameter types
      Returns:
      an instance of T that 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 of ProtocolEvent classes that this protocol has registered interest in.
      Returns:
      set of handled event classes
    • interestedInMessages

      Set<Class<? extends BabelMessage>> interestedInMessages()
      Returns the set of BabelMessage classes that this protocol is interested in receiving.
      Returns:
      set of handled inbound message classes
    • interestedOutSuccessMessages

      Set<Class<? extends BabelMessage>> interestedOutSuccessMessages()
      Returns the set of BabelMessage classes 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 of BabelMessage classes 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 handled ProtocolEvent classes to their compiled event handlers.
      Returns:
      map of event types to handlers