Class HierarchicalConfigProvider<T>
- java.lang.Object
-
- edu.uiuc.ncsa.security.core.configuration.provider.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 Summary
Constructors Constructor Description HierarchicalConfigProvider()HierarchicalConfigProvider(CFNode cfNode)HierarchicalConfigProvider(org.apache.commons.configuration.tree.ConfigurationNode config)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddListener(CfgEventListener c)protected abstract booleancheckEvent(CfgEvent cfgEvent)Checks that the event applies to this component.protected TfireComponentFound(CfgEvent cfgEvent)StringgetAttribute(String key)Gets the attribute with the given key.protected StringgetAttribute(String key, String defaultValue)utility method to supply a default value if the given value is missing.booleangetBooleanAttribute(String key)CFNodegetCFNode()org.apache.commons.configuration.tree.ConfigurationNodegetConfig()org.apache.commons.configuration.tree.ConfigurationNodegetConfigurationAt(String name)Return the givenConfigurationNode.intgetIntAttribute(String key)intgetIntAttribute(String key, int defaultValue)LinkedList<CfgEventListener>getListeners()booleanhasA(String name)Does this have the named component? In other words, is there a configuration of this name one level down?booleanhasCFNode()booleanisA(String name)Check if the configuration is of the indicated type.voidremoveListener(CfgEventListener x)voidsetCFNode(CFNode cfNode)voidsetConfig(org.apache.commons.configuration.tree.ConfigurationNode config)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface edu.uiuc.ncsa.security.core.configuration.provider.CfgEventListener
componentFound
-
-
-
-
Constructor Detail
-
HierarchicalConfigProvider
public HierarchicalConfigProvider()
-
HierarchicalConfigProvider
public HierarchicalConfigProvider(org.apache.commons.configuration.tree.ConfigurationNode config)
-
HierarchicalConfigProvider
public HierarchicalConfigProvider(CFNode cfNode)
-
-
Method Detail
-
getListeners
public LinkedList<CfgEventListener> getListeners()
-
addListener
public void addListener(CfgEventListener c)
-
removeListener
public void removeListener(CfgEventListener x)
-
getCFNode
public CFNode getCFNode()
-
setCFNode
public void setCFNode(CFNode cfNode)
-
hasCFNode
public boolean hasCFNode()
-
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 givenConfigurationNode. This- 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 theCfgEventListener.componentFound(CfgEvent)method. If checkEvent fails, do no more processing with the event.- Parameters:
cfgEvent-- Returns:
-
-