Package org.ametys.runtime.config
Class Config
- java.lang.Object
-
- org.ametys.runtime.config.Config
-
-
Field Summary
Fields Modifier and Type Field Description private static Config__configprivate static boolean__fileExistsprivate static String__filenameprivate static boolean__initializedprivate static long__lastModifiedprivate static org.slf4j.Logger__loggerprivate static Model__modelprivate Map<String,DefinitionAndValue>_definitionAndValues
-
Constructor Summary
Constructors Modifier Constructor Description privateConfig()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static Map<String,Object>__extractValues(Map<String,DefinitionAndValue> definitionAndValues)(package private) static Map<String,DefinitionAndValue>__read()Read configuration fileprivate void_load()private void_reloadIfNeeded()static voiddispose()Dispose thisConfiginstancestatic booleanfileExists()Returns true if the configuration filename exists.static ConfiggetInstance()Get the instance of Config using the config file.<T> TgetValue(String name)Retrieves the typed parameter value<T> TgetValue(String name, boolean useDefaultFromModel, T defaultValue)Retrieves the typed parameter value, or the default valueMap<String,Object>getValues()Retrieves all configuration parameter valuesstatic Map<String,Object>getValuesAsJSONForClient()Retrieves all configuration parameter values as JSON objectsstatic voidsetFilename(String filename)Set the configuration filenamestatic voidsetInitialized(boolean initialized)Set the initialization status of the configurationstatic voidsetModel(Model model)Sets the configuration model
-
-
-
Field Detail
-
__logger
private static org.slf4j.Logger __logger
-
__initialized
private static boolean __initialized
-
__filename
private static String __filename
-
__fileExists
private static boolean __fileExists
-
__lastModified
private static long __lastModified
-
_definitionAndValues
private Map<String,DefinitionAndValue> _definitionAndValues
-
-
Constructor Detail
-
Config
private Config()
-
-
Method Detail
-
getInstance
public static Config getInstance()
Get the instance of Config using the config file.- Returns:
- An instance of Config containing config file values and definition, or null if config file cannot be read.
-
setModel
public static void setModel(Model model)
Sets the configuration model- Parameters:
model- the model to set
-
_reloadIfNeeded
private void _reloadIfNeeded()
-
__read
static Map<String,DefinitionAndValue> __read() throws Exception
Read configuration file- Returns:
- the configuration definition and values
- Throws:
Exception- if a problem occurs reading values
-
setInitialized
public static void setInitialized(boolean initialized)
Set the initialization status of the configuration- Parameters:
initialized- the initialization status of the configuration
-
setFilename
public static void setFilename(String filename)
Set the configuration filename- Parameters:
filename- Name with path of the configuration file
-
fileExists
public static boolean fileExists()
Returns true if the configuration filename exists.- Returns:
- true if the configuration filename exists.
-
getValues
public Map<String,Object> getValues()
Retrieves all configuration parameter values- Returns:
- the configuration values
-
__extractValues
static Map<String,Object> __extractValues(Map<String,DefinitionAndValue> definitionAndValues)
-
getValuesAsJSONForClient
public static Map<String,Object> getValuesAsJSONForClient()
Retrieves all configuration parameter values as JSON objects- Returns:
- the configuration values as JSON objects
-
getValue
public <T> T getValue(String name)
Retrieves the typed parameter value- Type Parameters:
T- type of the value to retrieve- Parameters:
name- name of the configuration parameter- Returns:
- the parameter value
-
getValue
public <T> T getValue(String name, boolean useDefaultFromModel, T defaultValue)
Retrieves the typed parameter value, or the default value- Type Parameters:
T- type of the value to retrieve- Parameters:
name- name of the configuration parameteruseDefaultFromModel- true to use the default value from the model, false to use the give default valuedefaultValue- default value used if value is null and useDefaultFromModel is false, or if there is no default value on model- Returns:
- the parameter value
-
-