org.apache.tamaya.events.internal

## Class DefaultConfigEventManagerSpi

- java.lang.Object
- - org.apache.tamaya.events.internal.DefaultConfigEventManagerSpi

- All Implemented Interfaces:
    ConfigEventManagerSpi

      public class DefaultConfigEventManagerSpi
      extends Object
      implements ConfigEventManagerSpi

  Default implementation of `DefaultConfigEventManagerSpi` just forwarding all events synchronously to the listeners.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultConfigEventManagerSpi()` Constructor.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addListener(ConfigEventListener l)` Adds a listener for observing events.
    `<T extends ConfigEvent> void` | `addListener(ConfigEventListener l, Class<T> eventType)` Adds a listener for observing events of a given type.
    `void` | `enableChangeMonitor(boolean enable)` Start/stop the change monitoring service, which will observe/reevaluate the current configuration regularly and trigger ConfigurationChange events if something is changed.
    `void` | `fireEvent(ConfigEvent<?> event)` Publishes an event to all interested listeners, hereby executing all registered listeners sequentually and synchronously
    `void` | `fireEventAsynch(ConfigEvent<?> event)` Publishes an event to all interested listeners, hereby publishing the change events asynchrously and in parallel (multithreaded).
    `long` | `getChangeMonitoringPeriod()` Get the current check period to check for configuration changes.
    `Collection<? extends ConfigEventListener>` | `getListeners()` Access all globally registered listeners.
    `Collection<? extends ConfigEventListener>` | `getListeners(Class<? extends ConfigEvent> eventType)` Access all listeners listening for a certain event type, including any global listeners.
    `boolean` | `isChangeMonitorActive()` Check if the observer is running currently.
    `void` | `removeListener(ConfigEventListener l)` Removes a listener for observing events.
    `<T extends ConfigEvent> void` | `removeListener(ConfigEventListener l, Class<T> eventType)` Removes a listener for observing events of a certain type.
    `void` | `setChangeMonitoringPeriod(long millis)`

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

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

- - ### Constructor Detail

    - #### DefaultConfigEventManagerSpi

          public DefaultConfigEventManagerSpi()

      Constructor. Also loads all registered listeners.

  - ### Method Detail

    - #### addListener

          public void addListener(ConfigEventListener l)

      Description copied from interface: `ConfigEventManagerSpi`
      Adds a listener for observing events. References of this component to the listeners must be managed as weak references.
      Specified by:
        `addListener` in interface `ConfigEventManagerSpi`
      Parameters:
        `l` - the listener not null.

    - #### addListener

          public <T extends ConfigEvent> void addListener(ConfigEventListener l,
                                                 Class<T> eventType)

      Description copied from interface: `ConfigEventManagerSpi`
      Adds a listener for observing events of a given type.
      Specified by:
        `addListener` in interface `ConfigEventManagerSpi`
      Type Parameters:
        `T` - the type of the events listened to.
      Parameters:
        `l` - the listener not null.
        `eventType` - the type of concrete configuration event this listeners should be informed about. All other event types will never be delivered to this listener instance.

    - #### removeListener

          public void removeListener(ConfigEventListener l)

      Description copied from interface: `ConfigEventManagerSpi`
      Removes a listener for observing events.
      Specified by:
        `removeListener` in interface `ConfigEventManagerSpi`
      Parameters:
        `l` - the listener not null.

    - #### removeListener

          public <T extends ConfigEvent> void removeListener(ConfigEventListener l,
                                                    Class<T> eventType)

      Description copied from interface: `ConfigEventManagerSpi`
      Removes a listener for observing events of a certain type.
      Specified by:
        `removeListener` in interface `ConfigEventManagerSpi`
      Type Parameters:
        `T` - the type of the events listened to.
      Parameters:
        `l` - the listener not null.
        `eventType` - the type of concrete configuration event this listeners should be informed about. All other event types will never be delivered toe this listener instance.

    - #### getListeners

          public Collection<? extends ConfigEventListener> getListeners(Class<? extends ConfigEvent> eventType)

      Description copied from interface: `ConfigEventManagerSpi`
      Access all listeners listening for a certain event type, including any global listeners.
      Specified by:
        `getListeners` in interface `ConfigEventManagerSpi`
      Parameters:
        `eventType` - the type of concrete configuration event this listeners should be informed about. All other event types will never be delivered toe this listener instance.
      Returns:
        the listeners found, never null.

    - #### getListeners

          public Collection<? extends ConfigEventListener> getListeners()

      Description copied from interface: `ConfigEventManagerSpi`
      Access all globally registered listeners.
      Specified by:
        `getListeners` in interface `ConfigEventManagerSpi`
      Returns:
        the listeners found, never null.

    - #### fireEvent

          public void fireEvent(ConfigEvent<?> event)

      Description copied from interface: `ConfigEventManagerSpi`
      Publishes an event to all interested listeners, hereby executing all registered listeners sequentually and synchronously.,
      Specified by:
        `fireEvent` in interface `ConfigEventManagerSpi`
      Parameters:
        `event` - the event, not null.

    - #### fireEventAsynch

          public void fireEventAsynch(ConfigEvent<?> event)

      Description copied from interface: `ConfigEventManagerSpi`
      Publishes an event to all interested listeners, hereby publishing the change events asynchrously and in parallel (multithreaded).
      Specified by:
        `fireEventAsynch` in interface `ConfigEventManagerSpi`
      Parameters:
        `event` - the event, not null.

    - #### getChangeMonitoringPeriod

          public long getChangeMonitoringPeriod()

      Description copied from interface: `ConfigEventManagerSpi`
      Get the current check period to check for configuration changes.
      Specified by:
        `getChangeMonitoringPeriod` in interface `ConfigEventManagerSpi`
      Returns:
        the check period in ms.

    - #### setChangeMonitoringPeriod

          public void setChangeMonitoringPeriod(long millis)

      Specified by:
        `setChangeMonitoringPeriod` in interface `ConfigEventManagerSpi`

    - #### isChangeMonitorActive

          public boolean isChangeMonitorActive()

      Description copied from interface: `ConfigEventManagerSpi`
      Check if the observer is running currently.
      Specified by:
        `isChangeMonitorActive` in interface `ConfigEventManagerSpi`
      Returns:
        true, if the change monitoring service is currently running.

    - #### enableChangeMonitor

          public void enableChangeMonitor(boolean enable)

      Description copied from interface: `ConfigEventManagerSpi`
      Start/stop the change monitoring service, which will observe/reevaluate the current configuration regularly and trigger ConfigurationChange events if something is changed. This is quite handy for publishing configuration changes to whatever systems are interested in. Hereby the origin of a configuration change can be on this machine, or also remotedly. For handling corresponding `ConfigEventListener` have to be registered, e.g. listening on `ConfigurationChange` events.
      Specified by:
        `enableChangeMonitor` in interface `ConfigEventManagerSpi`
      Parameters:
        `enable` - whether to enable or disable the change monitoring.

Copyright © 2014–2016 Apache Software Foundation. All rights reserved.