java.lang.Object
it.rebirthproject.ufoeb.architecture.eventbus.GlobalEventBus

public final class GlobalEventBus extends Object
Class which exposes an API to create and use a global eventbus with a singleton instance
  • Field Details

    • globalInstance

      private static volatile EventBus globalInstance
      A unique instance of GlobalEventBus. This is a singleton EventBus instance which can be used across each class of an application.
  • Constructor Details

    • GlobalEventBus

      private GlobalEventBus()
      Private constructor
  • Method Details

    • setup

      public static void setup(EventBusBuilder eventBusBuilder) throws EventBusException
      Set up the global eventbus singleton instance. Call it just once.
      Parameters:
      eventBusBuilder - The builder that will be used to construct the eventbus singleton instance
      Throws:
      EventBusException - If an error occurs while trying to set up a new GlobalEventBus instance through an EventBusBuilder
    • getInstance

      public static EventBus getInstance() throws EventBusException
      Get the global eventbus singleton instance. Use this method only after the setupInstance method is being called.
      Returns:
      The instance of the new setup singleton eventbus
      Throws:
      EventBusException - If an error occurs while trying to obtain a new instance
    • setupAndGetInstance

      public static EventBus setupAndGetInstance(EventBusBuilder eventBusBuilder) throws EventBusException
      Setup the global eventbus singleton instance and returns it. Call it just once.
      Parameters:
      eventBusBuilder - The builder that will be used to construct the eventbus singleton instance
      Returns:
      The instance of the new setup singleton eventbus
      Throws:
      EventBusException - If an error occurs during setup(EventBusBuilder) or getInstance()
      See Also:
    • clearGlobalInstance

      static void clearGlobalInstance()
      Utility method just for test purposes