org.modeshape.graph.observe
Class LocalObservationBus

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

@ThreadSafe
public class LocalObservationBus
extends Object
implements ObservationBus

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
LocalObservationBus()
           
 
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.
 void start()
          Prepare this bus for operation by starting any resources.
 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

LocalObservationBus

public LocalObservationBus()
Method Detail

start

public void start()
Prepare this bus for operation by starting any resources.

Specified by:
start in interface ObservationBus
See Also:
ObservationBus.start()

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.

Specified by:
hasObservers in interface ObservationBus
Returns:
true if there is at least one observer, or false otherwise
See Also:
ObservationBus.hasObservers()

shutdown

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

Specified by:
shutdown in interface ObservationBus
See Also:
ObservationBus.shutdown()


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