public final class ConfigManager extends Object implements Contextualizable, Serviceable, Initializable
Modifier and Type | Field and Description |
---|---|
private static ConfigManager |
__manager |
private Map<I18nizableText,ConfigParameterCategory> |
_categorizedParameters |
private Context |
_context |
private Map<String,ConfigParameterInfo> |
_declaredParameterCheckers |
private Map<String,ConfigParameterInfo> |
_declaredParams |
private ThreadSafeComponentManager<Enumerator> |
_enumeratorManager |
private boolean |
_isComplete |
private boolean |
_isInitialized |
(package private) Logger |
_logger |
private ServiceManager |
_manager |
private ThreadSafeComponentManager<ParameterChecker> |
_parameterCheckerManager |
private Map<String,ConfigParameterCheckerDescriptor> |
_parameterCheckers |
private Map<String,ConfigParameter> |
_params |
private Collection<String> |
_usedParamsName |
private ThreadSafeComponentManager<Validator> |
_validatorManager |
static Pattern |
CONFIG_ID_PATTERN
the regular expression for ids
|
private static String |
FIELD_SEPARATOR
The field separator for the field hierarchy
|
Modifier | Constructor and Description |
---|---|
private |
ConfigManager() |
Modifier and Type | Method and Description |
---|---|
private Map<String,Object> |
_bindAndValidateParameters(Map<String,String> untypedValues,
Map<String,String> oldUntypedValues,
Map<String,Errors> errorFields)
Bind all parameters to typed values and for each, if enabled, validate it
|
private Map<I18nizableText,ConfigParameterCategory> |
_categorizeParameters(Map<String,ConfigParameter> params,
Map<String,ConfigParameterCheckerDescriptor> paramCheckers) |
private boolean |
_evaluateCondition(DisableCondition condition,
Map<String,String> untypedValues) |
private Object |
_getValue(String paramID,
ParameterHelper.ParameterType type,
Map<String,String> untypedValues) |
private void |
_toSAX(TransformerHandler handler,
Map<String,Object> typedValues)
SAX the config values into a content handler
|
private Object |
_validateParameter(Map<String,String> untypedValues,
ConfigParameter parameter) |
private void |
_validateParameters(Map<String,String> untypedValues) |
void |
addConfig(String featureId,
Map<String,ConfigParameterInfo> parameters,
Collection<String> parametersReferences,
Map<String,ConfigParameterInfo> paramCheckers)
Registers a new parameter or references a globalConfig parameter.
|
void |
addGlobalConfig(String pluginName,
Map<String,ConfigParameterInfo> parameters,
Map<String,ConfigParameterInfo> paramCheckers)
Registers new available parameters.
The addConfig() method allows to select which ones are actually useful. |
void |
contextualize(Context context) |
void |
dispose()
Dispose the manager before restarting it
|
boolean |
evaluateDisableConditions(DisableConditions disableConditions,
Map<String,String> untypedValues)
Recursively evaluate the
DisableConditions against the configuration values |
ConfigParameter |
get(String id)
Gets the config parameter by its id
|
Map<I18nizableText,ConfigParameterCategory> |
getCategories()
Returns all
ConfigParameter grouped by categories and groups. |
static ConfigManager |
getInstance()
Returns the shared instance of the
PluginManager |
ConfigParameterCheckerDescriptor |
getParameterChecker(String id)
Gets the parameter checker with its id
|
Map<String,ConfigParameterCheckerDescriptor> |
getParameterCheckers()
Returns all
ConfigParameterCheckerDescriptor s. |
Map<String,ConfigParameter> |
getParameters()
Gets the typed configuration parameters
|
String[] |
getParametersIds()
Get the id of the config parameters.
|
Map<String,Object> |
getValues()
Returns typed config values.
|
void |
initialize() |
boolean |
isComplete()
Returns true if the model is initialized and all parameters are valued
|
boolean |
isEmpty()
Returns true if the config file does not exist
|
Map<String,Errors> |
save(Map<String,String> untypedValues,
String fileName)
Update the configuration file with the given values
Values are untyped (all are of type String) and might be null. |
void |
service(ServiceManager manager) |
void |
validate()
Ends the initialization of the config parameters, by checking against the
already valued parameters.
If at least one parameter has no value, the application won't start. |
public static final Pattern CONFIG_ID_PATTERN
private static final String FIELD_SEPARATOR
private static ConfigManager __manager
private ServiceManager _manager
private Collection<String> _usedParamsName
private Map<String,ConfigParameterInfo> _declaredParams
private Map<String,ConfigParameter> _params
private Map<String,ConfigParameterInfo> _declaredParameterCheckers
private Map<String,ConfigParameterCheckerDescriptor> _parameterCheckers
private Map<I18nizableText,ConfigParameterCategory> _categorizedParameters
private boolean _isInitialized
private boolean _isComplete
private ThreadSafeComponentManager<Validator> _validatorManager
private ThreadSafeComponentManager<Enumerator> _enumeratorManager
private ThreadSafeComponentManager<ParameterChecker> _parameterCheckerManager
private ConfigManager()
public static ConfigManager getInstance()
PluginManager
public boolean isComplete()
public boolean isEmpty()
public void contextualize(Context context)
contextualize
in interface Contextualizable
public void service(ServiceManager manager)
service
in interface Serviceable
public void initialize()
initialize
in interface Initializable
public void addGlobalConfig(String pluginName, Map<String,ConfigParameterInfo> parameters, Map<String,ConfigParameterInfo> paramCheckers)
pluginName
- the name of the plugin defining the parametersparameters
- the config parameters definitionparamCheckers
- the parameters checkers definitionpublic void addConfig(String featureId, Map<String,ConfigParameterInfo> parameters, Collection<String> parametersReferences, Map<String,ConfigParameterInfo> paramCheckers)
featureId
- the id of the feature defining the parametersparameters
- the config parameters definitionparametersReferences
- references to already defined parametersparamCheckers
- the parameters checkers definitionpublic void validate()
private void _validateParameters(Map<String,String> untypedValues)
private Object _validateParameter(Map<String,String> untypedValues, ConfigParameter parameter)
public boolean evaluateDisableConditions(DisableConditions disableConditions, Map<String,String> untypedValues)
DisableConditions
against the configuration valuesdisableConditions
- the disable conditions to evaluateuntypedValues
- the untyped configuration valuesprivate boolean _evaluateCondition(DisableCondition condition, Map<String,String> untypedValues)
public void dispose()
public String[] getParametersIds()
public Map<String,Object> getValues()
public Map<I18nizableText,ConfigParameterCategory> getCategories()
ConfigParameter
grouped by categories and groups.ConfigParameter
.public ConfigParameter get(String id)
id
- Id of the config parameter to getpublic Map<String,ConfigParameter> getParameters()
public Map<String,ConfigParameterCheckerDescriptor> getParameterCheckers()
ConfigParameterCheckerDescriptor
s.ConfigParameterCheckerDescriptor
s.public ConfigParameterCheckerDescriptor getParameterChecker(String id)
id
- the id of the parameter checker to getprivate Map<I18nizableText,ConfigParameterCategory> _categorizeParameters(Map<String,ConfigParameter> params, Map<String,ConfigParameterCheckerDescriptor> paramCheckers)
private Object _getValue(String paramID, ParameterHelper.ParameterType type, Map<String,String> untypedValues)
public Map<String,Errors> save(Map<String,String> untypedValues, String fileName) throws Exception
untypedValues
- A map (key, untyped value).fileName
- the config file absolute pathException
- If an error occurred while saving valuesprivate Map<String,Object> _bindAndValidateParameters(Map<String,String> untypedValues, Map<String,String> oldUntypedValues, Map<String,Errors> errorFields)
untypedValues
- The untyped values (from client-side)oldUntypedValues
- The old untyped values (before saving)errorFields
- The parameters in errors to be completed by validation processprivate void _toSAX(TransformerHandler handler, Map<String,Object> typedValues) throws SAXException
handler
- Handler where to saxtypedValues
- Map (key, typed value) to saxSAXException
- if an error occurred