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(org.apache.commons.configuration.tree.ConfigurationNode config)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addListener(CfgEventListener c)
protected abstract boolean
checkEvent(CfgEvent cfgEvent)
Checks that the event applies to this component.protected T
fireComponentFound(CfgEvent cfgEvent)
String
getAttribute(String key)
Gets the attribute with the given key.protected String
getAttribute(String key, String defaultValue)
utility method to supply a default value if the given value is missing.boolean
getBooleanAttribute(String key)
org.apache.commons.configuration.tree.ConfigurationNode
getConfig()
org.apache.commons.configuration.tree.ConfigurationNode
getConfigurationAt(String name)
Return the given configurationint
getIntAttribute(String key)
int
getIntAttribute(String key, int defaultValue)
LinkedList<CfgEventListener>
getListeners()
boolean
hasA(String name)
Does this have the named component? In other words, is there a configuration of this name one level down?boolean
isA(String name)
Check if the configuration is of the indicated type.void
removeListener(CfgEventListener x)
void
setConfig(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
-
-
-
-
Method Detail
-
getListeners
public LinkedList<CfgEventListener> getListeners()
-
addListener
public void addListener(CfgEventListener c)
-
removeListener
public void removeListener(CfgEventListener x)
-
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 theCfgEventListener.componentFound(CfgEvent)
method. If checkEvent fails, do no more processing with the event.- Parameters:
cfgEvent
-- Returns:
-
-