Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.modeshape.clustering
Class ClusteredObservationBus

    java.lang.Object
      org.modeshape.clustering.ClusteredObservationBus

All Implemented Interfaces:
  Observable, ObservationBus, Observer

    public class ClusteredObservationBus

extends Object
implements ObservationBus

An implementation of a cluster-aware `ObservationBus`.

Nested Class Summary
`protected class` | `ClusteredObservationBus.Listener`
`protected class` | `ClusteredObservationBus.Receiver`

Field Summary
`protected AtomicBoolean` | `isOpen` Flag that dictates whether this bus has connected to the cluster.
`protected static Logger` | `LOGGER`
`protected AtomicBoolean` | `multipleAddressesInCluster` Flag that dictates whether there are multiple participants in the cluster; if not, then the changes are propogated only to the local observers.
`protected ChangeObservers` | `observers` The list of `Observer` instances that should receive events from the bus.

Constructor Summary
`ClusteredObservationBus()`

Method Summary
`protected static Changes` | `deserialize(byte[] data)`
`String` | `getClusterName()` Get the name of the JGroups cluster.
`String` | `getConfiguration()` Get the configuration for JGroups.
`boolean` | `hasObservers()` Determine whether this particular bus currently has any observers.
`boolean` | `isStarted()` Return whether this bus has been `started` and not yet `shut down`.
`protected org.jgroups.JChannel` | `newChannel(String configuration)` A method that is used to instantiate the `JChannel` object with the supplied configuration.
`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.
`protected static byte[]` | `serialize(Changes changes)`
`void` | `setClusterName(String clusterName)` Set the name of the JGroups cluster.
`void` | `setConfiguration(String configuration)` Set the JGroups configuration, which may be a string that refers to a resource on the classpath, the path of the local configuration, the URL to the configuration file, or the configuration specified using the newer-style XML form or older-style string form.
`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`

Field Detail

### LOGGER

    protected static final Logger LOGGER

### observers

    protected final ChangeObservers observers

  The list of `Observer` instances that should receive events from the bus. These Observer objects are all local.

### isOpen

    protected final AtomicBoolean isOpen

  Flag that dictates whether this bus has connected to the cluster.

### multipleAddressesInCluster

    protected final AtomicBoolean multipleAddressesInCluster

  Flag that dictates whether there are multiple participants in the cluster; if not, then the changes are propogated only to the local observers.

Constructor Detail

### ClusteredObservationBus

    public ClusteredObservationBus()

Method Detail

### getConfiguration

    public String getConfiguration()

  Get the configuration for JGroups. This configuration may be a string that refers to a resource on the classpath, the path of the local configuration, the URL to the configuration file, or the configuration specified using the newer-style XML form or older-style string form.

  Returns:
    the location of the JGroups configuration, or null if no configuration has been defined

### setConfiguration

    public void setConfiguration(String configuration)

  Set the JGroups configuration, which may be a string that refers to a resource on the classpath, the path of the local configuration, the URL to the configuration file, or the configuration specified using the newer-style XML form or older-style string form.

  Parameters:
    `configuration` - the relative path to a classpath resource, path to a local file, URL to the configuration file, or the configuration specified using the newer-style XML form or older-style string form.
  Throws:
    `IllegalStateException` - if this method is called after this bus has been `started` but before it has been `shutdown`

### getClusterName

    public String getClusterName()

  Get the name of the JGroups cluster.

  Returns:
    the cluster name, or null if the cluster name was not yet defined
  See Also:
    `JChannel.connect(String)`

### setClusterName

    public void setClusterName(String clusterName)

  Set the name of the JGroups cluster. This must be called with a non-null cluster name before `start()` is called.

  Parameters:
    `clusterName` - Sets clusterName to the specified value.
  Throws:
    `IllegalStateException` - if this method is called after this bus has been `started` but before it has been `shutdown`
  See Also:
    `JChannel.connect(String)`

### start

    public void start()

  Prepare this bus for operation by starting any resources.

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

### newChannel

    protected org.jgroups.JChannel newChannel(String configuration)
                                       throws org.jgroups.ChannelException

  A method that is used to instantiate the `JChannel` object with the supplied configuration. Subclasses can override this method to specialize this behavior.

  Parameters:
    `configuration` - the configuration; may be null or empty string, if the default configuration should be used
  Returns:
    the JChannel instance; never null
  Throws:
    `org.jgroups.ChannelException` - if there is a problem creating the new channel object

### 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)`

### 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)`

### 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()`

### isStarted

    public boolean isStarted()

  Return whether this bus has been `started` and not yet `shut down`.

  Returns:
    true if `start()` has been called but `shutdown()` has not, or false otherwise

### 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()`

### serialize

    protected static byte[] serialize(Changes changes)
                               throws Exception

  Throws:
    `Exception`

### deserialize

    protected static Changes deserialize(byte[] data)
                                  throws Exception

  Throws:
    `Exception`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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