|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.objectweb.proactive.core.event.AbstractEventProducer
Provides support for adding, removing and notifying ProActiveListener
. This class
is a generic class that can be derived to get immediate support for sending ProActiveEvent
to ProActiveListener
.
A class producing ProActiveEvent
and allowing ProActiveListener
to register can
have two strategies with those listeners in case of migration. If the listeners are local to the JVM,
it doesn't make sense to serialize them with the migrating object. If the listener are part of the
migrating subsystem, they should be serialized with the subsystem.
This class supports the two strategies and a boolean passed to the constructor indicates the strategy to apply with the registered listeners in case of migration.
In case of the listeners are not serialized with this object, meaning that there are not part of the subsystem in which is attached this object, we only keep weak references on them. The reference this event producer is keeping on one given listener won't prevent it to be garbage collected if no other strong reference are kept by another object.
This class is thread safe.
Nested Class Summary | |
protected static interface |
AbstractEventProducer.ListenerList
A class implementing this interface provide a minimum set of methods to support the addition and removal of listener. |
Field Summary | |
protected AbstractEventProducer.ListenerList |
eventListeners
the list of listeners. |
protected static org.apache.log4j.Logger |
logger
|
protected boolean |
shouldSerializeListeners
flag specifying if the list of listeners should be serialized |
Constructor Summary | |
AbstractEventProducer()
Creates an AbstractEventProducer that does not serialize its registered listener. |
|
AbstractEventProducer(boolean shouldSerializeListeners)
Creates an AbstractEventProducer and specifies whether its registered listener
should be serialized or not |
Method Summary | |
protected void |
addListener(ProActiveListener listener)
Adds the given listener |
protected boolean |
hasListeners()
Returns true is this event producer has at least one registered listener |
protected void |
notifyAllListeners(ProActiveEvent event)
Notifies all registered listener with the event. |
protected abstract void |
notifyOneListener(ProActiveListener listener,
ProActiveEvent event)
Notifies one listener with the event. |
protected void |
removeListener(ProActiveListener listener)
Removes the given listener |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static org.apache.log4j.Logger logger
protected boolean shouldSerializeListeners
protected transient AbstractEventProducer.ListenerList eventListeners
Constructor Detail |
public AbstractEventProducer()
AbstractEventProducer
that does not serialize its registered listener.
public AbstractEventProducer(boolean shouldSerializeListeners)
AbstractEventProducer
and specifies whether its registered listener
should be serialized or not
shouldSerializeListeners
- true if the registered listeners should be serialized, false else.Method Detail |
protected boolean hasListeners()
protected void addListener(ProActiveListener listener)
protected void removeListener(ProActiveListener listener)
protected void notifyAllListeners(ProActiveEvent event)
notifyOneListener
on each registered listener.
protected abstract void notifyOneListener(ProActiveListener listener, ProActiveEvent event)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |