org.apache.tamaya.events

## Class ConfigEventManager

- java.lang.Object
- - org.apache.tamaya.events.ConfigEventManager

-     public final class ConfigEventManager
      extends Object

  Singleton accessor for accessing the event support component that distributes change events of `PropertySource` and `Configuration`.

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `addListener(ConfigEventListener l)` Adds a Config listener that listens to all kind of `ConfigEvent`.
    `static <T extends ConfigEvent> void` | `addListener(ConfigEventListener l, Class<T> eventType)` Adds a Config listener that listens to all kind of `ConfigEvent`.
    `static void` | `enableChangeMonitoring(boolean enable)` Start/Stop the change monitoring service, which will observe/reevaluate the current configuration regularly and trigger ConfigurationChange events if something changed.
    `static <T> void` | `fireEvent(ConfigEvent<?> event)` Publishes a `ConfigurationChange` synchronously to all interested listeners.
    `static <T> void` | `fireEventAsynch(ConfigEvent<?> event)` Publishes a `ConfigurationChange` asynchronously/multithreaded to all interested listeners.
    `long` | `getChangeMonitoringPeriod()` Get the current check period to check for configuration changes.
    `static <T extends ConfigEvent> Collection<? extends ConfigEventListener>` | `getListeners()` Access all registered ConfigEventListeners listening to a all kind of event types globally.
    `static <T extends ConfigEvent> Collection<? extends ConfigEventListener>` | `getListeners(Class<T> type)` Access all registered ConfigEventListeners listening to a given event type.
    `static boolean` | `isChangeMonitoring()` Check if the observer is running currently.
    `static void` | `removeListener(ConfigEventListener l)` Removes a listener registered globally.
    `static <T extends ConfigEvent> void` | `removeListener(ConfigEventListener l, Class<T> eventType)` Removes a listener registered for the given event type.
    `void` | `setChangeMonitoringPeriod(long millis)` Sets the current monitoring period and restarts the monitor.

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

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

- - ### Method Detail

    - #### addListener

          public static void addListener(ConfigEventListener l)

      Adds a Config listener that listens to all kind of `ConfigEvent`.
      Parameters:
        `l` - the listener not null.

    - #### addListener

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

      Adds a Config listener that listens to all kind of `ConfigEvent`.
      Type Parameters:
        `T` - the type of the event.
      Parameters:
        `l` - the listener not null.
        `eventType` - the event type to which this listener listens to.

    - #### removeListener

          public static void removeListener(ConfigEventListener l)

      Removes a listener registered globally.
      Parameters:
        `l` - the listener not null.

    - #### removeListener

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

      Removes a listener registered for the given event type.
      Type Parameters:
        `T` - the type of the event.
      Parameters:
        `l` - the listener, not null.
        `eventType` - the event type to which this listener listens to.

    - #### getListeners

          public static <T extends ConfigEvent> Collection<? extends ConfigEventListener> getListeners(Class<T> type)

      Access all registered ConfigEventListeners listening to a given event type.
      Type Parameters:
        `T` - type param
      Parameters:
        `type` - the event type
      Returns:
        a list with the listeners found, never null.

    - #### getListeners

          public static <T extends ConfigEvent> Collection<? extends ConfigEventListener> getListeners()

      Access all registered ConfigEventListeners listening to a all kind of event types globally.
      Type Parameters:
        `T` - the type of the event.
      Returns:
        a list with the listeners found, never null.

    - #### fireEvent

          public static <T> void fireEvent(ConfigEvent<?> event)

      Publishes a `ConfigurationChange` synchronously to all interested listeners.
      Type Parameters:
        `T` - the type of the event.
      Parameters:
        `event` - the event, not null.

    - #### fireEventAsynch

          public static <T> void fireEventAsynch(ConfigEvent<?> event)

      Publishes a `ConfigurationChange` asynchronously/multithreaded to all interested listeners.
      Type Parameters:
        `T` - the type of the event.
      Parameters:
        `event` - the event, not null.

    - #### enableChangeMonitoring

          public static void enableChangeMonitoring(boolean enable)

      Start/Stop the change monitoring service, which will observe/reevaluate the current configuration regularly and trigger ConfigurationChange events if something 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 remotely. For handling corresponding `ConfigEventListener` have to be registered, e.g. listening on `ConfigurationChange` events.
      Parameters:
        `enable` - whether to enable or disable the change monitoring.
      See Also:
        `isChangeMonitoring()`, `getChangeMonitoringPeriod()`

    - #### isChangeMonitoring

          public static boolean isChangeMonitoring()

      Check if the observer is running currently.
      Returns:
        true, if the change monitoring service is currently running.
      See Also:
        `enableChangeMonitoring(boolean)`

    - #### getChangeMonitoringPeriod

          public long getChangeMonitoringPeriod()

      Get the current check period to check for configuration changes.
      Returns:
        the check period in ms.

    - #### setChangeMonitoringPeriod

          public void setChangeMonitoringPeriod(long millis)

      Sets the current monitoring period and restarts the monitor. You still have to enable the monitor if it is currently not enabled.
      Parameters:
        `millis` - the monitoring period in ms.
      See Also:
        `enableChangeMonitoring(boolean)`, `isChangeMonitoring()`

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