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
Modifier and TypeFieldDescriptionprivate final Thread
AThread
used by theBusMemoryStateManager
to work asynchronously.private final CountDownLatch
During the shutdown phase theEventBusInfrastructure
will send a shutdown message to eachEventExecutor
's worker and to theBusMemoryStateManager
.private static final org.slf4j.Logger
The logger used by this class.private final BlockingQueue<Message>
A blocking queue used to communicate internal messages to otherEventBus
's components.private final int
The number of workers (EventExecutor
s) used by the bus behind the scenes to deliver events.private final ExecutorService
AnExecutorService
used as a thread pool ofEventExecutor
workers. -
Constructor Summary
ConstructorDescriptionEventBusInfrastructure
(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) void
sendMessage
(Message message) The method used to send messages to other internal componentsprivate void
Private utility method to send aShutdownStateManagerMessage
to theBusMemoryStateManager
(package private) void
shutdown()
The method used to shut down theEventBus
.(package private) void
startup()
The method used to start up theEventBusInfrastructure
-
Field Details
-
logger
private static final org.slf4j.Logger loggerThe logger used by this class. -
workersPoolExecutor
AnExecutorService
used as a thread pool ofEventExecutor
workers. -
busMemoryStateManagerThread
AThread
used by theBusMemoryStateManager
to work asynchronously. -
countDownLatch
During the shutdown phase theEventBusInfrastructure
will send a shutdown message to eachEventExecutor
's worker and to theBusMemoryStateManager
. ThisCountDownLatch
is 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 (EventExecutor
s) 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
- TheListenerMethodFinder
is a service used to retrieve registered listeners methods annotated withListen
and to store them inside theMemoryState
inheritancePolicy
- The eventInheritancePolicy
used by the busnumberOfWorkers
- The number of workers (EventExecutor
s) 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
. TheEventBusInfrastructure
will dispose his data structures and send a message to all the others internal components (likeEventExecutor
s workers andBusMemoryStateManager
) in order to shut down. -
sendShutdownStateManagerMessage
private void sendShutdownStateManagerMessage()Private utility method to send aShutdownStateManagerMessage
to theBusMemoryStateManager
-