Module it.rebirthproject.ufoeb
Class EventBusInfrastructure
java.lang.Object
it.rebirthproject.ufoeb.architecture.eventbus.EventBusInfrastructure
The data structures composing the infrastructure of the
EventBus.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ThreadAThreadused by theBusMemoryStateManagerto work asynchronously.private final CountDownLatchDuring the shutdown phase theEventBusInfrastructurewill send a shutdown message to eachEventExecutor's worker and to theBusMemoryStateManager.private static final org.slf4j.LoggerThe logger used by this class.private final BlockingQueue<Message>A blocking queue used to communicate internal messages to otherEventBus's components.private final intThe number of workers (EventExecutors) used by the bus behind the scenes to deliver events.private final ExecutorServiceAnExecutorServiceused as a thread pool ofEventExecutorworkers. -
Constructor Summary
ConstructorsConstructorDescriptionEventBusInfrastructure(ListenerMethodFinder listenerMethodFinder, InheritancePolicy inheritancePolicy, int queueLength, int numberOfWorkers, boolean safeRegistrationsListNeeded, boolean throwNoRegistrationsWarning, boolean verboseLogging) The constructor used to build theEventBusInfrastructure -
Method Summary
Modifier and TypeMethodDescription(package private) voidsendMessage(Message message) The method used to send messages to other internal componentsprivate voidPrivate utility method to send aShutdownStateManagerMessageto theBusMemoryStateManager(package private) voidshutdown()The method used to shut down theEventBus.(package private) voidstartup()The method used to start up theEventBusInfrastructure
-
Field Details
-
logger
private static final org.slf4j.Logger loggerThe logger used by this class. -
workersPoolExecutor
AnExecutorServiceused as a thread pool ofEventExecutorworkers. -
busMemoryStateManagerThread
AThreadused by theBusMemoryStateManagerto work asynchronously. -
countDownLatch
During the shutdown phase theEventBusInfrastructurewill send a shutdown message to eachEventExecutor's worker and to theBusMemoryStateManager. ThisCountDownLatchis used to wait until each eventbus component is being shutdown. -
messageQueue
A blocking queue used to communicate internal messages to otherEventBus's components. -
numberOfWorkers
private final int numberOfWorkersThe number of workers (EventExecutors) used by the bus behind the scenes to deliver events.
-
-
Constructor Details
-
EventBusInfrastructure
EventBusInfrastructure(ListenerMethodFinder listenerMethodFinder, InheritancePolicy inheritancePolicy, int queueLength, int numberOfWorkers, boolean safeRegistrationsListNeeded, boolean throwNoRegistrationsWarning, boolean verboseLogging) The constructor used to build theEventBusInfrastructure- Parameters:
listenerMethodFinder- TheListenerMethodFinderis a service used to retrieve registered listeners methods annotated withListenand to store them inside theMemoryStateinheritancePolicy- The eventInheritancePolicyused by the busnumberOfWorkers- The number of workers (EventExecutors) used by the bus behind the scenes to deliver events.safeRegistrationsListNeeded- is used when you want to use inheritance over a listener and all its superclasses. Enabling it will let the bus look for all listeners' methods considering also all their superclasses methods.throwNoRegistrationsWarning- A boolean which defines if it's needed to throw warnings when no registrations are found for a specific eventverboseLogging- Boolean parameter set to true if a more verbose logging is needed- See Also:
-
-
Method Details
-
startup
void startup()The method used to start up theEventBusInfrastructure -
sendMessage
The method used to send messages to other internal components- Parameters:
message- The command/query message to send to other internal components- Throws:
EventBusException- if something goes wrong sending an internal message
-
shutdown
void shutdown()The method used to shut down theEventBus. TheEventBusInfrastructurewill dispose his data structures and send a message to all the others internal components (likeEventExecutors workers andBusMemoryStateManager) in order to shut down. -
sendShutdownStateManagerMessage
private void sendShutdownStateManagerMessage()Private utility method to send aShutdownStateManagerMessageto theBusMemoryStateManager
-