Package org.apache.uima.resource.impl
Class ConfigurationManagerImplBase
java.lang.Object
org.apache.uima.resource.impl.ConfigurationManagerImplBase
- All Implemented Interfaces:
ConfigurationManager
- Direct Known Subclasses:
ConfigurationManager_impl
Convenience base class for Configuration Manager implementations. Subclasses just need to
implement the abstract methods
declareParameters(String, ConfigurationParameter[], ConfigurationParameterSettings, String, Settings)
and lookupSharedParamNoLinks(String)
.-
Field Summary
Modifier and TypeFieldDescriptionprotected static final char
Character that separates parameter name from group name in the parameter map.Map the fully-qualified name of a parameter to the fully-qualified name of the parameter it is linked to (from which it takes its value).protected static final String
Key under which to store configuration information in the Session object. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
createContext
(String aContextName, ResourceMetaData aResourceMetaData, Settings externalOverrides) Creates and sets up a new configuration parameter context.protected void
declareParameters
(String aGroupName, ConfigurationParameter[] aParams, ConfigurationParameterSettings aSettings, String aContextName, Settings aExternalOverrides) Called during creation of a new context.getConfigParameterDeclarations
(String aContextName) Gets the ConfigurationParameterDeclarations for the given context.getConfigParameterValue
(String aQualifiedParameterName) Retrieves the value for a configuration parameter.getConfigParameterValue
(String aQualifiedParameterName, String aGroupName) Retrieves the value for a configuration parameter in a group.getCurrentConfigParameterSettings
(String aContextName) Gets an object containing the current settings for all configuration parameters within the given context.protected String
Gets the name of the parameter to which a given parameter is linked.protected Class<?>
Get the Java class of the expected value of the specified parameter.protected Object
Does a direct lookup of a complete name, including the group.protected abstract Object
lookupSharedParamNoLinks
(String aCompleteName) Looks up the value of a shared parameter, but does NOT follow links.protected String
makeQualifiedName
(String aContextName, String aParamName, String aGroupName) Creates a qualified parameter name.void
reconfigure
(String aContextName) Completes the reconfiguration of parameters within the specified context.void
setConfigParameterValue
(String aQualifiedParamName, Object aValue) Sets the value of a configuration parameter.void
setConfigParameterValue
(String aQualifiedParamName, String aGroupName, Object aValue) Sets the value of a configuration parameter in a group.void
setSession
(Session aSession) Sets the currentSession
.
-
Field Details
-
GROUP_SEPARATOR
protected static final char GROUP_SEPARATORCharacter that separates parameter name from group name in the parameter map.- See Also:
-
SESSION_CONFIGURATION_KEY
Key under which to store configuration information in the Session object.- See Also:
-
mLinkMap
Map the fully-qualified name of a parameter to the fully-qualified name of the parameter it is linked to (from which it takes its value). Not sync'd based on belief: setup of values must be complete before any reference occurs, even in multi-threaded context. The setup is done under a sync'd control to insure only one setup is done
-
-
Constructor Details
-
ConfigurationManagerImplBase
public ConfigurationManagerImplBase()
-
-
Method Details
-
setSession
Description copied from interface:ConfigurationManager
Sets the currentSession
. The Configuration Manager uses theSession
object to store changes to configuration settings made by calling thesetConfigParameterValue
methods. This ensures that in a multi-client deployment those settings only apply to the same client that set them.Code that uses this class must be sure to call
setSession
before using the other methods (exceptcreateContext
) on this class.- Specified by:
setSession
in interfaceConfigurationManager
- Parameters:
aSession
- the session object used to store configuration parameter overrides made by a particular client.
-
getSession
-
createContext
public void createContext(String aContextName, ResourceMetaData aResourceMetaData, Settings externalOverrides) throws ResourceConfigurationException Description copied from interface:ConfigurationManager
Creates and sets up a new configuration parameter context. This method is called during the initialization of each Resource that uses this Configuration Manager. Validation will be performed on the configuration parameters declared in this context; if an error is found an exception will be thrown. Multi-threading: This may be called with the same parameters on multiple threads. Implementations should check for repeated calls to create the same context and just return in that case- Specified by:
createContext
in interfaceConfigurationManager
- Parameters:
aContextName
- the name of the context in which the configuration parameter is being accessed. This corresponds to the path through the aggregate resource, e.g /subAE1/annotator1.aResourceMetaData
- metadata object containing the configuration parameter declarations and settings.externalOverrides
- the external overrides- Throws:
ResourceConfigurationException
- if the configuration settings are invalid
-
getConfigParameterValue
Description copied from interface:ConfigurationManager
Retrieves the value for a configuration parameter.- Specified by:
getConfigParameterValue
in interfaceConfigurationManager
- Parameters:
aQualifiedParameterName
- the fully-qualified configuration parameter name. This is of the formContextName + / + ParameterName
.- Returns:
- the value of the parameter with the given name. The caller is expected to know the data
type of the parameter. If the parameter does not exist,
null
is returned.
-
getConfigParameterValue
Description copied from interface:ConfigurationManager
Retrieves the value for a configuration parameter in a group.- Specified by:
getConfigParameterValue
in interfaceConfigurationManager
- Parameters:
aQualifiedParameterName
- the fully-qualified configuration parameter name. This is of the formContextName + / + ParameterName
.aGroupName
- the name of the parameter group- Returns:
- the value of the parameter with the given name. The caller is expected to know the data
type of the parameter. If the parameter does not exist,
null
is returned.
-
setConfigParameterValue
Description copied from interface:ConfigurationManager
Sets the value of a configuration parameter. This only works for a parameter that is not defined in any group. Note that there is no guarantee that the change will take effect untilConfigurationManager.reconfigure(String)
is called.- Specified by:
setConfigParameterValue
in interfaceConfigurationManager
- Parameters:
aQualifiedParamName
- the fully-qualified configuration parameter name. This is of the formContextName + / + ParameterName
.aValue
- the value to assign to the parameter
-
setConfigParameterValue
Description copied from interface:ConfigurationManager
Sets the value of a configuration parameter in a group. Note that there is no guarantee that the change will take effect untilConfigurationManager.reconfigure(String)
is called.- Specified by:
setConfigParameterValue
in interfaceConfigurationManager
- Parameters:
aQualifiedParamName
- the fully-qualified configuration parameter name. This is of the formContextName + / + ParameterName
.aGroupName
- the name of a configuration group. If this parameter isnull
, this method will have the same effect assetParameterValue(String,Object)
.aValue
- the value to assign to the parameter
-
reconfigure
Description copied from interface:ConfigurationManager
Completes the reconfiguration of parameters within the specified context. Also validates the parameter settings.- Specified by:
reconfigure
in interfaceConfigurationManager
- Parameters:
aContextName
- the name of the context being reconfigured- Throws:
ResourceConfigurationException
- if the new configuration is invalid
-
getConfigParameterDeclarations
Description copied from interface:ConfigurationManager
Gets the ConfigurationParameterDeclarations for the given context.- Specified by:
getConfigParameterDeclarations
in interfaceConfigurationManager
- Parameters:
aContextName
- the name for which to get the parameter declarations- Returns:
- parameter declarations for the context or
null
if there are no declarations.
-
getCurrentConfigParameterSettings
Description copied from interface:ConfigurationManager
Gets an object containing the current settings for all configuration parameters within the given context.- Specified by:
getCurrentConfigParameterSettings
in interfaceConfigurationManager
- Parameters:
aContextName
- name of context for which to retrieve parameter settings- Returns:
- an object containing the current configuration parameter settings
-
lookup
Does a direct lookup of a complete name, including the group. Follows links but does not do any fallback processing. An external name definition overrides all- Parameters:
aCompleteName
- complete name, of the form context/parameter$group- Returns:
- value of parameter, null if none
-
declareParameters
protected void declareParameters(String aGroupName, ConfigurationParameter[] aParams, ConfigurationParameterSettings aSettings, String aContextName, Settings aExternalOverrides) throws ResourceConfigurationException Called during creation of a new context. Declares parameters, optionally in a group. Concrete subclasses will likely want to override this to set up any necessary data structures.- Parameters:
aGroupName
- name of parameter group, null if noneaParams
- parameter declarationsaSettings
- settings for parametersaContextName
- name of context containing this parameteraExternalOverrides
- settings for parameters with external overrides- Throws:
ResourceConfigurationException
- passthru
-
getLink
Gets the name of the parameter to which a given parameter is linked.- Parameters:
aCompleteName
- complete name, of the form context/parameter$group- Returns:
- if the parameter with name
aCompleteName
is linked to another parameter, the complete name of that parameter is returned. Otherwise, null is returned.
-
makeQualifiedName
Creates a qualified parameter name. This consists of the context name followed by the param name (separate by a slash), followed by a $ character and the group name (if a group is specified).- Parameters:
aContextName
- the name of the context containing this parameteraParamName
- the configuration parameter nameaGroupName
- the name of the group containining the parameter, null if none- Returns:
- the qualified parameter name
-
getParameterExpectedValueClass
Get the Java class of the expected value of the specified parameter.- Parameters:
aParam
- configuration parameter declaration information- Returns:
- the expected value class
-