Class 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
    • Field Detail

      • reloadingController

        private ReloadingController reloadingController
        The reloading controller used by this builder.
    • Constructor Detail

      • ReloadingCombinedConfigurationBuilder

        public ReloadingCombinedConfigurationBuilder()
        Creates a new instance of ReloadingCombinedConfigurationBuilder. No parameters are set.
      • ReloadingCombinedConfigurationBuilder

        public ReloadingCombinedConfigurationBuilder​(java.util.Map<java.lang.String,​java.lang.Object> params)
        Creates a new instance of ReloadingCombinedConfigurationBuilder and sets the specified initialization parameters.
        Parameters:
        params - a map with initialization parameters
      • ReloadingCombinedConfigurationBuilder

        public ReloadingCombinedConfigurationBuilder​(java.util.Map<java.lang.String,​java.lang.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
    • Method Detail

      • obtainReloadingController

        public static void obtainReloadingController​(java.util.Collection<ReloadingController> subControllers,
                                                     java.lang.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
      • 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
      • 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
      • 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
      • getReloadingController

        public ReloadingController getReloadingController()
        Gets 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
      • 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