Class HierarchicalConfigProvider<T>

  • All Implemented Interfaces:
    CfgEventListener, EventListener, javax.inject.Provider<T>
    Direct Known Subclasses:
    ConnectionPoolProvider, MailUtilProvider, TypedProvider

    public abstract class HierarchicalConfigProvider<T>
    extends Object
    implements javax.inject.Provider<T>, CfgEventListener


    All configurations are interpreted locally, that is to say, it is up to something else to hand over the relevant node for this provider. Generally providers should not be aware of the complete hierarchy since that may be hard or impossible to navigate without a lot more information.

    Created by Jeff Gaynor
    on 1/10/12 at 1:57 PM

    • Constructor Detail

      • HierarchicalConfigProvider

        public HierarchicalConfigProvider()
      • HierarchicalConfigProvider

        public HierarchicalConfigProvider​(org.apache.commons.configuration.tree.ConfigurationNode config)
    • Method Detail

      • fireComponentFound

        protected T fireComponentFound​(CfgEvent cfgEvent)
      • getConfig

        public org.apache.commons.configuration.tree.ConfigurationNode getConfig()
      • setConfig

        public void setConfig​(org.apache.commons.configuration.tree.ConfigurationNode config)
      • getAttribute

        public String getAttribute​(String key)
        Gets the attribute with the given key. This slaps "[@" and "]" around the key to conform with how Apache resolves these.
        Parameters:
        key -
        Returns:
      • getAttribute

        protected String getAttribute​(String key,
                                      String defaultValue)
        utility method to supply a default value if the given value is missing.
        Parameters:
        key -
        defaultValue -
        Returns:
      • getIntAttribute

        public int getIntAttribute​(String key,
                                   int defaultValue)
      • getIntAttribute

        public int getIntAttribute​(String key)
      • getBooleanAttribute

        public boolean getBooleanAttribute​(String key)
      • isA

        public boolean isA​(String name)
        Check if the configuration is of the indicated type. This means that the root node has the name of the component, e.g. fileStore, mysql or whatever.
        Parameters:
        name -
        Returns:
      • hasA

        public boolean hasA​(String name)
        Does this have the named component? In other words, is there a configuration of this name one level down?
        Parameters:
        name -
        Returns:
      • getConfigurationAt

        public org.apache.commons.configuration.tree.ConfigurationNode getConfigurationAt​(String name)
        Return the given configuration
        Parameters:
        name -
        Returns:
      • checkEvent

        protected abstract boolean checkEvent​(CfgEvent cfgEvent)
        Checks that the event applies to this component. The type is the component and the target is Normally you set the component key as a static field in the class (e.g. "mysql") and pass it along in the the CfgEventListener.componentFound(CfgEvent) method. If checkEvent fails, do no more processing with the event.
        Parameters:
        cfgEvent -
        Returns: