org.logicalcobwebs.proxool.util

Class AbstractListenerContainer

Implemented Interfaces:
ListenerContainerIF
Known Direct Subclasses:
CompositeConfigurationListener, CompositeConnectionListener, CompositeProxoolListener, CompositeStateListener, CompositeStatisticsListener

public abstract class AbstractListenerContainer
extends java.lang.Object
implements ListenerContainerIF

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
Version:
$Revision: 1.8 $, $Date: 2004/03/16 08:48:33 $
Authors:
Christian Nedregaard (christian_nedregaard@email.com)
$Author: brenuart $ (current maintainer)
Since:
Proxool 0.7

Method Summary

void
addListener(Object listener)
protected Object[]
getListeners()
Get a reference to the array of registered listeners.
boolean
isEmpty()
boolean
removeListener(Object listener)

Method Details

addListener

public void addListener(Object listener)
Specified by:
addListener in interface ListenerContainerIF

getListeners

protected Object[] getListeners()
Get a reference to the array of registered listeners.
Returns:
reference to the array containing registered listeners (always not NULL)

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface ListenerContainerIF

removeListener

public boolean removeListener(Object listener)
Specified by:
removeListener in interface ListenerContainerIF