org.modeshape.jcr.bus

## Class ClusteredRepositoryChangeBus

- java.lang.Object
- - org.modeshape.jcr.clustering.MessageConsumer<ChangeSet>
  - - org.modeshape.jcr.bus.ClusteredRepositoryChangeBus

- All Implemented Interfaces:
    ChangeBus, ChangeSetListener, Observable

      @ThreadSafe
      public final class ClusteredRepositoryChangeBus
      extends MessageConsumer<ChangeSet>
      implements ChangeBus

  Implementation of a `ChangeBus` which can run in a cluster, via `ClusteringService`. This bus wraps around another bus, to which it delegates all "local" processing of events.

  It is important that the order of the `ChangeSet` instances are maintained across the cluster, and JGroups will do this for us as long as we push all local changes into the channel and receive all local/remote changes from the channel.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ClusteredRepositoryChangeBus(ChangeBus delegate, ClusteringService clusteringService)` Creates a new clustered repository bus

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `consume(ChangeSet changes)` Consumes a payload of the given type.
    `boolean` | `hasObservers()` Checks if there are any observers registered with the bus.
    `protected void` | `logReceivedOperation(ChangeSet changeSet)`
    `protected void` | `logSendOperation(ChangeSet changeSet)`
    `void` | `notify(ChangeSet changeSet)` Notifies a listener of the given changes.
    `boolean` | `register(ChangeSetListener listener)` Register the supplied observer.
    `boolean` | `registerInThread(ChangeSetListener listener)` Register the supplied observer which will be always notified in the same thread as the bus instance.
    `void` | `shutdown()` Shuts down the change bus, closing and clearing resources created during `ChangeBus.start()`
    `void` | `start()` Starts up the change bus.
    `boolean` | `unregister(ChangeSetListener listener)` Unregister the supplied observer.

    - ### Methods inherited from class org.modeshape.jcr.clustering.MessageConsumer

      `getPayloadType`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ClusteredRepositoryChangeBus

          public ClusteredRepositoryChangeBus(ChangeBus delegate,
                                      ClusteringService clusteringService)

      Creates a new clustered repository bus
      Parameters:
        `delegate` - the local bus to which changes will be delegated
        `clusteringService` - the object which will handle sending/receiving information in the cluster.

  - ### Method Detail

    - #### consume

          public void consume(ChangeSet changes)

      Description copied from class: `MessageConsumer`
      Consumes a payload of the given type.
      Specified by:
        `consume` in class `MessageConsumer<ChangeSet>`
      Parameters:
        `changes` - a `Serializable` payload.

    - #### start

          public void start()
                     throws Exception

      Description copied from interface: `ChangeBus`
      Starts up the change bus.
      Specified by:
        `start` in interface `ChangeBus`
      Throws:
        `Exception` - if anything unexpected fails during startup.

    - #### hasObservers

          public boolean hasObservers()

      Description copied from interface: `ChangeBus`
      Checks if there are any observers registered with the bus.
      Specified by:
        `hasObservers` in interface `ChangeBus`
      Returns:
        `true` if there are any registered observers, `false` otherwise

    - #### shutdown

          public void shutdown()

      Description copied from interface: `ChangeBus`
      Shuts down the change bus, closing and clearing resources created during `ChangeBus.start()`
      Specified by:
        `shutdown` in interface `ChangeBus`

    - #### notify

          public void notify(ChangeSet changeSet)

      Description copied from interface: `ChangeSetListener`
      Notifies a listener of the given changes.
      Specified by:
        `notify` in interface `ChangeSetListener`
      Parameters:
        `changeSet` - a `non-null` `ChangeSet`

    - #### logSendOperation

          protected final void logSendOperation(ChangeSet changeSet)

    - #### logReceivedOperation

          protected final void logReceivedOperation(ChangeSet changeSet)

    - #### register

          public boolean register(ChangeSetListener listener)

      Description copied from interface: `Observable`
      Register the supplied observer. This method does nothing if the observer reference is null.
      Specified by:
        `register` in interface `Observable`
      Parameters:
        `listener` - 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

    - #### registerInThread

          public boolean registerInThread(ChangeSetListener listener)

      Description copied from interface: `ChangeBus`
      Register the supplied observer which will be always notified in the same thread as the bus instance. This method does nothing if the observer reference is null.
      Specified by:
        `registerInThread` in interface `ChangeBus`
      Parameters:
        `listener` - 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

    - #### unregister

          public boolean unregister(ChangeSetListener listener)

      Description copied from interface: `Observable`
      Unregister the supplied observer. This method does nothing if the observer reference is null.
      Specified by:
        `unregister` in interface `Observable`
      Parameters:
        `listener` - 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

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