org.apache.commons.configuration2.builder.combined

## Class ReloadingCombinedConfigurationBuilder

- java.lang.Object
- - org.apache.commons.configuration2.builder.BasicConfigurationBuilder<CombinedConfiguration>
  - - org.apache.commons.configuration2.builder.combined.CombinedConfigurationBuilder
    - - org.apache.commons.configuration2.builder.combined.ReloadingCombinedConfigurationBuilder

- All Implemented Interfaces:
    ConfigurationBuilder<CombinedConfiguration>, EventSource, ReloadingControllerSupport

      public class ReloadingCombinedConfigurationBuilder
      extends CombinedConfigurationBuilder
      implements ReloadingControllerSupport

  An extension of `CombinedConfigurationBuilder` which also supports reloading operations.

  This class differs from its super class in the following aspects:

  - A `ReloadingController` is created which manages all child configuration builders supporting reloading operations.
  - If no `ConfigurationBuilder` is provided for the definition configuration, a builder with reloading support is created.

  This class can be used exactly as its super class for creating combined configurations from multiple configuration sources. In addition, the combined reloading controller managed by an instance can be used to react on changes in one of these configuration sources or in the definition configuration.

  Since:
    2.0
  Version:
    $Id: ReloadingCombinedConfigurationBuilder.java 1679776 2015-05-16 17:43:10Z oheger $

- - ### Field Summary

    - ### Fields inherited from class org.apache.commons.configuration2.builder.combined.CombinedConfigurationBuilder

      `ADDITIONAL_NAME`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ReloadingCombinedConfigurationBuilder()` Creates a new instance of `ReloadingCombinedConfigurationBuilder`.
    `ReloadingCombinedConfigurationBuilder(Map<String,Object> params)` Creates a new instance of `ReloadingCombinedConfigurationBuilder` and sets the specified initialization parameters.
    `ReloadingCombinedConfigurationBuilder(Map<String,Object> params, boolean allowFailOnInit)` Creates a new instance of `ReloadingCombinedConfigurationBuilder` and sets the specified initialization parameters and the allowFailOnInit flag.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `ReloadingCombinedConfigurationBuilder` | `configure(BuilderParameters... params)` Appends the content of the specified `BuilderParameters` objects to the current initialization parameters.
    `protected ReloadingController` | `createReloadingController()` Creates the `ReloadingController` for this builder.
    `protected ConfigurationBuilder<? extends HierarchicalConfiguration<?>>` | `createXMLDefinitionBuilder(BuilderParameters builderParams)` Creates a default builder for the definition configuration and initializes it with a parameters object.
    `ReloadingController` | `getReloadingController()` Returns the `ReloadingController` associated with this object.
    `protected void` | `initResultInstance(CombinedConfiguration result)` Initializes a newly created result object.
    `static void` | `obtainReloadingController(Collection<ReloadingController> subControllers, Object builder)` Checks whether the passed in builder object supports reloading.

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

      `builderNames, configureEntityResolver, createAdditionalsConfiguration, createResultDeclaration, getChildBuilders, getDefinitionBuilder, getDefinitionConfiguration, getNamedBuilder, initChildBuilderParameters, initFileSystem, initSystemProperties, providerForTag, registerConfiguredLookups, resetParameters, setupDefinitionBuilder`

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

      `addEventListener, addParameters, connectToReloadingController, copyEventListeners, copyEventListeners, createResult, createResultInstance, fetchBeanHelper, fireBuilderEvent, getConfiguration, getParameters, getResultClass, getResultDeclaration, installEventListener, isAllowFailOnInit, removeEventListener, reset, resetResult, setParameters`

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

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

- - ### Constructor Detail

    - #### ReloadingCombinedConfigurationBuilder

          public ReloadingCombinedConfigurationBuilder()

      Creates a new instance of `ReloadingCombinedConfigurationBuilder`. No parameters are set.

    - #### ReloadingCombinedConfigurationBuilder

          public ReloadingCombinedConfigurationBuilder(Map<String,Object> params,
                                                       boolean allowFailOnInit)

      Creates a new instance of `ReloadingCombinedConfigurationBuilder` and sets the specified initialization parameters and the allowFailOnInit flag.
      Parameters:
        `params` - a map with initialization parameters
        `allowFailOnInit` - the allowFailOnInit flag

    - #### ReloadingCombinedConfigurationBuilder

          public ReloadingCombinedConfigurationBuilder(Map<String,Object> params)

      Creates a new instance of `ReloadingCombinedConfigurationBuilder` and sets the specified initialization parameters.
      Parameters:
        `params` - a map with initialization parameters

  - ### Method Detail

    - #### configure

          public ReloadingCombinedConfigurationBuilder configure(BuilderParameters... params)

      Appends the content of the specified `BuilderParameters` objects to the current initialization parameters. Calling this method multiple times will create a union of the parameters provided. This method is overridden to adapt the return type. This method is overridden to adapt the return type.
      Overrides:
        `configure` in class `CombinedConfigurationBuilder`
      Parameters:
        `params` - an arbitrary number of objects with builder parameters
      Returns:
        a reference to this builder for method chaining

    - #### getReloadingController

          public ReloadingController getReloadingController()

      Returns the `ReloadingController` associated with this object. This implementation returns a `CombinedReloadingController` which contains sub controllers for all child configuration sources with reloading support. If the definition builder supports reloading, its controller is contained, too. Note that the combined reloading controller is initialized when the result configuration is created (i.e. when calling `getConfiguration()` for the first time). So this method does not return a meaningful result before.
      Specified by:
        `getReloadingController` in interface `ReloadingControllerSupport`
      Returns:
        the associated `ReloadingController`

    - #### createXMLDefinitionBuilder

          protected ConfigurationBuilder<? extends HierarchicalConfiguration<?>> createXMLDefinitionBuilder(BuilderParameters builderParams)

      Creates a default builder for the definition configuration and initializes it with a parameters object. This method is called if no definition builder is defined in this builder's parameters. This implementation creates a default file-based builder which produces an `XMLConfiguration`; it expects a corresponding file specification. Note: This method is called in a synchronized block. This implementation creates a builder for XML configurations with reloading support.
      Overrides:
        `createXMLDefinitionBuilder` in class `CombinedConfigurationBuilder`
      Parameters:
        `builderParams` - the parameters object for the builder
      Returns:
        the standard builder for the definition configuration

    - #### initResultInstance

          protected void initResultInstance(CombinedConfiguration result)
                                     throws ConfigurationException

      Initializes a newly created result object. This is the second step of the process of producing a result object for this builder. This implementation uses the `BeanHelper` class to initialize the object's property based on the `BeanDeclaration` returned by `BasicConfigurationBuilder.getResultDeclaration()`. Note: This method is invoked in a synchronized block. This is required because internal state is accessed. Sub classes must not call this method without proper synchronization. This implementation processes the definition configuration in order to
      - initialize the resulting `CombinedConfiguration`
      - determine the builders for all configuration sources
      - populate the resulting `CombinedConfiguration`
      This implementation first calls the super method to actually initialize the result configuration. Then it creates the `CombinedReloadingController` for all child configuration sources with reloading support.
      Overrides:
        `initResultInstance` in class `CombinedConfigurationBuilder`
      Parameters:
        `result` - the object to be initialized
      Throws:
        `ConfigurationException` - if an error occurs

    - #### createReloadingController

          protected ReloadingController createReloadingController()
                                                           throws ConfigurationException

      Creates the `ReloadingController` for this builder. This method is called after the result configuration has been created and initialized. It is called from a synchronized block. This implementation creates a `CombinedReloadingController`.
      Returns:
        the `ReloadingController` for this builder
      Throws:
        `ConfigurationException` - if an error occurs

    - #### obtainReloadingController

          public static void obtainReloadingController(Collection<ReloadingController> subControllers,
                                                       Object builder)

      Checks whether the passed in builder object supports reloading. If yes, its reloading controller is obtained and added to the given list.
      Parameters:
        `subControllers` - the list with sub controllers
        `builder` - the builder object to be checked

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