|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.logicalcobwebs.proxool.util.AbstractListenerContainer
public abstract class AbstractListenerContainer
Implementation of ListenerContainerIF
that uses a reads/write lock to handle concurrency in a safe and
fast way.
The registered listeners are offered to subclasses through the protected getListeners()
method. This
method returns a reference to an array containing the registered listeners. A new array holding the listeners
is created everytime a modification on the registration list is required (add/remove listener). Therefore,
subclasses can safely iterate over the received array.
Your code sould look like this:
Object[] listeners = getListeners();
for(int i=0; i
Field Summary | |
---|---|
private static java.lang.Object[] |
EMPTY_LISTENERS
|
private java.lang.Object[] |
listeners
|
Constructor Summary | |
---|---|
AbstractListenerContainer()
|
Method Summary | |
---|---|
void |
addListener(java.lang.Object listener)
Add a listener to this container. |
protected java.lang.Object[] |
getListeners()
Get a reference to the array of registered listeners. |
boolean |
isEmpty()
Get wether this container is empty or not. |
boolean |
removeListener(java.lang.Object listener)
Remove a listener from this container. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private java.lang.Object[] listeners
private static final java.lang.Object[] EMPTY_LISTENERS
Constructor Detail |
---|
public AbstractListenerContainer()
Method Detail |
---|
public void addListener(java.lang.Object listener)
ListenerContainerIF
addListener
in interface ListenerContainerIF
listener
- the listener to add.ListenerContainerIF.addListener(Object)
public boolean removeListener(java.lang.Object listener)
ListenerContainerIF
removeListener
in interface ListenerContainerIF
listener
- the listener to be removed.
ListenerContainerIF.removeListener(Object)
protected java.lang.Object[] getListeners()
public boolean isEmpty()
ListenerContainerIF
isEmpty
in interface ListenerContainerIF
ListenerContainerIF.isEmpty()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |