Class CmsParameterStore
Parameter files are XML configuration files that contain a list of named, string-valued configuration parameters, optionally with a numeric weight. The weight can be set individually for each parameter, or globally for a whole parameter file, but individual weights override parameter file weights. The schema for these is defined in org/opencm/configuration/paramfile.dtd.
To register a parameter file in OpenCms, its path must be listed as a value of the 'paramfile' module parameter for an installed module. The module parameter can be set on multiple modules, and may also contain multiple paths separated by commas.
When retrieving a value that is defined in multiple parameter files, the one with the highest weight wins. If there are multiple instances with the same weight, which one of them wins is implementation dependent.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
An individual weighted parameter value, with a 'source' attribute for better debuggability. -
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic CmsParameterStore
Gets the global instance.Gets the string value with the maximal weight for the parameter with the given key.getWeightedValue
(CmsObject cms, String key) Finds the value with the maximal weight for the given key.static Map<String,
CmsParameterStore.WeightedValue> Helper method for parsing a parameter file from a byte array.static Map<String,
CmsParameterStore.WeightedValue> Parses a parameter file from an XML element.static Map<String,
CmsParameterStore.WeightedValue> Helper method for parsing a parameter file from a VFS resource.
-
Field Details
-
A_NAME
XML attribute name.- See Also:
-
A_WEIGHT
XML attribute name.- See Also:
-
DEFAULT_WEIGHT
Default weight, if not defined in parameter file.- See Also:
-
N_PARAM
XML node name.- See Also:
-
PARAM_PARAMFILE
Module parameter for registering parameter files.- See Also:
-
-
Constructor Details
-
CmsParameterStore
public CmsParameterStore()
-
-
Method Details
-
getInstance
Gets the global instance.- Returns:
- the global instance
-
parse
public static Map<String,CmsParameterStore.WeightedValue> parse(byte[] data, String source) throws CmsXmlException Helper method for parsing a parameter file from a byte array.- Parameters:
data
- the binary data for the parameter filesource
- the source identifier- Returns:
- the of parameters
- Throws:
CmsXmlException
- if something goes wrong
-
parse
public static Map<String,CmsParameterStore.WeightedValue> parse(CmsObject cms, String path) throws CmsException Helper method for parsing a parameter file from a VFS resource.- Parameters:
cms
- the CmsObjectpath
- the path of the resource- Returns:
- the map of parameters
- Throws:
CmsException
- if something goes wrong
-
parse
public static Map<String,CmsParameterStore.WeightedValue> parse(org.dom4j.Element rootElem, String source) Parses a parameter file from an XML element.- Parameters:
rootElem
- the root element of the XMLsource
- the source identifier- Returns:
- the parameter map
-
getValue
Gets the string value with the maximal weight for the parameter with the given key.- Parameters:
cms
- the CMS contextkey
- the key- Returns:
- the string value with maximal weight
-
getWeightedValue
Finds the value with the maximal weight for the given key.- Parameters:
cms
- the CMS contextkey
- the parameter key- Returns:
- the value with the maximal weight
-