|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.cesr.lara.components.eventbus.impl.LEventbus
public class LEventbus
The LEventbus serves as a communication system between different components, where the components do not necessarily know each other. Components can publish events to the LaraEventbus. All subscribers of this event will be notified on occurrence. The event bus is implemented as a singleton to ensure all components communicate over the same channel and to make use of the event bus easier. However, it also manages eventbuses by ID objects which enables specific eventbuses per agent. GOAL: Loose coupling of components, Event driven initialization.
Constructor Summary | |
---|---|
protected |
LEventbus()
This is a singleton. |
Method Summary | |
---|---|
static LEventbus |
getInstance()
returns a reference to the global eventbus |
static LEventbus |
getInstance(Object id)
returns a reference to a special eventbus |
boolean |
isForceSequential()
|
protected void |
notifySubscribers(LaraEvent event)
TODO search for subscribers to super classes! |
boolean |
occured(LaraEvent event)
Checks whether the given LaraEvent has occurred during the current tick. |
void |
publish(LaraEvent event)
Publish / fire event - this will notify subscribers of this event about occurrence of this event |
static void |
resetAll()
Iterates over all instances and calls resetInstance() . |
void |
resetInstance()
Clears eventsThisTimestamp, event subscriber map, event-waiting counters, and statistics. |
void |
setForceSequential(boolean forceSequential)
|
boolean |
subclassOccured(LaraEvent event)
Checks whether the given LaraEvent or any sub class has occurred during the current tick. |
void |
subscribe(LaraAbstractEventSubscriber subscriber,
Class<? extends LaraEvent> eventClass)
Subscribe for an event - subscriber will be informed about occurrence of event (triggers onEvent() method of implemented interface LaraEventSubscriber) |
void |
unsubscribe(Class<? extends LaraEvent> eventClass)
Unsubscribes all subscribers from the given event class. |
void |
unsubscribe(LaraAbstractEventSubscriber subscriber)
Unsubscribe the given subscriber from all events. |
void |
unsubscribe(LaraAbstractEventSubscriber subscriber,
Class<? extends LaraEvent> eventClass)
Unsubscribe a subscriber from an event |
void |
unsubscribe(LaraEvent event)
Unsubscribes all subscribers from the event class the given event belongs to. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected LEventbus()
Method Detail |
---|
public static LEventbus getInstance()
public static LEventbus getInstance(Object id)
id
-
public static void resetAll()
resetInstance()
.
Clears collection of instances.
public boolean occured(LaraEvent event)
event
- to check
public void publish(LaraEvent event)
event
- public void resetInstance()
public boolean subclassOccured(LaraEvent event)
event
- to check
public void subscribe(LaraAbstractEventSubscriber subscriber, Class<? extends LaraEvent> eventClass)
subscriber
- event
- public void unsubscribe(Class<? extends LaraEvent> eventClass)
subscriber
- public void unsubscribe(LaraAbstractEventSubscriber subscriber)
subscriber
- public void unsubscribe(LaraAbstractEventSubscriber subscriber, Class<? extends LaraEvent> eventClass)
subscriber
- event
- public void unsubscribe(LaraEvent event)
subscriber
- protected void notifySubscribers(LaraEvent event)
event
- public boolean isForceSequential()
public void setForceSequential(boolean forceSequential)
forceSequential
- the forceSequential to set
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |