java.lang.Object
it.rebirthproject.ufoeb.architecture.eventbus.UfoEventBus
All Implemented Interfaces:
EventBus

final class UfoEventBus extends Object implements EventBus
The concrete implementation of the EventBus interface
  • Field Details

    • logger

      private static final org.slf4j.Logger logger
      The logger used by this class
    • eventBusInfrastructure

      private final EventBusInfrastructure eventBusInfrastructure
      The EventBusInfrastructure is a class that manage the internal components of the EventBus
  • Constructor Details

  • Method Details

    • register

      public void register(Object listenerToRegister) throws EventBusException
      Description copied from interface: EventBus
      Registers a listener to the eventbus to receive specific events. Listeners must call EventBus.unregister(Object) once they are no longer interested in receiving events. Listeners event handling methods must be annotated with the Listen annotation.
      Specified by:
      register in interface EventBus
      Parameters:
      listenerToRegister - The listener to register
      Throws:
      EventBusException - If the listener is null or something fails while registering
    • unregister

      public void unregister(Object listenerToUnregister) throws EventBusException
      Description copied from interface: EventBus
      Unregisters the given listener from the eventbus.
      Specified by:
      unregister in interface EventBus
      Parameters:
      listenerToUnregister - The listener to unregister
      Throws:
      EventBusException - If the given listener is null or something fails while unregistering
      See Also:
    • post

      public void post(Object event) throws EventBusException
      Description copied from interface: EventBus
      Posts the given event to the eventbus. This event will always be notified to and listened by registered listeners. Depending on which inheritance policy is chosen during bus initialization and on which event class/interface is listened by the listeners, listeners could get other events too. For example if an event extends a superclass or implements an interface. For a detailed explanation about inheritance policies refers to EventBusBuilder documentation
      Specified by:
      post in interface EventBus
      Parameters:
      event - The event to post
      Throws:
      EventBusException - If the event is null or some internal error occurs while posting the event
    • postSticky

      public void postSticky(Object event) throws EventBusException
      Description copied from interface: EventBus
      Posts the given event to the eventbus that saves it (because it's sticky). Once new listeners register to the same sticky event they will be notified about the sticky event on registration. In this way it's possible to not lose events which are being already sent before the listener is being registered.
      Specified by:
      postSticky in interface EventBus
      Parameters:
      event - The 'sticky' event to post
      Throws:
      EventBusException - If the sticky event is null or some internal error occurs while posting the sticky event
    • removeSticky

      public void removeSticky(Class<?> eventClass) throws EventBusException
      Description copied from interface: EventBus
      Removes a sticky event from the eventbus given the event type.
      Specified by:
      removeSticky in interface EventBus
      Parameters:
      eventClass - The class of a sticky event to remove
      Throws:
      EventBusException - If the class of the sticky event to remove is null or some internal error occurs while posting the sticky event
      See Also:
    • removeSticky

      public void removeSticky(Object event) throws EventBusException
      Description copied from interface: EventBus
      Removes a sticky event from the eventbus.
      Specified by:
      removeSticky in interface EventBus
      Parameters:
      event - The sticky event to remove
      Throws:
      EventBusException - If the sticky event is null or some internal error occurs while posting the sticky event
      See Also:
    • removeAllSticky

      public void removeAllSticky() throws EventBusException
      Description copied from interface: EventBus
      Removes all the sticky events from eventbus.
      Specified by:
      removeAllSticky in interface EventBus
      Throws:
      EventBusException - If some error occurs while removing all the sticky events
    • isRegistered

      public Future<Boolean> isRegistered(Object possibleRegisteredListener) throws EventBusException
      Description copied from interface: EventBus
      Checks if the passed object is already registered in the eventbus for listening to events.
      Specified by:
      isRegistered in interface EventBus
      Parameters:
      possibleRegisteredListener - An object which represents a possible registered listener
      Returns:
      A future wrapping a boolean value which will be true if the object passed to the method is a listener for some events or false otherwise
      Throws:
      EventBusException - If the possibleRegisteredListener is null or some error occurs during isRegistered method execution
      See Also:
    • printBusState

      public void printBusState() throws EventBusException
      Description copied from interface: EventBus
      Tells the bus to log its memory state for debug pourpose.
      Specified by:
      printBusState in interface EventBus
      Throws:
      EventBusException
    • shutdownBus

      public void shutdownBus()
      Description copied from interface: EventBus
      Shutdown the eventbus infrastructure. This is needed to free memory and to stop background workers behind the scenes. Note: Make sure to call this method when there is no more need for an eventbus in your application, so this can be usually done before the application shutdown.
      Specified by:
      shutdownBus in interface EventBus
    • printEventbusInformation

      private void printEventbusInformation()
      Prints basic information about the used Java VM and the UfoEventBus version