org.apache.commons.configuration2.builder.combined

## Class ReloadingMultiFileConfigurationBuilder<T extends FileBasedConfiguration>

- java.lang.Object
- - org.apache.commons.configuration2.builder.BasicConfigurationBuilder<T>
  - - org.apache.commons.configuration2.builder.combined.MultiFileConfigurationBuilder<T>
    - - org.apache.commons.configuration2.builder.combined.ReloadingMultiFileConfigurationBuilder<T>

- Type Parameters:
    `T` - the concrete type of `Configuration` objects created by this builder
  All Implemented Interfaces:
    ConfigurationBuilder<T>, EventSource, ReloadingControllerSupport

      public class ReloadingMultiFileConfigurationBuilder<T extends FileBasedConfiguration>
      extends MultiFileConfigurationBuilder<T>
      implements ReloadingControllerSupport

  A specialized `MultiFileConfigurationBuilder` implementation which adds support for reloading.

  This class - as its super class - allows operating on multiple configuration files whose file names are determined using a file name pattern and a `ConfigurationInterpolator` object. It provides the following additional features:

  - Configuration builder for managed configurations have reloading support. So reloading is possible for all configuration sources loaded by this builder instance.
  - A `ReloadingController` is provided which can be used to trigger reload checks on all managed configurations.

  Although this builder manages an arbitrary number of child configurations, to clients only a single configuration is visible - the one selected by the evaluation of the file name pattern. Builder reset notifications triggered by the reloading mechanism do not really take this fact into account; they are not limited to the currently selected child configuration, but occur for each of the managed configuration.

  Since:
    2.0
  Version:
    $Id: ReloadingMultiFileConfigurationBuilder.java 1679777 2015-05-16 17:43:39Z oheger $

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ReloadingMultiFileConfigurationBuilder(Class<T> resCls)` Creates a new instance of `ReloadingMultiFileConfigurationBuilder` without setting initialization parameters.
    `ReloadingMultiFileConfigurationBuilder(Class<T> resCls, Map<String,Object> params)` Creates a new instance of `ReloadingMultiFileConfigurationBuilder` and sets initialization parameters.
    `ReloadingMultiFileConfigurationBuilder(Class<T> resCls, Map<String,Object> params, boolean allowFailOnInit)` Creates a new instance of `ReloadingMultiFileConfigurationBuilder` and sets initialization parameters and a flag whether initialization failures should be ignored.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected FileBasedConfigurationBuilder<T>` | `createManagedBuilder(String fileName, Map<String,Object> params)` Creates a builder for a managed configuration.
    `ReloadingController` | `getReloadingController()` Returns the `ReloadingController` associated with this object.

    - ### Methods inherited from class org.apache.commons.configuration2.builder.combined.MultiFileConfigurationBuilder

      `addEventListener, configure, constructFileName, createInitializedManagedBuilder, createInterpolator, getConfiguration, getInterpolator, getManagedBuilder, getManagedBuilders, removeEventListener, resetParameters`

    - ### Methods inherited from class org.apache.commons.configuration2.builder.BasicConfigurationBuilder

      `addParameters, connectToReloadingController, copyEventListeners, copyEventListeners, createResult, createResultDeclaration, createResultInstance, fetchBeanHelper, fireBuilderEvent, getParameters, getResultClass, getResultDeclaration, initResultInstance, installEventListener, isAllowFailOnInit, reset, resetResult, setParameters`

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

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

- - ### Constructor Detail

    - #### ReloadingMultiFileConfigurationBuilder

          public ReloadingMultiFileConfigurationBuilder(Class<T> resCls,
                                                        Map<String,Object> params,
                                                        boolean allowFailOnInit)

      Creates a new instance of `ReloadingMultiFileConfigurationBuilder` and sets initialization parameters and a flag whether initialization failures should be ignored.
      Parameters:
        `resCls` - the result configuration class
        `params` - a map with initialization parameters
        `allowFailOnInit` - a flag whether initialization errors should be ignored
      Throws:
        `IllegalArgumentException` - if the result class is null

    - #### ReloadingMultiFileConfigurationBuilder

          public ReloadingMultiFileConfigurationBuilder(Class<T> resCls,
                                                        Map<String,Object> params)

      Creates a new instance of `ReloadingMultiFileConfigurationBuilder` and sets initialization parameters.
      Parameters:
        `resCls` - the result configuration class
        `params` - a map with initialization parameters
      Throws:
        `IllegalArgumentException` - if the result class is null

    - #### ReloadingMultiFileConfigurationBuilder

          public ReloadingMultiFileConfigurationBuilder(Class<T> resCls)

      Creates a new instance of `ReloadingMultiFileConfigurationBuilder` without setting initialization parameters.
      Parameters:
        `resCls` - the result configuration class
      Throws:
        `IllegalArgumentException` - if the result class is null

  - ### Method Detail

    - #### getReloadingController

          public ReloadingController getReloadingController()

      Returns the `ReloadingController` associated with this object. This implementation returns a special `ReloadingController` that delegates to the reloading controllers of the managed builders created so far.
      Specified by:
        `getReloadingController` in interface `ReloadingControllerSupport`
      Returns:
        the associated `ReloadingController`

    - #### createManagedBuilder

          protected FileBasedConfigurationBuilder<T> createManagedBuilder(String fileName,
                                                                          Map<String,Object> params)
                                                                   throws ConfigurationException

      Creates a builder for a managed configuration. This method is called whenever a configuration for a file name is requested which has not yet been loaded. The passed in map with parameters is populated from this builder's configuration (i.e. the basic parameters plus the optional parameters for managed builders). This base implementation creates a standard builder for file-based configurations. Derived classes may override it to create special purpose builders. This implementation returns a file-based configuration builder with reloading support.
      Overrides:
        `createManagedBuilder` in class `MultiFileConfigurationBuilder<T extends FileBasedConfiguration>`
      Parameters:
        `fileName` - the name of the file to be loaded
        `params` - a map with initialization parameters for the new builder
      Returns:
        the newly created builder instance
      Throws:
        `ConfigurationException` - if an error occurs

Copyright © 2001–2015 The Apache Software Foundation. All rights reserved.