|
||||||||||
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.P
- the kind of data to be passed on to the notified partypublic 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
if the notificaiton process is underway, then to be removed listeners are registered here (they will still receive notifications in the current notification round as their de-registration is actually a result of the current notification round) |
private ArrayList<T> |
listeners
The listeners that will receive notifications if the notify listeners function is called |
private SingleNotificationHandler<T,P> |
myHandler
the entity that is actually used to perform the notifications |
private ArrayList<T> |
newListeners
if the notificaiton process is underway, then new listeners are registered here (they will not receive notifications in the current notification round as their registration is actually a result of the current notification round) |
private boolean |
noEventDispatchingInProcess
a marker to show if there is a notification process underway |
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)
payload
- to be sent out for all interested parties upon receiving this
notification
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |