Package com.groiss.component
Class Configuration
java.lang.Object
com.groiss.component.Configuration
- All Implemented Interfaces:
Cloneable
This class handles the access to the configuration. There are two types of configurations:
the configuration of @enterprise and the configuration of the applications. On startup
@enterprise reads the configuration files and keeps the contents in memory. For access to the
system configuration use Configuration.get(). For accessing the configuration of an application
use Configuration.get("appl-id").
A configuration object contains the map between parameter names and values.
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
void
addPropertiesChangeListener
(PropertiesChangeListener l, String... props) boolean
allowOnClient
(String param) Returns true if this property may be send to the smartclient via ep/configstatic Object
convertType
(Class<?> type, String key, String value) converts the string value to the specified data-typestatic Configuration
Add a configuration to the internal map of configurations.static String
Deprecated.static Configuration
get()
Return the @enterprise configuration.static Configuration
Get the configuration by the given id.boolean
getBoolean
(String name) Return the property value as boolean.Class<?>
Return the property value as class.returns all property names which are allowed to be used on the html-clientstatic Map<String,
Configuration> Return the whole map of configurations.getDefaultValue
(String propname) Return the definition of a configuration.Return the property value as Double.getDuration
(String name) Return the property value asDuration
.return the file of the property, if the property is not yet in a file we return the last file - this is the one where it will be stored.Return the file name the configuration is loaded from.getFiles()
static long
getFileTime
(File file) Return the property value as Float.getId()
Return the id of this configuration.Return the property value as Integer.Return the label of the given property.Return the parameter as list.Return the property value as Long.Return the property value.getPasswordProperty
(String name) Get the value of a "mangled" property.Return the whole parameter map.getPropertiesStartingWith
(String prefix) Returns the subset of properties with names that start with a given prefix.getProperty
(String name) Returns the value of the property with the given name.getProperty
(String name, String defValue) Deprecated.define default values in the xml decsription of the configuration.Returns the value of the (multi-valued) property with the given name in the form of a property.Return the resource for this configuration.Class<?>
Return the type of the given property.boolean
isAmendedProperty
(String name) boolean
isPasswordProperty
(String name) boolean
load()
Load or reload the configuration.void
static void
loadTopLevel
(String fileNames) Load the main configuration.static String
Deprecated.boolean
needsRestart
(String param) Returns true if the property change needs a server restart to become effective.boolean
reload()
Reload the configuration from the configured files.static Configuration
Remove a configuration.static String
saveConvert
(String theString, boolean escapeSpace) void
setFileName
(String filename) Set the file name for the configuration.protected void
setProperties
(Properties props) void
setProperty
(String name, Object value) Set a property to a value.void
setProperty
(String name, String value) Set a property to a value.void
setPropFile
(String url) Set the url for the description file for the configuration.void
setResource
(Resource res) Set a resource for internationalization of this configuration.void
Deprecated.since @ep9.0void
setVisibility
(String paramGroupId, boolean visible) Set the visibility of a parameter group in the configurationvoid
store()
static String
valToString
(Object value) Convert a value from the configuration to a string.
-
Field Details
-
CONFIG_SCHEMA
- See Also:
-
OBFUSCATED_PREFIX
- See Also:
-
-
Method Details
-
getChangedAt
-
isAmendedProperty
-
create
Add a configuration to the internal map of configurations. This is called on startup for the system configuration and the application configurations.- Parameters:
id
- the id of the application- Returns:
- a new Configuration object
-
get
Get the configuration by the given id.- Parameters:
id
- the id of the configuration, normally the id of an application.- Returns:
- a Configuration object
-
getConfigurations
Return the whole map of configurations.- Returns:
- a map
-
get
Return the @enterprise configuration.- Returns:
- the configuration object.
-
remove
Remove a configuration. The "avw" configuration cannot be removed. Intended to be used solely internally.- Parameters:
id
- the id of the configuration to be removed- Returns:
- the removed configuration or null if it could not be found
-
setResource
Set a resource for internationalization of this configuration. The resource of the application configuration objects is set to the application resource on startup.- Parameters:
res
- a resource object
-
getResource
Return the resource for this configuration.- Returns:
- a resource or null if none is set.
-
restartList
-
setVisibility
Set the visibility of a parameter group in the configuration- Parameters:
paramGroupId
- the id of the groupvisible
- the new visibility
-
getDefinition
Return the definition of a configuration.- Returns:
- the root node of the definition as JDOM Element
-
setPropFile
Set the url for the description file for the configuration.- Parameters:
url
-
-
addParameterGroup
- Parameters:
s
-
-
addPropertiesChangeListener
-
needsRestart
Returns true if the property change needs a server restart to become effective.- Parameters:
param
- name of the property- Returns:
- true if restart is necessary
-
allowOnClient
Returns true if this property may be send to the smartclient via ep/config- Parameters:
param
- name of the property- Returns:
- true if restart is necessary
-
load
Load or reload the configuration.- Returns:
- true if file was found
- Throws:
IOException
-
getAmendedProperties
-
getFileTime
- Throws:
IOException
-
reload
Reload the configuration from the configured files.- Throws:
IOException
-
convertType
converts the string value to the specified data-type- Parameters:
type
- target-typekey
- property-idvalue
- property-value- Returns:
-
loadDefinition
public void loadDefinition() -
loadTopLevel
Load the main configuration.- Throws:
IOException
-
setSystemProps
Deprecated.since @ep9.0Copy all properties of this configuration into the system properties. -
getFileName
Return the file name the configuration is loaded from.- Returns:
- a path name
-
getFiles
-
setFileName
Set the file name for the configuration. The file name is used when the configuration is stored.- Parameters:
filename
-
-
getId
Return the id of this configuration.- Returns:
- a string
-
getPropertiesStartingWith
Returns the subset of properties with names that start with a given prefix.- Parameters:
prefix
- the prefix to search for- Returns:
- the matching properties
-
getPropertyAsProperties
Returns the value of the (multi-valued) property with the given name in the form of a property. If there is no property with this name the method returns null.- Parameters:
name
- name of a property- Returns:
- the value of the specified property as Property Object or null if the configuration entry is either not found or empty.
-
getProperty
Returns the value of the property with the given name. If there is no property with this name the method returns null. If the property value is not of type string the method toString() is called on it.- Parameters:
name
- name of a property- Returns:
- the value
-
getProperty
Deprecated.define default values in the xml decsription of the configuration.Returns the value of the specified configuration key or thedefValue
, if the configuration entry is not found.- Parameters:
name
- the configuration entry keydefValue
- the default value- Returns:
- the value of the specified configuration key or the
defValue
, if the configuration entry is not found.
-
getBoolean
Return the property value as boolean.- Parameters:
name
- the name of the property- Returns:
- the value casted to boolean, if value is not present, false is returned.
-
getInt
Return the property value as Integer. If the property is of type Duration, this method returns the time in seconds.- Parameters:
name
- the name of the property- Returns:
- the value casted to Integer
-
getLong
Return the property value as Long. If the property is of type Duration, this method returns the time in seconds.- Parameters:
name
- the name of the property- Returns:
- the value casted to Long
-
getFloat
Return the property value as Float.- Parameters:
name
- the name of the property- Returns:
- the value casted to Float
-
getDouble
Return the property value as Double.- Parameters:
name
- the name of the property- Returns:
- the value casted to Double
-
getClass
Return the property value as class.- Parameters:
name
- the name of the property- Returns:
- the value casted to Class
-
getDate
-
getDuration
Return the property value asDuration
.- Parameters:
name
- the name of the property- Returns:
- the value parsed to
Duration
-
getObject
Return the property value.- Parameters:
name
- the name of the property- Returns:
- the value without any conversion
-
getList
Return the parameter as list. Parameter type must be string, separators are space, tab, newline, comma.- Parameters:
name
- the name of the property
-
setProperty
Set a property to a value.- Parameters:
name
- the name of the propertyvalue
- the value string
-
setProperty
Set a property to a value.- Parameters:
name
- the name of the propertyvalue
- the value object
-
isPasswordProperty
-
getPasswordProperty
Get the value of a "mangled" property.- Parameters:
name
-- Returns:
- the plain value
-
getType
Return the type of the given property.- Parameters:
name
- the name of the property- Returns:
- the type
-
getLabel
Return the label of the given property.- Parameters:
name
- the name of the property- Returns:
- the label
-
getFile
return the file of the property, if the property is not yet in a file we return the last file - this is the one where it will be stored.- Parameters:
propname
-
-
getDefaultValue
-
setProperties
-
store
public void store() -
valToString
Convert a value from the configuration to a string. The method converts null to the empty string, returns the classname for classes and calls toString() to all other values. Moreover it calls trim() on the result.- Parameters:
value
- an object- Returns:
- a string representation of a configuration value
-
mansch
Deprecated.This method makes a string unreadable. Is is used to store passwords in a configuration file. It is not an encryption but is much better than storing the value unchanged. -
demansch
Deprecated.Inverse function to mansch. -
getProperties
Return the whole parameter map.- Returns:
- a Properties object
-
saveConvert
-
getClientParams
returns all property names which are allowed to be used on the html-client- Returns:
-