|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecthu.mta.sztaki.lpds.cloud.simulator.notifications.StateDependentEventHandler<T,P>
T
- the kind of state change for which this handler is prepared to notify about.public class StateDependentEventHandler<T,P>
The main non-time dependent event handling mechanism in DISSECT-CF. This class is kept generic, and every user could either derive from it or use this as an embedded object. It is expected that the user of this class will want to deliver notifications about its internal state changes. The kind of state changes possible are not known by this generic mechanism, but the user of this class is expected to express this via the generic parameter of the class. The individual notifications can be customized via the class's constructor.
Field Summary | |
---|---|
private ArrayList<T> |
cancelledListeners
|
private ArrayList<T> |
listeners
|
private SingleNotificationHandler<T,P> |
myHandler
|
private ArrayList<T> |
newListeners
|
private boolean |
noEventDispatchingInProcess
|
Constructor Summary | |
---|---|
StateDependentEventHandler(SingleNotificationHandler<T,P> handler)
Initialization of the event handling mechanism. |
Method Summary | |
---|---|
private void |
mainNotificationLoop(P payload)
The main event dispatching loop. |
void |
notifyListeners(P payload)
Sends out the notifications via the user defined event handler for all currently listed listeners. |
void |
subscribeToEvents(T listener)
To get state dependent events one must subscribe to them via this function. |
void |
unsubscribeFromEvents(T listener)
If there are no events needed for a particular listener then they can be cancelled here. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private ArrayList<T> listeners
private ArrayList<T> newListeners
private ArrayList<T> cancelledListeners
private boolean noEventDispatchingInProcess
private final SingleNotificationHandler<T,P> myHandler
Constructor Detail |
---|
public StateDependentEventHandler(SingleNotificationHandler<T,P> handler)
handler
- via this interface's implementation will the actual observed
object be capable of dispatching custom events abouts its
state changeMethod Detail |
---|
public void subscribeToEvents(T listener)
listener
- who should receive notifications upon state changes in the
observed objectpublic void unsubscribeFromEvents(T listener)
listener
- the listener which does not need the state related events
anymoreprivate void mainNotificationLoop(P payload)
public void notifyListeners(P payload)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |