org.apache.hadoop.service
Class ServiceOperations.ServiceListeners

java.lang.Object
  extended by org.apache.hadoop.service.ServiceOperations.ServiceListeners
Enclosing class:
ServiceOperations

public static class ServiceOperations.ServiceListeners
extends Object

Class to manage a list of ServiceStateChangeListener instances, including a notification loop that is robust against changes to the list during the notification process.


Constructor Summary
ServiceOperations.ServiceListeners()
           
 
Method Summary
 void add(ServiceStateChangeListener l)
          Thread-safe addition of a new listener to the end of a list.
 void notifyListeners(Service service)
          Change to a new state and notify all listeners.
 boolean remove(ServiceStateChangeListener l)
          Remove any registration of a listener from the listener list.
 void reset()
          Reset the listener list
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServiceOperations.ServiceListeners

public ServiceOperations.ServiceListeners()
Method Detail

add

public void add(ServiceStateChangeListener l)
Thread-safe addition of a new listener to the end of a list. Attempts to re-register a listener that is already registered will be ignored.

Parameters:
l - listener

remove

public boolean remove(ServiceStateChangeListener l)
Remove any registration of a listener from the listener list.

Parameters:
l - listener
Returns:
true if the listener was found (and then removed)

reset

public void reset()
Reset the listener list


notifyListeners

public void notifyListeners(Service service)
Change to a new state and notify all listeners. This method will block until all notifications have been issued. It caches the list of listeners before the notification begins, so additions or removal of listeners will not be visible.

Parameters:
service - the service that has changed state


Copyright © 2014 Apache Software Foundation. All Rights Reserved.