public final class ConfigManager extends Object implements Model, Contextualizable, Serviceable, Initializable
Modifier and Type | Field and Description |
---|---|
private static ConfigManager |
__manager |
private List<ModelItem> |
_categorizedDefinitions |
private Map<String,CategorizedElementDefinitionProxy> |
_categorizedParameterProxies |
private ConfigParameterTypeExtensionPoint |
_configParameterTypeEP |
private Context |
_context |
private Map<String,ConfigParameterInfo> |
_declaredParamCheckers |
private Map<String,ConfigParameterInfo> |
_declaredParams |
private ThreadSafeComponentManager<Enumerator> |
_enumeratorManager |
private Map<String,ElementDefinition> |
_flatDefinitions |
private boolean |
_isComplete |
private boolean |
_isInitialized |
private Logger |
_logger |
private ThreadSafeComponentManager<ItemChecker> |
_parameterCheckerManager |
private Map<String,ConfigParameterCheckerDescriptor> |
_parameterCheckers |
private ServiceManager |
_serviceManager |
private Logger |
_threadSafeComponentLogger |
private Collection<String> |
_usedParamIds |
private ThreadSafeComponentManager<Validator> |
_validatorManager |
Modifier | Constructor and Description |
---|---|
private |
ConfigManager() |
Modifier and Type | Method and Description |
---|---|
private void |
_addParameterCheckersToModelItems() |
private void |
_categorizeParameters() |
private void |
_declareParameterCheckers(Map<String,ConfigParameterInfo> parameterCheckers) |
private void |
_declareParameters(Map<String,ConfigParameterInfo> parameters) |
private Map<String,DefinitionAndValue> |
_getDefinitionAndResolvedValues(Map<String,Object> values,
Map<String,DefinitionAndValue> oldDefinitionAndValues) |
private Map<String,DefinitionAndValue> |
_getDefinitionAndValues(Map<String,Object> values) |
private ModelItemGroup |
_getModelItemGroup(List<ModelItem> items,
I18nizableText itemGroupLabel) |
private void |
_parseParameterCheckers(ConfigParameterCheckerParser parameterCheckerParser) |
private void |
_parseParameters(ConfigParameterDefinitionParser parser) |
private Object |
_resolveValue(ElementDefinition definition,
Object value,
Map<String,DefinitionAndValue> oldDefinitionAndValues) |
private void |
_saxConfigurationFile(String fileName,
Map<String,DefinitionAndValue> definitionAndValues) |
private void |
_saxParameters(TransformerHandler handler,
Map<String,Object> values) |
private void |
_validateParametersForReading() |
void |
addFeatureConfig(String featureId,
Map<String,ConfigParameterInfo> parameters,
Map<String,ConfigParameterInfo> parameterCheckers,
Collection<String> parameterReferences)
Registers a new parameter or references a globalConfig parameter.
|
void |
addPluginConfig(String pluginName,
Map<String,ConfigParameterInfo> parameters,
Map<String,ConfigParameterInfo> parameterCheckers)
Registers new available parameters.
|
void |
contextualize(Context context) |
void |
dispose()
Dispose the manager before restarting it
|
boolean |
evaluateDisableConditions(DisableConditions disableConditions,
Map<String,Object> values)
Recursively evaluate the
DisableConditions against the configuration values |
Collection<ElementDefinition> |
getConfigurationParameters()
Retrieves all configuration parameters
|
String |
getFamilyId()
Retrieves the Family Id (for example the extension point)
Each model Id have to be unique in it's family Id
|
String |
getId()
Retrieves the model id (an id must be unique in the family
Model.getFamilyId() |
static ConfigManager |
getInstance()
Returns the shared instance of the ConfigManager
|
ModelItem |
getModelItem(String itemPath)
Retrieves the model item at given path
|
Collection<ModelItem> |
getModelItems()
Retrieves all the model items of this container
|
Map<String,DefinitionAndValue> |
getOldDefinitionAndValues()
Retrieves old definition and values if the configuration is not well initialized
|
ConfigParameterCheckerDescriptor |
getParameterChecker(String id)
Gets the parameter checker with its id
|
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
|
void |
parseAndValidate()
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. |
String |
resolveValueForParameterChecker(String parameterName,
Object value,
Map<String,DefinitionAndValue> oldDefinitionAndValues)
Resolve the given value for the parameter check
|
Map<String,List<I18nizableText>> |
save(Map<String,Object> values,
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) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getChild, hasModelItem
private static ConfigManager __manager
private Logger _threadSafeComponentLogger
private ServiceManager _serviceManager
private ThreadSafeComponentManager<Validator> _validatorManager
private ThreadSafeComponentManager<Enumerator> _enumeratorManager
private ThreadSafeComponentManager<ItemChecker> _parameterCheckerManager
private Map<String,ConfigParameterInfo> _declaredParams
private Map<String,ConfigParameterInfo> _declaredParamCheckers
private Collection<String> _usedParamIds
private Map<String,CategorizedElementDefinitionProxy> _categorizedParameterProxies
private Map<String,ConfigParameterCheckerDescriptor> _parameterCheckers
private List<ModelItem> _categorizedDefinitions
private Map<String,ElementDefinition> _flatDefinitions
private boolean _isInitialized
private boolean _isComplete
private ConfigParameterTypeExtensionPoint _configParameterTypeEP
private ConfigManager()
public static ConfigManager getInstance()
public void contextualize(Context context)
contextualize
in interface Contextualizable
public void service(ServiceManager manager) throws ServiceException
service
in interface Serviceable
ServiceException
public void initialize()
initialize
in interface Initializable
public void addPluginConfig(String pluginName, Map<String,ConfigParameterInfo> parameters, Map<String,ConfigParameterInfo> parameterCheckers)
pluginName
- the name of the plugin defining the parametersparameters
- the configuration parameters definitionparameterCheckers
- the parameters checkers definitionpublic void addFeatureConfig(String featureId, Map<String,ConfigParameterInfo> parameters, Map<String,ConfigParameterInfo> parameterCheckers, Collection<String> parameterReferences)
featureId
- the id of the feature defining the parametersparameters
- the configuration parameters definitionparameterCheckers
- the parameters checkers definitionparameterReferences
- references to already defined parametersprivate void _declareParameters(Map<String,ConfigParameterInfo> parameters)
private void _declareParameterCheckers(Map<String,ConfigParameterInfo> parameterCheckers)
public void parseAndValidate()
private void _parseParameters(ConfigParameterDefinitionParser parser)
private void _parseParameterCheckers(ConfigParameterCheckerParser parameterCheckerParser)
private void _categorizeParameters()
private void _addParameterCheckersToModelItems()
private ModelItemGroup _getModelItemGroup(List<ModelItem> items, I18nizableText itemGroupLabel)
private void _validateParametersForReading()
public Map<String,List<I18nizableText>> save(Map<String,Object> values, String fileName) throws Exception
values
- A map (key, value).fileName
- the configuration file absolute pathException
- If an error occurred while saving valuespublic Map<String,DefinitionAndValue> getOldDefinitionAndValues()
private Map<String,DefinitionAndValue> _getDefinitionAndResolvedValues(Map<String,Object> values, Map<String,DefinitionAndValue> oldDefinitionAndValues)
public String resolveValueForParameterChecker(String parameterName, Object value, Map<String,DefinitionAndValue> oldDefinitionAndValues)
parameterName
- name of the parameter to resolvevalue
- the value to resolveoldDefinitionAndValues
- the old definition and values if the configuration is not initializedprivate Object _resolveValue(ElementDefinition definition, Object value, Map<String,DefinitionAndValue> oldDefinitionAndValues)
private void _saxConfigurationFile(String fileName, Map<String,DefinitionAndValue> definitionAndValues) throws TransformerFactoryConfigurationError, Exception
private void _saxParameters(TransformerHandler handler, Map<String,Object> values) throws SAXException
SAXException
public boolean evaluateDisableConditions(DisableConditions disableConditions, Map<String,Object> values)
DisableConditions
against the configuration valuesdisableConditions
- the disable conditions to evaluatevalues
- the configuration valuesprivate Map<String,DefinitionAndValue> _getDefinitionAndValues(Map<String,Object> values)
public ModelItem getModelItem(String itemPath) throws UndefinedItemPathException
ModelItemContainer
getModelItem
in interface ModelItemContainer
itemPath
- the item pathUndefinedItemPathException
- if there is no item defined at the given pathpublic Collection<ElementDefinition> getConfigurationParameters()
public Collection<ModelItem> getModelItems()
ModelItemContainer
getModelItems
in interface ModelItemContainer
public ConfigParameterCheckerDescriptor getParameterChecker(String id)
id
- the id of the parameter checker to getpublic boolean isComplete()
public boolean isEmpty()
public void dispose()
public String getId()
Model
Model.getFamilyId()
public String getFamilyId()
Model
getFamilyId
in interface Model