org.modeshape.graph.observe
Class ChangeObservers

java.lang.Object
  extended by org.modeshape.graph.observe.ChangeObservers
All Implemented Interfaces:
Observable

@ThreadSafe
public class ChangeObservers
extends Object
implements Observable

Reusable manager of change listeners, typically employed by another Observable implementation.


Nested Class Summary
protected  class ChangeObservers.ObserverReference
          A WeakReference implementation that provides a valid
 
Constructor Summary
ChangeObservers()
           
 
Method Summary
 void broadcast(Changes changes)
          Broadcast the supplied changes to the registered observers.
 boolean isEmpty()
          Determine whether there are any observers at the time this method is called.
 boolean register(Observer observer)
          Register the supplied observer.
 void shutdown()
          Unregister all registered observers, and mark this as no longer accepting new registered observers.
 boolean unregister(Observer observer)
          Unregister the supplied observer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChangeObservers

public ChangeObservers()
Method Detail

register

public boolean register(Observer observer)
Register the supplied observer. This method does nothing if the observer reference is null.

Specified by:
register in interface Observable
Parameters:
observer - the observer to be added; may be null
Returns:
true if the observer was added, or false if the observer was null, if the observer was already registered, or if the observer could not be added
See Also:
Observable.register(org.modeshape.graph.observe.Observer)

unregister

public boolean unregister(Observer observer)
Unregister the supplied observer. This method does nothing if the observer reference is null.

Specified by:
unregister in interface Observable
Parameters:
observer - the observer to be removed; may not be null
Returns:
true if the observer was removed, or false if the observer was null or if the observer was not registered on this source
See Also:
Observable.unregister(org.modeshape.graph.observe.Observer)

shutdown

public void shutdown()
Unregister all registered observers, and mark this as no longer accepting new registered observers.


isEmpty

public boolean isEmpty()
Determine whether there are any observers at the time this method is called.

Returns:
true if there are currently no observers, or false if there is at least one observer

broadcast

public void broadcast(Changes changes)
Broadcast the supplied changes to the registered observers.

Parameters:
changes - the changes to broadcast
Throws:
IllegalArgumentException - if the changes reference is null


Copyright © 2008-2012 JBoss, a division of Red Hat. All Rights Reserved.