|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objecteu.webtoolkit.jwt.AbstractSignal
eu.webtoolkit.jwt.AbstractEventSignal
eu.webtoolkit.jwt.EventSignal
public class EventSignal
An signal which relays a browser event. This event signal does not pass any event details.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class eu.webtoolkit.jwt.AbstractEventSignal |
|---|
AbstractEventSignal.AutoLearnListener, AbstractEventSignal.JavaScriptListener, AbstractEventSignal.LearningListener, AbstractEventSignal.PreLearnListener |
| Nested classes/interfaces inherited from class eu.webtoolkit.jwt.AbstractSignal |
|---|
AbstractSignal.Connection |
| Method Summary | |
|---|---|
void |
addListener(JSlot slot)
Adds a JavaScript event listener. |
void |
addListener(WObject receiver,
AbstractEventSignal.LearningListener listener)
Adds a learning listener to this signal. |
AbstractSignal.Connection |
addListener(WObject listenerOwner,
Signal.Listener listener)
Adds a listener for this signal. |
protected int |
getListenerCount()
Returns the number of connected listeners. |
void |
removeListener(Signal.Listener listener)
Removes a listener. |
void |
trigger()
Triggers the signal. |
| Methods inherited from class eu.webtoolkit.jwt.AbstractEventSignal |
|---|
addListener, addListener, addListener, addListener, createUserEventCall, disconnect, isConnected, isDefaultActionPrevented, isPropagationPrevented, preventDefaultAction, preventDefaultAction, preventPropagation, preventPropagation, removeListener |
| Methods inherited from class eu.webtoolkit.jwt.AbstractSignal |
|---|
getListeners, isBlocked, setBlocked |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public AbstractSignal.Connection addListener(WObject listenerOwner,
Signal.Listener listener)
AbstractSignalEach listener will be notified when the signal is triggered.
An owner object may be passed when the listener is implemented using an (anonymous) inner class. In that case the owner object should be the enclosing object of the listener object, and this is used to bind the lifetime of the listener. To avoid the owner object from not being garbage collected when it is no longer used, only the owner object will add a reference to the listener, while the signal will use a weak reference.
This avoids the most common reason for memory leaks in Java
implementations of the Observer pattern: the owner object will not get
garbage collected because of the (anonymous) listener object having a
reference to it, even if the receiver object is no longer referenced from
anywhere. When the owner object is not null, the listener is
stored using a strong reference in the owner object, and using a weak
reference in the signal.
addListener in class AbstractSignallistenerOwner - if not null, the enclosing object for a
listener implemented using an inner classlistener - the listener
protected int getListenerCount()
AbstractSignal
getListenerCount in class AbstractEventSignalpublic void removeListener(Signal.Listener listener)
AbstractSignal
removeListener in class AbstractSignallistener - a listener that was previously added.public void trigger()
AbstractEventSignal
The AbstractEventSignal.LearningListener.trigger() method of all listeners added to this signal are triggered.
trigger in class AbstractEventSignalpublic void addListener(JSlot slot)
AbstractEventSignal
addListener in class AbstractEventSignalslot - the JavaScript event listener
public void addListener(WObject receiver,
AbstractEventSignal.LearningListener listener)
AbstractEventSignal
An owner object may be passed when the listener is implemented using an
anonymous inner class. In that case the owner object should be the
enclosing object of the listener object, and this is used to bind the
lifetime of the listener: when the owner object is garbage collected, the
listener will be freed as well. This avoids the most common reason for
memory leaks in Java implementations of the Observer pattern: the owner
object will not get garbage collected because of the (anonymous) listener
object having a reference to it, even if the receiver object is no longer
referenced from anywhere. When the owner object is not null,
the listener is stored using a strong reference in the owner object, and
using a weak reference in the signal.
Note: The receiver is currently not yet used.
addListener in class AbstractEventSignalreceiver - if not null, the enclosing object for an
anonymous listenerlistener - the listener
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||