org.modeshape.graph.observe
Class ObservationBus

java.lang.Object
  extended by org.modeshape.graph.observe.ObservationBus
All Implemented Interfaces:
Observable, Observer

@ThreadSafe
public class ObservationBus
extends Object
implements Observable, Observer

A simple Observer that is itself Observable. This class essentially multiplexes the events from a single Observable to disseminate each event to multiple Observers.


Constructor Summary
ObservationBus()
           
 
Method Summary
 boolean hasObservers()
          Determine whether this particular bus currently has any observers.
 void notify(Changes changes)
          Method that is called for each set of changes from the Observable instance(s) with which this observer is registered.
 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
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObservationBus

public ObservationBus()
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)

notify

public void notify(Changes changes)
Method that is called for each set of changes from the Observable instance(s) with which this observer is registered.

Specified by:
notify in interface Observer
Parameters:
changes - the changes that are being published
See Also:
Observer.notify(org.modeshape.graph.observe.Changes)

hasObservers

public boolean hasObservers()
Determine whether this particular bus currently has any observers.

Returns:
true if there is at least one observer, or false otherwise

shutdown

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



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