Class GebBridge

java.lang.Object
me.tamkungz.signals.geb.GebBridge

public final class GebBridge extends Object
Direct access to the GEB bus behind a SignalBus: custom IEvents, @Listen listeners and sub-buses.

Obtain it with SignalBus.geb().

  • Constructor Summary

    Constructors
    Constructor
    Description
    GebBridge(foo.zaaarf.geb.api.IBus bus)
    Wraps a GEB bus.
  • Method Summary

    Modifier and Type
    Method
    Description
    foo.zaaarf.geb.api.IBus
    bus()
    Returns the underlying GEB bus.
    boolean
    isRegistered(foo.zaaarf.geb.api.IBus subBus)
    Tells whether a sub-bus is registered.
    boolean
    isRegistered(foo.zaaarf.geb.api.IListener listener)
    Tells whether a listener is registered.
    listen(foo.zaaarf.geb.api.IListener listener)
    Registers a listener and returns a connection that unregisters it.
    listen(ConnectionGroup group, foo.zaaarf.geb.api.IListener listener)
    Registers a listener and tracks its connection in a group.
    void
    Registers every dispatcher a class loader lists in META-INF/services/foo.zaaarf.geb.api.IEventDispatcher, the file GEB's annotation processor writes.
    boolean
    post(foo.zaaarf.geb.api.IEvent event)
    Posts an event to every registered listener.
    void
    registerDispatcher(foo.zaaarf.geb.api.IEventDispatcher<?> dispatcher)
    Registers the dispatcher of an event type.
    void
    registerListener(foo.zaaarf.geb.api.IListener listener)
    Registers a listener.
    void
    registerSubBus(foo.zaaarf.geb.api.IBus subBus, int priority)
    Registers a sub-bus.
    subBus(foo.zaaarf.geb.api.IBus subBus, int priority)
    Registers a sub-bus and returns a connection that unregisters it.
    subBus(ConnectionGroup group, foo.zaaarf.geb.api.IBus subBus, int priority)
    Registers a sub-bus and tracks its connection in a group.
    void
    unregisterDispatcher(foo.zaaarf.geb.api.IEventDispatcher<?> dispatcher)
    Unregisters the dispatcher of an event type; its listeners stop being called.
    void
    unregisterListener(foo.zaaarf.geb.api.IListener listener)
    Unregisters a listener.
    void
    unregisterSubBus(foo.zaaarf.geb.api.IBus subBus)
    Unregisters a sub-bus.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • GebBridge

      public GebBridge(foo.zaaarf.geb.api.IBus bus)
      Wraps a GEB bus.
      Parameters:
      bus - bus to expose
  • Method Details

    • bus

      public foo.zaaarf.geb.api.IBus bus()
      Returns the underlying GEB bus.
      Returns:
      the raw bus
    • post

      public boolean post(foo.zaaarf.geb.api.IEvent event)
      Posts an event to every registered listener.
      Parameters:
      event - event to post
      Returns:
      false if the event was cancelled, true otherwise
    • registerDispatcher

      public void registerDispatcher(foo.zaaarf.geb.api.IEventDispatcher<?> dispatcher)
      Registers the dispatcher of an event type.

      GEB only calls the listeners of an event type once its dispatcher is registered on the bus, and drops events that have none without any warning. Dispatchers are generated by GEB's annotation processor for classes with @Listen methods.

      Parameters:
      dispatcher - dispatcher to register
    • unregisterDispatcher

      public void unregisterDispatcher(foo.zaaarf.geb.api.IEventDispatcher<?> dispatcher)
      Unregisters the dispatcher of an event type; its listeners stop being called.
      Parameters:
      dispatcher - dispatcher to unregister
    • loadAndRegisterDispatchers

      public void loadAndRegisterDispatchers(ClassLoader classLoader)
      Registers every dispatcher a class loader lists in META-INF/services/foo.zaaarf.geb.api.IEventDispatcher, the file GEB's annotation processor writes.

      Pass the class loader of the plugin that defines the @Listen methods, for example getClass().getClassLoader() in the plugin's main class.

      Parameters:
      classLoader - class loader to read the service file from
    • listen

      public Connection listen(foo.zaaarf.geb.api.IListener listener)
      Registers a listener and returns a connection that unregisters it.

      The listener is only called for event types whose dispatcher is registered, see registerDispatcher(IEventDispatcher).

      Parameters:
      listener - listener to register
      Returns:
      connection that unregisters the listener
    • listen

      public Connection listen(ConnectionGroup group, foo.zaaarf.geb.api.IListener listener)
      Registers a listener and tracks its connection in a group.
      Parameters:
      group - group that will disconnect the listener
      listener - listener to register
      Returns:
      connection that unregisters the listener
    • registerListener

      public void registerListener(foo.zaaarf.geb.api.IListener listener)
      Registers a listener.
      Parameters:
      listener - listener to register
    • unregisterListener

      public void unregisterListener(foo.zaaarf.geb.api.IListener listener)
      Unregisters a listener.
      Parameters:
      listener - listener to unregister
    • isRegistered

      public boolean isRegistered(foo.zaaarf.geb.api.IListener listener)
      Tells whether a listener is registered.
      Parameters:
      listener - listener to check
      Returns:
      true if registered
    • subBus

      public Connection subBus(foo.zaaarf.geb.api.IBus subBus, int priority)
      Registers a sub-bus and returns a connection that unregisters it.
      Parameters:
      subBus - bus to forward events to
      priority - sub-bus priority
      Returns:
      connection that unregisters the sub-bus
    • subBus

      public Connection subBus(ConnectionGroup group, foo.zaaarf.geb.api.IBus subBus, int priority)
      Registers a sub-bus and tracks its connection in a group.
      Parameters:
      group - group that will unregister the sub-bus
      subBus - bus to forward events to
      priority - sub-bus priority
      Returns:
      connection that unregisters the sub-bus
    • registerSubBus

      public void registerSubBus(foo.zaaarf.geb.api.IBus subBus, int priority)
      Registers a sub-bus.
      Parameters:
      subBus - bus to forward events to
      priority - sub-bus priority
    • unregisterSubBus

      public void unregisterSubBus(foo.zaaarf.geb.api.IBus subBus)
      Unregisters a sub-bus.
      Parameters:
      subBus - bus to stop forwarding to
    • isRegistered

      public boolean isRegistered(foo.zaaarf.geb.api.IBus subBus)
      Tells whether a sub-bus is registered.
      Parameters:
      subBus - bus to check
      Returns:
      true if registered