|
SalesPoint Framework v3.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.swing.event.EventListenerList util.ListenerHelper
Helper class that supports Listeners which themselves can be listened to.
The main intent is to support garbage collection by avoiding cyclic links between the listener and its event source. Listeners that use ListenerHelper (and implement HelpableListener) will be registered with their event source only as long as there are any listeners registered with them. They will however guarantee up-to-date-ness indepent of whether a listener is registered with them or not, by polling their model whenever a query is performed against them and they have no listeners.
For this mechanism to work properly such listeners must abide by the following rules:
needModelUpdate()
As the Swing serialization is buggy, this class will serialize only listeners that implement
SerializableListener
. For this purpose, however, all methods in
EventListenerList
need to be overridden.
HelpableListener
,
needModelUpdate()
,
Serialized FormField Summary | |
protected Object[] |
aoListeners
The list of ListenerType - Listener pairs. |
protected HelpableListener |
m_hlOwner
The listener that owns this listener helper. |
Fields inherited from class javax.swing.event.EventListenerList |
listenerList |
Constructor Summary | |
ListenerHelper()
Construct a new ListenerHelper. |
|
ListenerHelper(HelpableListener hlOwner)
Create a new ListenerHelper. |
Method Summary | |
void |
add(Class t,
EventListener l)
Add the listener as a listener of the specified type. |
int |
getListenerCount()
Return the total number of listeners for this listenerlist |
int |
getListenerCount(Class t)
Return the total number of listeners of the supplied type for this listenerlist. |
Object[] |
getListenerList()
This passes back the event listener list as an array of ListenerType - listener pairs. |
void |
needModelUpdate()
Make sure, the owner's model is up to date. |
void |
remove(Class t,
EventListener l)
Remove the listener as a listener of the specified type. |
String |
toString()
Return a string representation of the SerializableListenerHelper. |
Methods inherited from class javax.swing.event.EventListenerList |
getListeners |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected transient Object[] aoListeners
EventListenerList
mechanism.
PENDING (sz9): Need to replace direct references to listeners by SoftReferences, in order to avoid
cycles and thereby memory leaks. Example: Stocks listen to their catalogs in order to maintain
referential integrity. They also store a pointer to their catalog in order to be able to reference
it. A cycle is created, which means that creating lots of temporary stocks is a potential memory
problem.
protected HelpableListener m_hlOwner
Constructor Detail |
public ListenerHelper()
public ListenerHelper(HelpableListener hlOwner)
hlOwner
- the HelpableListener that is associated to this ListenerHelper.Method Detail |
public Object[] getListenerList()
public int getListenerCount()
public int getListenerCount(Class t)
public void add(Class t, EventListener l)
t
- the type of the listener to be addedl
- the listener to be addedpublic void remove(Class t, EventListener l)
t
- the type of the listener to be removedl
- the listener to be removedpublic void needModelUpdate()
HelpableListener.updateModel()
in the owner.
public String toString()
|
SalesPoint Framework v3.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |