org.oddjob.arooa.utils
Class ListenerSupportBase<T>

java.lang.Object
  extended by org.oddjob.arooa.utils.ListenerSupportBase<T>
Type Parameters:
T - The type of the listener.
Direct Known Subclasses:
ConfigurationOwnerSupport, ConfigurationSessionSupport

public class ListenerSupportBase<T>
extends Object

A Helper Class for tracking Listeners. Allows commands to be run on the first listener and when there are no more listeners. This is useful when the events are being notified in a chain and there is no need to subscribe when nothing is listening. For instance in the Oddjob JMX handlers.

Author:
rob

Constructor Summary
ListenerSupportBase()
           
 
Method Summary
protected  void addListener(T listener)
           
protected  List<T> copy()
           
 Runnable getOnEmpty()
           
 Runnable getOnFirst()
           
protected  void removeListener(T listener)
           
 void setOnEmpty(Runnable onEmpty)
          Set an action to be run when the last listener has been removed.
 void setOnFirst(Runnable onFirst)
          Set an action to run when the first listener is added.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ListenerSupportBase

public ListenerSupportBase()
Method Detail

copy

protected List<T> copy()

addListener

protected void addListener(T listener)

removeListener

protected void removeListener(T listener)

getOnFirst

public Runnable getOnFirst()

setOnFirst

public void setOnFirst(Runnable onFirst)
Set an action to run when the first listener is added.

Parameters:
onFirst -

getOnEmpty

public Runnable getOnEmpty()

setOnEmpty

public void setOnEmpty(Runnable onEmpty)
Set an action to be run when the last listener has been removed.

Parameters:
onEmpty -