Package de.aristaflow.adept2.util
Class ConfigurationTools
java.lang.Object
de.aristaflow.adept2.util.ConfigurationTools
This class provides methods for converting values used in
Configurations from the
corresponding type to strings and back.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic final booleancheckConfigurationForNulls(Configuration conf, StringBuilder sb, String[] keys) Checks whether the given configuration contains every given key and if every property is set.static Triple<BigInteger,BigInteger, BigInteger> createKeyPair(int keySize) Creates a RSA key pair and returns the modulus, the public and the private exponent.static StringencryptPassword(String password) Encrypts the designated password string with the public key of the AristaFlow configuration framework and encodes the resulting string as Base64 (non-strict since it does not contain line breaks).static booleanencryptPassword(Configuration conf, String key, String password, Logger logger, PrintStream ps) Encrypts the designated password and stores it under the designated configuration key name in the designated configuration.static ListDelimiterHandlerGets the instance for the list delimiter handler separating via,.static StringGets the complete content of the designated configuration as appropriately formatted string.protected static DateTimeFormattergetDateOptTimeFormatter(DateTimeFormatter timeElementFormatter) Gets the formatter for a date with an optional time and an optional offset in a string.protected static DateTimeFormattergetDateTimeFormatter(DateTimeFormatter dateTimeFormatter) Gets the designated formatter initialised with default values for the temporal fields.Since the signature ofImmutableConfiguration.getList(String)changed, we could use this tool method to 'cast' the list of objects to a list of strings.getList(Configuration conf, String key) A convenience method forImmutableConfiguration.getList(String)that callsgetListon the designated configuration with the designated key and converts the result to a list of strings or an empty list.protected static DateTimeFormatterGets a formatter for a time string using,as decimal point for the fraction of a second.protected static DateTimeFormatterGets a formatter for a time string using.as decimal point for the fraction of a second.protected static DateTimeFormattergetTimeFormatter(DateTimeFormatter timeElementFormatter) Gets the formatter for a time with an optional offset in a string.static booleaninsertNewGsmKeyPair(Configuration conf, int keySize, String modConfKey, String pubConfKey, String privConfKey, Logger logger, PrintStream ps) Creates a new RSA key pair for the global security manager and stores it in the designated configuration using the appropriate configuration variables (modulus, public and private exponent).static CompositeConfigurationnewCompositeConfiguration(Configuration inMemoryConf) Creates a newCompositeConfigurationallowing to combine several configurations.static DatabaseConfigurationnewDatabaseConfiguration(DataSource dataSource, String tableName, String keyColumn, String valueColumn) Creates a newDatabaseConfigurationusing the designated table and columns to store the configuration in the designated data source.static MapConfigurationnewMapConfiguration(Map<String, String> values) Creates a newAbstractConfigurationcontaining the designated values (if provided).static MapConfigurationnewMapConfiguration(Map<String, String> values, boolean handleListDelimiters) Creates a newAbstractConfigurationcontaining the designated values (if provided).static PropertiesConfigurationCreates a new emptyPropertiesConfiguration.static PropertiesFileConfigurationCreates a newPropertiesFileConfigurationcontaining the contents of the designated file.static PropertiesFileConfigurationnewPropertiesConfiguration(File file, Logger autosaveLogger) Creates a newPropertiesFileConfigurationcontaining the contents of the designated file.static PropertiesConfigurationCreates a newPropertiesConfigurationcontaining the contents of the designated input stream.static PropertiesFileConfigurationCreates a newPropertiesFileConfigurationcontaining the contents of the designated file.static PropertiesFileConfigurationnewPropertiesConfiguration(String file, Logger autosaveLogger) Creates a newPropertiesFileConfigurationcontaining the contents of the designated file.static PropertiesFileConfigurationCreates a newPropertiesFileConfigurationcontaining the contents of the designated URL.static PropertiesFileConfigurationnewPropertiesConfiguration(URL url, InputStream is) Creates a newPropertiesFileConfigurationcontaining the contents of the designated input stream.static PropertiesFileConfigurationnewPropertiesConfiguration(URL url, Logger autosaveLogger) Creates a newPropertiesFileConfigurationcontaining the contents of the designated URL.static BooleanparseBoolean(String booleanValue) Parses the designated string and returns the corresponding boolean value.static String[]parseCSVString(String csvString, String separator) Splits the given CSV string around the designated separator and removes whitespace at the start and end of each resulting token.static DateParses the designated string and returns the corresponding date value ornullin case the value cannot be parsed or is not a valid date.static DoubleparseFloat(String floatValue) Parses the designated string and returns the corresponding float value ornullin case the value cannot be parsed or is not a valid float.static LongparseInteger(String integerValue) Parses the designated string and returns the corresponding integer value ornullin case the value cannot be parsed or is not a valid integer.static final StringparsePassword(String password) Parses the property's value in the designated configuration as a string, decodes and decrypts it and returns the resulting string.static final StringparsePassword(Configuration configuration, String propertyName) Parses the property's value in the designated configuration as a string, decodes and decrypts it and returns the resulting string.static final StringparsePasswordTolerant(String password) Parses the property's value in the designated configuration as a string, decodes and decrypts it and returns the resulting string.static final StringparsePasswordTolerant(Configuration configuration, String propertyName) Parses the property's value in the designated configuration as a string, decodes and decrypts it and returns the resulting string.static byte[]Parses the designated string and returns the corresponding UDT-value (as byte-array) ornullin case the value cannot be parsed or is not a valid byte[].static URIParses the designated string and returns the corresponding URI ornullin case the value cannot be parsed or is not a valid URI.static URIparseURI(Configuration configuration, String propertyName) Parses the property's value in the given configuration and returns it as aURI.static final booleanpropertyPresent(Configuration configuration, String key) Checks whether the value for the designated key in the designated configuration is not null and if it is a string, it is not the empty string.static final booleanpropertyValuePresent(Configuration configuration, String key) Checks whether the value for the designated key in the designated configuration is not null and not the empty string.static final booleanstringValid(String validString) Checks whether the designated string is not null and not the empty string.static StringtoString(boolean booleanValue) Converts the designated boolean value to a string for usage in configurations when manually editing these.static StringtoString(byte[] udtValue) Converts the designatedbyte[]to a string for usage in configurations when manually editing these.static StringtoString(double floatValue) Converts the designated float value to a string for usage in configurations when manually editing these.static StringtoString(long integerValue) Converts the designated integer value to a string for usage in configurations when manually editing these.static StringtoString(InputStream inputStream) Converts the designatedInputStreamto a string for usage in configurations when manually editing these.static StringConverts the designated URI to a string for usage in configurations when manually editing these.static StringConverts the designated date to a string for usage in configurations when manually editing these.
-
Constructor Details
-
ConfigurationTools
public ConfigurationTools()
-
-
Method Details
-
parseBoolean
Parses the designated string and returns the corresponding boolean value. UsetoString(boolean)to convert a boolean value to a string.- Parameters:
booleanValue- The string representation of a boolean value to be converted.- Returns:
- The boolean value of the designated string or
nullin case the string isnull.
-
toString
Converts the designated boolean value to a string for usage in configurations when manually editing these. When setting the value via theConfiguration-interface directly, the conversion will be handled internally.
UseparseBoolean(String)to convert a string back to a boolean.- Parameters:
booleanValue- The boolean value to be represented as a string.- Returns:
- The string representation of the designated boolean value.
-
parseInteger
Parses the designated string and returns the corresponding integer value ornullin case the value cannot be parsed or is not a valid integer. UsetoString(long)to convert an integer value to a string.- Parameters:
integerValue- The string representation of an integer value to be converted.- Returns:
- The integer value of the designated string or
nullin case the designated string cannot be parsed to a valid integer.
-
toString
Converts the designated integer value to a string for usage in configurations when manually editing these. When setting the value via theConfiguration-interface directly, the conversion will be handled internally.
UseparseInteger(String)to convert a string back to an integer.- Parameters:
integerValue- The integer value to be represented as a string.- Returns:
- The string representation of the designated integer value.
-
parseFloat
Parses the designated string and returns the corresponding float value ornullin case the value cannot be parsed or is not a valid float. UsetoString(double)to convert a float value to a string.- Parameters:
floatValue- The string representation of a float value to be converted.- Returns:
- The float value of the designated string or
nullin case the designated string cannot be parsed to a valid float.
-
toString
Converts the designated float value to a string for usage in configurations when manually editing these. When setting the value via theConfiguration-interface directly, the conversion will be handled internally.
UseparseFloat(String)to convert a string back to a float.- Parameters:
floatValue- The float value to be represented as a string.- Returns:
- The string representation of the designated float value.
-
parseURI
Parses the designated string and returns the corresponding URI ornullin case the value cannot be parsed or is not a valid URI. UsetoString(URI)to convert a URI to a string.- Parameters:
uriValue- The string representation of the URI to be converted.- Returns:
- The URI-value of the designated string or
nullin case the designated string cannot be parsed to a valid URI.
-
toString
Converts the designated URI to a string for usage in configurations when manually editing these. When setting the value via theConfiguration-interface directly, the conversion will be handled internally.
UseparseURI(String)to convert a string back to a URI.- Parameters:
uriValue- The URI to be represented as a string.- Returns:
- The string representation of the designated URI-value.
- Throws:
NullArgumentException- If the designated URI isnull, aNullArgumentExceptionwill be thrown.
-
parseDate
Parses the designated string and returns the corresponding date value ornullin case the value cannot be parsed or is not a valid date. UsetoString(Date)to convert a date value to a string.The following grammar is used for parsing:
datetime = date-opt-time | time date-opt-time = date-element ['T' [time-element] [offset]] date-element = yyyy ['-' MM ['-' dd]] time = 'T' time-element [offset] time-element = HH [':' mm [':' ss [fraction]]] fraction = ('.' | ',') digit+ offset = 'Z' | (('+' | '-') HH [':' mm [':' ss [('.' | ',') SSS]]])If the string representation does not contain a time zone or zone offset, UTC will be assumed.- Parameters:
dateValue- The string representation of a date value to be converted.- Returns:
- The date value of the designated string or
nullin case the designated string cannot be parsed to a valid date.
-
getDateTimeFormatter
Gets the designated formatter initialised with default values for the temporal fields.- Parameters:
dateTimeFormatter- The date time formatter missing default values for the temporal fields.- Returns:
- The designated formatter initialised with default values for the temporal fields.
-
getTimeFormatter
Gets the formatter for a time with an optional offset in a string.- Parameters:
timeElementFormatter- The formatter for the time element part.- Returns:
- The formatter for a time with an optional offset in a string.
-
getDateOptTimeFormatter
Gets the formatter for a date with an optional time and an optional offset in a string.- Parameters:
timeElementFormatter- The formatter for the time element part.- Returns:
- The formatter for a date with an optional time and an optional offset in a string.
-
getTimeElementFormatterDot
Gets a formatter for a time string using.as decimal point for the fraction of a second.- Returns:
- A formatter for a time string using
.as decimal point for the fraction of a second.
-
getTimeElementFormatterComma
Gets a formatter for a time string using,as decimal point for the fraction of a second.- Returns:
- A formatter for a time string using
,as decimal point for the fraction of a second.
-
toString
Converts the designated date to a string for usage in configurations when manually editing these. When setting the value via theConfiguration-interface directly, the conversion will be handled internally.
UseparseDate(String)to convert a string back to a date.- Parameters:
dateValue- The date to be represented as a string.- Returns:
- The string representation of the designated date.
- Throws:
NullArgumentException- If the designated date isnull, aNullArgumentExceptionwill be thrown.
-
parseUDT
Parses the designated string and returns the corresponding UDT-value (as byte-array) ornullin case the value cannot be parsed or is not a valid byte[]. UsetoString(byte[])to convert a byte-array to a string.- Parameters:
udtValue- The string representation of the UDT-value to be converted ornullif the designated string isnull.- Returns:
- The UTD-value of the designated string or
nullin case the designated string cannot be parsed to a valid UDT-value.
-
toString
Converts the designatedbyte[]to a string for usage in configurations when manually editing these. This encodes the value as basic Base64. It will also be gzipped until there is a problem. In such a case it will be converted without gzip.
When setting the value via theConfiguration-interface directly, the conversion will be handled internally.
UseparseUDT(String)to convert a string back to an UDT-value.- Parameters:
udtValue- The UDT-value to be represented as a string.- Returns:
- The string representation of the designated UDT-value.
- Throws:
NullArgumentException- If the designated UDT-value isnull, aNullArgumentExceptionwill be thrown.
-
toString
Converts the designatedInputStreamto a string for usage in configurations when manually editing these. This encodes the value as basic Base64. It will also be gzipped until there is a problem. In such a case it will be converted without gzip.
When setting the value via theConfiguration-interface directly, the conversion will be handled internally.
UseparseUDT(String)to convert a string back to an UDT-value.- Parameters:
inputStream- The input stream (of which the content is) to be to be represented as a string. The stream will be closed after reading.- Returns:
- The string representation (of the content) of the designated input stream.
- Throws:
NullArgumentException- If the designated input stream isnull, aNullArgumentExceptionwill be thrown.IOException- If there are problems creating the stream without gzip, anIOExceptionwill be thrown.
-
stringValid
Checks whether the designated string is not null and not the empty string. This method can be used for checking property values of configurations.- Parameters:
validString- The string to check.- Returns:
validString != null && validString.length() > 0
-
propertyValuePresent
Checks whether the value for the designated key in the designated configuration is not null and not the empty string. This method can be used for checking property values of configurations.- Parameters:
configuration- The configuration which contain a value for the designated key (or not).key- The key for which to check the value of the property.- Returns:
stringValid(configuration.getString(key))
-
propertyPresent
Checks whether the value for the designated key in the designated configuration is not null and if it is a string, it is not the empty string. This method can be used for checking property values of arbitrary type provided by configurations.- Parameters:
configuration- The configuration which contain a value for the designated key (or not).key- The key for which to check the value of the property.- Returns:
propertyValuePresent(configuration.getString(key))or a non-string is!= null.
-
checkConfigurationForNulls
public static final boolean checkConfigurationForNulls(Configuration conf, StringBuilder sb, String[] keys) Checks whether the given configuration contains every given key and if every property is set.- Parameters:
conf- The configuration that should be checked.sb- The string builder where the missing keys are appended, if notnull.keys- The configuration keys that should be checked.- Returns:
- Returns true if one of the given keys is missing or the value is not set, false otherwise.
-
parseCSVString
Splits the given CSV string around the designated separator and removes whitespace at the start and end of each resulting token. Returns an empty array if the string is not set or empty.- Parameters:
csvString- The string representing the multi-valued string.separator- The string which separates the values of the property.- Returns:
- The separated values of the property list.
-
parseURI
Parses the property's value in the given configuration and returns it as aURI. The property is expected to be set and of the correct type.- Parameters:
configuration- the configuration containing the property valuepropertyName- the name of property whose value should be parsed- Returns:
- The property's value as a
URIornullin case the property value could not be parsed as URI.
-
getConfigurationDump
Gets the complete content of the designated configuration as appropriately formatted string. This is useful for debugging.- Parameters:
conf- The configuration for which to get the complete content.- Returns:
- The content of the designated string formatted appropriately.
-
createKeyPair
public static Triple<BigInteger,BigInteger, createKeyPairBigInteger> (int keySize) throws NoSuchAlgorithmException, InvalidKeySpecException Creates a RSA key pair and returns the modulus, the public and the private exponent.- Parameters:
keySize- The size of the key to create.- Returns:
- The modulus, the public and the private exponent of a newly created RSA key pair.
- Throws:
NoSuchAlgorithmException- If no RSA algorithm can be found, aNoSuchAlgorithmExceptionwill be thrown.InvalidKeySpecException- If the key spec for the private RSA key cannot be found, anInvalidKeySpecExceptionwill be thrown.
-
insertNewGsmKeyPair
public static boolean insertNewGsmKeyPair(Configuration conf, int keySize, String modConfKey, String pubConfKey, String privConfKey, Logger logger, PrintStream ps) Creates a new RSA key pair for the global security manager and stores it in the designated configuration using the appropriate configuration variables (modulus, public and private exponent).
If the corresponding configuration variables already exist in the designated configuration file, they will be overwritten.- Parameters:
conf- The configuration in which to store the key pair attributes.keySize- The size of the RSA key.modConfKey- The name of the configuration key with which to store the modulus of the key pair.pubConfKey- The name of the configuration key with which to store the public exponent of the key pair.privConfKey- The name of the configuration key with which to store the private exponent of the key pair.logger- The logger to track the progress and problems. This may benull.ps- A print stream to track the progress and problems. This may benull.- Returns:
- Whether creating and inserting the key pair has been successful. If not, check the logger and/or the print stream for details.
-
encryptPassword
Encrypts the designated password string with the public key of the AristaFlow configuration framework and encodes the resulting string as Base64 (non-strict since it does not contain line breaks).- Parameters:
password- The password string to encrypt and encode.- Returns:
- A string representing the encrypted and (Base64-) encoded password.
- Throws:
GeneralSecurityException- If there are problems encrypting the password, aGeneralSecurityExceptionwill be thrown.
-
encryptPassword
public static boolean encryptPassword(Configuration conf, String key, String password, Logger logger, PrintStream ps) Encrypts the designated password and stores it under the designated configuration key name in the designated configuration. If no password is provided, it will be read from the configuration using the designated configuration key name.- Parameters:
conf- The configuration in which to store the password and from which to optionally read the password.key- The configuration key name under which to store the password and optionally with which to read the password.password- The password to be encrypted and stored in the designated configuration. If this isnull, the password will be read with the designated configuration key name from the designated configuration.logger- The logger to track the progress and problems. This may benull.ps- A print stream to track the progress and problems. This may benull.- Returns:
- Whether encrypting and storing the password has been successful. If not, check the logger and/or the print stream for details.
-
parsePassword
public static final String parsePassword(Configuration configuration, String propertyName) throws GeneralSecurityException Parses the property's value in the designated configuration as a string, decodes and decrypts it and returns the resulting string. This allows to use encrypted passwords in configuration files. The property is expected to be set and of the correct type. Returns an empty string if the password is empty.- Parameters:
configuration- The configuration containing the property valuepropertyName- The name of property of which the value should be parsed and decrypted.- Returns:
- The value of the property as decoded and decrypted
Stringor the empty string in case the password is empty. - Throws:
GeneralSecurityException- If there are problems decrypting the property value, aGeneralSecurityExceptionwill be thrown.
-
parsePassword
Parses the property's value in the designated configuration as a string, decodes and decrypts it and returns the resulting string. This allows to use encrypted passwords in configuration files. The property is expected to be set and of the correct type. Returns an empty string if the password is empty.- Parameters:
password- The encrypted password.- Returns:
- The value of the property as decoded and decrypted
Stringor the empty string in case the password is empty. - Throws:
GeneralSecurityException- If there are problems decrypting the property value, aGeneralSecurityExceptionwill be thrown.
-
parsePasswordTolerant
Parses the property's value in the designated configuration as a string, decodes and decrypts it and returns the resulting string. If the password cannot be decrypted, it will be assumed to be plain text and it will be returned.
The property is expected to be set and of the correct type. Returns an empty string if the password is empty.- Parameters:
configuration- The configuration containing the property valuepropertyName- The name of property of which the value should be parsed and decrypted or simply returned.- Returns:
- The value of the property as decoded and decrypted
Stringor the property value directly in case it cannot be decrypted.
-
parsePasswordTolerant
Parses the property's value in the designated configuration as a string, decodes and decrypts it and returns the resulting string. If the password cannot be decrypted, it will be assumed to be plain text and it will be returned.
This allows to use encrypted passwords in configuration files. The property is expected to be set and of the correct type. Returns an empty string if the password is empty.- Parameters:
password- The possibly encrypted password.- Returns:
- The designated value decoded and decrypted or directly without any changes.
-
getCommaHandler
Gets the instance for the list delimiter handler separating via,.- Returns:
- The instance for the list delimiter handler separating via
,.
-
getList
A convenience method forImmutableConfiguration.getList(String)that callsgetListon the designated configuration with the designated key and converts the result to a list of strings or an empty list.- Parameters:
conf- The configuration from which to retrieve the list.key- The configuration key.- Returns:
- A list of strings or an empty list if the configuration does not contain the key or the value is empty.
-
getList
Since the signature ofImmutableConfiguration.getList(String)changed, we could use this tool method to 'cast' the list of objects to a list of strings.- Parameters:
list- A list of objects.- Returns:
- A list of strings.
-
newMapConfiguration
Creates a newAbstractConfigurationcontaining the designated values (if provided).- Parameters:
values- The values to be in the base configuration ornullfor an empty configuration.- Returns:
- A new map configuration.
-
newMapConfiguration
public static MapConfiguration newMapConfiguration(Map<String, String> values, boolean handleListDelimiters) Creates a newAbstractConfigurationcontaining the designated values (if provided).- Parameters:
values- The values to be in the base configuration ornullfor an empty configuration.handleListDelimiters- Whether to handle list delimiters within strings.- Returns:
- A new map configuration.
-
newPropertiesConfiguration
Creates a new emptyPropertiesConfiguration.- Returns:
- A new empty properties configuration.
-
newPropertiesConfiguration
public static PropertiesConfiguration newPropertiesConfiguration(InputStream is) throws ConfigurationException Creates a newPropertiesConfigurationcontaining the contents of the designated input stream.- Parameters:
is- The input stream to read into the new properties configuration ornullfor an empty configuration.- Returns:
- A new properties configuration.
- Throws:
ConfigurationException- If creating the configuration or loading from the stream fails, aConfigurationExceptionwill be thrown.
-
newPropertiesConfiguration
public static PropertiesFileConfiguration newPropertiesConfiguration(URL url, InputStream is) throws ConfigurationException Creates a newPropertiesFileConfigurationcontaining the contents of the designated input stream.- Parameters:
url- The URL specifying the properties file. This is merely for information purpose. If you do not have an URL usenewPropertiesConfiguration(InputStream).is- The input stream to read the configuration from.- Returns:
- A new properties configuration.
- Throws:
ConfigurationException- If creating the configuration or loading from the stream fails, aConfigurationExceptionwill be thrown.
-
newPropertiesConfiguration
public static PropertiesFileConfiguration newPropertiesConfiguration(String file) throws ConfigurationException Creates a newPropertiesFileConfigurationcontaining the contents of the designated file.- Parameters:
file- The file to read into the new properties configuration ornullfor an empty configuration.- Returns:
- A new properties configuration.
- Throws:
ConfigurationException- If creating the configuration or loading the file fails, aConfigurationExceptionwill be thrown.
-
newPropertiesConfiguration
public static PropertiesFileConfiguration newPropertiesConfiguration(String file, Logger autosaveLogger) throws ConfigurationException Creates a newPropertiesFileConfigurationcontaining the contents of the designated file.- Parameters:
file- The file to read into the new properties configuration ornullfor an empty configuration.autosaveLogger- Whether to automatically save changes to the underlying file. If so, problems will be logged to this logger. Usenullto not automatically save changes.- Returns:
- A new properties configuration.
- Throws:
ConfigurationException- If creating the configuration or loading the file fails, aConfigurationExceptionwill be thrown.
-
newPropertiesConfiguration
public static PropertiesFileConfiguration newPropertiesConfiguration(File file) throws ConfigurationException Creates a newPropertiesFileConfigurationcontaining the contents of the designated file.- Parameters:
file- The file to read into the new properties configuration ornullfor an empty configuration.- Returns:
- A new properties configuration.
- Throws:
ConfigurationException- If creating the configuration or loading the file fails, aConfigurationExceptionwill be thrown.
-
newPropertiesConfiguration
public static PropertiesFileConfiguration newPropertiesConfiguration(File file, Logger autosaveLogger) throws ConfigurationException Creates a newPropertiesFileConfigurationcontaining the contents of the designated file.- Parameters:
file- The file to read into the new properties configuration ornullfor an empty configuration.autosaveLogger- Whether to automatically save changes to the underlying file. If so, problems will be logged to this logger. Usenullto not automatically save changes.- Returns:
- A new properties configuration.
- Throws:
ConfigurationException- If creating the configuration or loading the file fails, aConfigurationExceptionwill be thrown.
-
newPropertiesConfiguration
public static PropertiesFileConfiguration newPropertiesConfiguration(URL url) throws ConfigurationException Creates a newPropertiesFileConfigurationcontaining the contents of the designated URL.- Parameters:
url- The URL which to read into the new properties configuration ornullfor an empty configuration.- Returns:
- A new properties configuration.
- Throws:
ConfigurationException- If creating the configuration or loading from the URL fails, aConfigurationExceptionwill be thrown.
-
newPropertiesConfiguration
public static PropertiesFileConfiguration newPropertiesConfiguration(URL url, Logger autosaveLogger) throws ConfigurationException Creates a newPropertiesFileConfigurationcontaining the contents of the designated URL.- Parameters:
url- The URL which to read into the new properties configuration ornullfor an empty configuration.autosaveLogger- Whether to automatically save changes to the underlying file. If so, problems will be logged to this logger. Usenullto not automatically save changes.- Returns:
- A new properties configuration.
- Throws:
ConfigurationException- If creating the configuration or loading from the URL fails, aConfigurationExceptionwill be thrown.
-
newDatabaseConfiguration
public static DatabaseConfiguration newDatabaseConfiguration(DataSource dataSource, String tableName, String keyColumn, String valueColumn) throws ConfigurationException Creates a newDatabaseConfigurationusing the designated table and columns to store the configuration in the designated data source. This is a simple database configuration as provided by Commons Configuration, that is, the existence of the table is not handled. That is, the table will not be created and thus no configuration values will be stored. Also the existence of the table will not be checked before accessing it. This may lead to a lot of warnings in the DBMS log; every read or write access of a configuration entry without the corresponding table being present creates a log entry.
Therefore usage of this method is strongly discouraged. UseDatabaseConfiguration.newDatabaseConfiguration(Logger, de.aristaflow.adept2.base.dbaccess.JDBCDataSource, String, String, String)instead which creates the table if appropriate and checks for its existence before accessing it.- Parameters:
dataSource- The datasource which stores the configuration.tableName- The name of the table containing the configuration values.keyColumn- The name of the column containing the configuration keys.valueColumn- The name of the column containing the configuration values.- Returns:
- A new database configuration.
- Throws:
ConfigurationException- If creating the configuration fails, aConfigurationExceptionwill be thrown.- See Also:
-
newCompositeConfiguration
Creates a newCompositeConfigurationallowing to combine several configurations. If a configuration is provided, this will be the in memory configuration in which all changes of the returned composite configuration values will be stored.- Parameters:
inMemoryConf- The in memory configuration in which all changes of the returned composite configuration values will be stored. This may benull.- Returns:
- A new composite configuration.
-