org.modeshape.jcr.bus

## Class RepositoryChangeBus

- java.lang.Object
- - org.modeshape.jcr.bus.RepositoryChangeBus

- All Implemented Interfaces:
    ChangeBus, ChangeSetListener, Observable

      public final class RepositoryChangeBus
      extends Object
      implements ChangeBus

  Change bus implementation around a `RingBuffer`

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `protected class` | `RepositoryChangeBus.ChangeSetListenerConsumerAdapter`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static Logger` | `LOGGER`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `RepositoryChangeBus(String repositoryName, ExecutorService executor)` Creates new change bus

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `hasObservers()` Checks if there are any observers registered with the bus.
    `void` | `notify(ChangeSet changeSet)` Notifies a listener of the given changes.
    `boolean` | `register(ChangeSetListener observer)` Register the supplied observer.
    `boolean` | `registerInThread(ChangeSetListener observer)` 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 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

  - ### Constructor Detail

    - #### RepositoryChangeBus

          public RepositoryChangeBus(String repositoryName,
                             ExecutorService executor)

      Creates new change bus
      Parameters:
        `repositoryName` - the repository name; may not be null
        `executor` - the `ExecutorService` which will be used internally to submit workers to dispatching events to listeners.

  - ### Method Detail

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

    - #### register

          public boolean register(ChangeSetListener observer)

      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:
        `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

    - #### registerInThread

          public boolean registerInThread(ChangeSetListener observer)

      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:
        `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

    - #### unregister

          public boolean unregister(ChangeSetListener observer)

      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:
        `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

    - #### 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.

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

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