Module it.rebirthproject.ufoeb
Class GlobalEventBus
java.lang.Object
it.rebirthproject.ufoeb.architecture.eventbus.GlobalEventBus
Class which exposes an API to create and use a global eventbus with a singleton instance
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription(package private) static void
Utility method just for test purposesstatic EventBus
Get the global eventbus singleton instance.static void
setup
(EventBusBuilder eventBusBuilder) Set up the global eventbus singleton instance.static EventBus
setupAndGetInstance
(EventBusBuilder eventBusBuilder) Setup the global eventbus singleton instance and returns it.
-
Field Details
-
globalInstance
A unique instance ofGlobalEventBus
. This is a singletonEventBus
instance which can be used across each class of an application.
-
-
Constructor Details
-
GlobalEventBus
private GlobalEventBus()Private constructor
-
-
Method Details
-
setup
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 newGlobalEventBus
instance through anEventBusBuilder
-
getInstance
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 duringsetup(EventBusBuilder)
orgetInstance()
- See Also:
-
clearGlobalInstance
static void clearGlobalInstance()Utility method just for test purposes
-