Class AppConstants
- All Implemented Interfaces:
Serializable
,Cloneable
,Map<Object,
Object>
When an instance is created, it tries to load the properties file specified
by the propertiesFileName
field
If a property exits with the name ADDITIONAL.PROPERTIES.FILE
that file is loaded also
There is a global instance that can be retrieved with getInstance()
, and an
instance per configuration that can be retrieved with getInstance(ClassLoader)
using the configuration classloader. Each method will the instance if it does not yet exist.
To change a value across all instances, use setGlobalProperty(String, String)
. Changing
a value for only a single instance with setProperty(String, String)
is in general recommended
only for tests.
- Version:
- 2.1
- Author:
- Niels Meijer
- See Also:
-
Field Summary
FieldsFields inherited from class java.util.Properties
defaults
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
Clear a property in all instances of AppConstants.getAppConstants
(String keyBase) Returns a list ofAppConstants
which names begin with the keyBasegetAppConstants
(String keyBase, boolean useSystemProperties, boolean useEnvironmentVariables) Returns a list ofAppConstants
which names begin with the keyBasestatic AppConstants
Return the AppConstants root instancestatic AppConstants
getInstance
(ClassLoader classLoader) Retrieve an instance based on a ClassLoader.protected void
load
(ClassLoader classLoader, String filename) Load the contents of a properties file.static void
static void
static Boolean
setGlobalProperty
(String key, boolean value) Set boolean value in all instances of AppConstants, current and future.static String
setGlobalProperty
(String key, String value) Set value in all instances of AppConstants, current and future.setProperty
(String key, boolean value) Set key as boolean.setProperty
(String key, String value) Use this method for testing only, when only local properties need to be set that do not affect other tests.Methods inherited from class org.frankframework.util.PropertyLoader
containsKey, get, getBoolean, getDouble, getInt, getListProperty, getListProperty, getLong, getOrDefault, getProperty, getResolvedProperty, getString, getUnresolvedProperty, put
Methods inherited from class java.util.Properties
clear, clone, compute, computeIfAbsent, computeIfPresent, contains, containsValue, elements, entrySet, equals, forEach, getOrDefault, getProperty, hashCode, isEmpty, keys, keySet, list, list, load, load, loadFromXML, merge, propertyNames, putAll, putIfAbsent, rehash, remove, remove, replace, replace, replaceAll, save, size, store, store, storeToXML, storeToXML, storeToXML, stringPropertyNames, toString, values
-
Field Details
-
APPLICATION_SERVER_TYPE_PROPERTY
- See Also:
-
APPLICATION_SERVER_CUSTOMIZATION_PROPERTY
- See Also:
-
ADDITIONAL_PROPERTIES_FILE_SUFFIX_KEY
- See Also:
-
-
Method Details
-
getInstance
Return the AppConstants root instance- Returns:
- AppConstants instance
-
getInstance
Retrieve an instance based on a ClassLoader. This should be used by classes which are part of the Ibis configuration (like pipes and senders) because the configuration might be loaded from outside the webapp classpath. Hence, the Thread.currentThread().getContextClassLoader() at the time the class was instantiated should be used.- Parameters:
classLoader
- ClassLoader to retrieve AppConstants from- Returns:
- AppConstants instance
-
removeInstance
public static void removeInstance() -
removeInstance
-
getAppConstants
Returns a list ofAppConstants
which names begin with the keyBase -
getAppConstants
public Properties getAppConstants(String keyBase, boolean useSystemProperties, boolean useEnvironmentVariables) Returns a list ofAppConstants
which names begin with the keyBase -
setProperty
Use this method for testing only, when only local properties need to be set that do not affect other tests.- Overrides:
setProperty
in classProperties
- Parameters:
key
- the key to be placed into this property list.value
- the value corresponding tokey
.- Returns:
- Previous value, or null
-
setProperty
Set key as boolean. Use this method for testing only, when local properties need to be set that do not affect other tests.- Parameters:
key
- the key to be placed into this property list.value
- the value corresponding tokey
.- Returns:
- Previous value, or null
-
setGlobalProperty
Set boolean value in all instances of AppConstants, current and future. Use this in production-code to make sure a settings-change is propagated to all configurations.- Parameters:
key
- the key to be placed into this property list.value
- the value corresponding tokey
.- Returns:
- Previous value, or null
-
setGlobalProperty
Set value in all instances of AppConstants, current and future. Use this in production-code to make sure a settings-change is propagated to all configurations.- Parameters:
key
- the key to be placed into this property list.value
- the value corresponding tokey
.- Returns:
- Previous value, or null
-
clearGlobalProperty
Clear a property in all instances of AppConstants.- Parameters:
key
- the key to be removed- Returns:
- The value associated with the key, or null
-
load
Description copied from class:PropertyLoader
Load the contents of a properties file.Optionally, this may be a comma-separated list of files to load, e.g.
log4j2.properties,DeploymentSpecifics.properties
which will cause both files to be loaded in the listed order.- Overrides:
load
in classPropertyLoader
-