public class ConfigurationServiceImpl extends java.lang.Object implements ConfigurationService
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
PASSWORD_CMD_LINE_ARGS
Specify names of command line arguments which are password, so that their
values will be masked when 'sun.java.command' is printed to the logs.
|
static java.lang.String |
PASSWORD_SYS_PROPS
Set this filed value to a regular expression which will be used to select
system properties keys whose values should be masked when printed out to
the logs.
|
PNAME_CONFIGURATION_FILE_IS_READ_ONLY, PNAME_CONFIGURATION_FILE_NAME, PNAME_SC_CACHE_DIR_LOCATION, PNAME_SC_HOME_DIR_LOCATION, PNAME_SC_HOME_DIR_NAME, PNAME_SC_LOG_DIR_LOCATION
Constructor and Description |
---|
ConfigurationServiceImpl() |
Modifier and Type | Method and Description |
---|---|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a
PropertyChangeListener to the listener list. |
void |
addPropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener listener)
Adds a PropertyChangeListener to the listener list for a specific
property.
|
void |
addVetoableChangeListener(ConfigVetoableChangeListener listener)
Adds a VetoableChangeListener to the listener list.
|
void |
addVetoableChangeListener(java.lang.String propertyName,
ConfigVetoableChangeListener listener)
Adds a VetoableChangeListener to the listener list for a specific
property.
|
java.util.List<java.lang.String> |
getAllPropertyNames()
Returns a
List of Strings containing all
property names. |
boolean |
getBoolean(java.lang.String propertyName,
boolean defaultValue)
Gets the value of a specific property as a boolean.
|
java.lang.String |
getConfigurationFilename()
Use with caution!
Returns the name of the configuration file currently
used.
|
double |
getDouble(java.lang.String propertyName,
double defaultValue)
Gets the value of a specific property as a double.
|
int |
getInt(java.lang.String propertyName,
int defaultValue)
Gets the value of a specific property as a signed decimal integer.
|
long |
getLong(java.lang.String propertyName,
long defaultValue)
Gets the value of a specific property as a signed decimal long integer.
|
java.lang.Object |
getProperty(java.lang.String propertyName)
Returns the value of the property with the specified name or null if no
such property exists.
|
java.util.List<java.lang.String> |
getPropertyNamesByPrefix(java.lang.String prefix,
boolean exactPrefixMatch)
Returns a
List of Strings containing all property names
that have the specified prefix. |
java.util.List<java.lang.String> |
getPropertyNamesBySuffix(java.lang.String suffix)
Returns a List of Strings containing the property names
that have the specified suffix.
|
java.lang.String |
getScHomeDirLocation()
Returns the location of the directory where Jitsi is to store
user specific data such as configuration files, message and call history
as well as is bundle repository.
|
java.lang.String |
getScHomeDirName()
Returns the name of the directory where Jitsi is to store user
specific data such as configuration files, message and call history
as well as is bundle repository.
|
java.lang.String |
getString(java.lang.String propertyName)
Returns the String value of the specified property (minus all
encompassing whitespaces) and null in case no property value was mapped
against the specified propertyName, or in case the returned property
string had zero length or contained whitespaces only.
|
java.lang.String |
getString(java.lang.String propertyName,
java.lang.String defaultValue)
Returns the String value of the specified property and null in case no
property value was mapped against the specified propertyName, or in
case the returned property string had zero length or contained
whitespaces only.
|
void |
logConfigurationProperties(java.lang.String excludePattern)
Prints all configuration properties on 'INFO' logging level *except*
that properties which name matches given regular expression will have
their values masked with ***.
|
void |
purgeStoredConfiguration()
Deletes the configuration file currently used by this implementation.
|
void |
reloadConfiguration()
Deletes the current configuration and reloads it from the configuration
file.
|
void |
removeProperty(java.lang.String propertyName)
Removes the property with the specified name.
|
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes a
PropertyChangeListener from the listener list. |
void |
removePropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener listener)
Removes a PropertyChangeListener from the listener list for a specific
property.
|
void |
removeVetoableChangeListener(ConfigVetoableChangeListener listener)
Removes a VetoableChangeListener from the listener list.
|
void |
removeVetoableChangeListener(java.lang.String propertyName,
ConfigVetoableChangeListener listener)
Removes a VetoableChangeListener from the listener list for a specific
property.
|
void |
setProperties(java.util.Map<java.lang.String,java.lang.Object> properties)
Sets a set of specific properties to specific values as a batch operation
meaning that first
VetoableChangeListener s are asked to
approve the modifications of the specified properties to the specified
values, then the modifications are performed if no complaints have been
raised in the form of PropertyVetoException and finally
PropertyChangeListener s are notified about the changes of
each of the specified properties. |
void |
setProperty(java.lang.String propertyName,
java.lang.Object property)
Sets the property with the specified name to the specified value.
|
void |
setProperty(java.lang.String propertyName,
java.lang.Object property,
boolean isSystem)
Sets the property with the specified name to the specified value.
|
void |
storeConfiguration()
Store the current set of properties back to the configuration file.
|
public static java.lang.String PASSWORD_CMD_LINE_ARGS
public static java.lang.String PASSWORD_SYS_PROPS
public void setProperty(java.lang.String propertyName, java.lang.Object property) throws ConfigPropertyVetoException
setProperty
in interface ConfigurationService
propertyName
- the name of the property to change.property
- the new value of the specified property.ConfigPropertyVetoException
- in case the changed has been refused
by at least one propertychange listener.public void setProperty(java.lang.String propertyName, java.lang.Object property, boolean isSystem) throws ConfigPropertyVetoException
setProperty
in interface ConfigurationService
propertyName
- the name of the property to change.property
- the new value of the specified property.isSystem
- specifies whether or not the property being set is a
System property and should be resolved against the system property set.ConfigPropertyVetoException
- in case the changed has been refused by
at least one propertychange listener.public void setProperties(java.util.Map<java.lang.String,java.lang.Object> properties) throws ConfigPropertyVetoException
VetoableChangeListener
s are asked to
approve the modifications of the specified properties to the specified
values, then the modifications are performed if no complaints have been
raised in the form of PropertyVetoException
and finally
PropertyChangeListener
s are notified about the changes of
each of the specified properties. The batch operations allows the
ConfigurationService
implementations to optimize, for
example, the saving of the configuration which in this case can be
performed only once for the setting of multiple properties.setProperties
in interface ConfigurationService
properties
- a Map
of property names to their new values to
be set.ConfigPropertyVetoException
- if a change in at least one of the
properties has been refused by at least one of the VetoableChangeListener
s.public void removeProperty(java.lang.String propertyName)
removeProperty
in interface ConfigurationService
propertyName
- the name of the property to change.public java.lang.Object getProperty(java.lang.String propertyName)
getProperty
in interface ConfigurationService
propertyName
- the name of the property that is being queried.public java.util.List<java.lang.String> getAllPropertyNames()
List
of Strings containing all
property names.getAllPropertyNames
in interface ConfigurationService
List
containing all property names.public java.util.List<java.lang.String> getPropertyNamesByPrefix(java.lang.String prefix, boolean exactPrefixMatch)
List
of Strings containing all property names
that have the specified prefix. The return value will include property
names that have prefixes longer than specified, unless the
exactPrefixMatch parameter is true.
Example:
Imagine a configuration service instance containing 2 properties only:
net.java.sip.communicator.PROP1=value1
net.java.sip.communicator.service.protocol.PROP1=value2
A call to this method with a prefix="net.java.sip.communicator" and exactPrefixMatch=true would only return the first property - net.java.sip.communicator.PROP1, whereas the same call with exactPrefixMatch=false would return both properties as the second prefix includes the requested prefix string.
getPropertyNamesByPrefix
in interface ConfigurationService
prefix
- a String containing the prefix (the non dotted non-caps
part of a property name) that we're looking for.exactPrefixMatch
- a boolean indicating whether the returned
property names should all have a prefix that is an exact match of the
the prefix param or whether properties with prefixes that
contain it but are longer than it are also accepted.public java.util.List<java.lang.String> getPropertyNamesBySuffix(java.lang.String suffix)
For example, imagine a configuration service instance containing two properties only:
net.java.sip.communicator.PROP1=value1
net.java.sip.communicator.service.protocol.PROP1=value2
A call to this method with suffix equal to "PROP1" will return both properties, whereas the call with suffix equal to "communicator.PROP1" or "PROP2" will return an empty List. Thus, if the suffix argument contains a dot, nothing will be found.
getPropertyNamesBySuffix
in interface ConfigurationService
suffix
- the suffix for the property names to be returnedpublic void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
PropertyChangeListener
to the listener list. The listener
is registered for all properties in the current configuration.
addPropertyChangeListener
in interface ConfigurationService
listener
- the PropertyChangeListener
to be addedpublic void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
PropertyChangeListener
from the listener list.
removePropertyChangeListener
in interface ConfigurationService
listener
- the PropertyChangeListener
to be removedpublic void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
addPropertyChangeListener
in interface ConfigurationService
propertyName
- one of the property names listed abovelistener
- the PropertyChangeListener to be addedpublic void removePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
removePropertyChangeListener
in interface ConfigurationService
propertyName
- a valid property namelistener
- the PropertyChangeListener to be removedpublic void addVetoableChangeListener(ConfigVetoableChangeListener listener)
addVetoableChangeListener
in interface ConfigurationService
listener
- the VetoableChangeListener to be addedpublic void removeVetoableChangeListener(ConfigVetoableChangeListener listener)
removeVetoableChangeListener
in interface ConfigurationService
listener
- the VetoableChangeListener to be removedpublic void addVetoableChangeListener(java.lang.String propertyName, ConfigVetoableChangeListener listener)
addVetoableChangeListener
in interface ConfigurationService
propertyName
- one of the property names listed abovelistener
- the VetoableChangeListener to be addedpublic void removeVetoableChangeListener(java.lang.String propertyName, ConfigVetoableChangeListener listener)
removeVetoableChangeListener
in interface ConfigurationService
propertyName
- a valid property namelistener
- the VetoableChangeListener to be removedpublic void reloadConfiguration() throws java.io.IOException
In the last case the file is copied to the sip-communicator configuration directory right after being extracted from the classpath location.
reloadConfiguration
in interface ConfigurationService
java.io.IOException
- in case reading the configuration fails.public void storeConfiguration() throws java.io.IOException
In the last case the file is copied to the sip-communicator configuration directory right after being extracted from the classpath location.
storeConfiguration
in interface ConfigurationService
java.io.IOException
- in case storing the configuration failed.public java.lang.String getConfigurationFilename()
ConfigurationService.getScHomeDirLocation()
ConfigurationService.getScHomeDirName()
getConfigurationFilename
in interface ConfigurationService
public java.lang.String getScHomeDirLocation()
getScHomeDirLocation
in interface ConfigurationService
public java.lang.String getScHomeDirName()
getScHomeDirName
in interface ConfigurationService
public java.lang.String getString(java.lang.String propertyName)
getString
in interface ConfigurationService
propertyName
- the name of the property that is being queried.public java.lang.String getString(java.lang.String propertyName, java.lang.String defaultValue)
getString
in interface ConfigurationService
propertyName
- the name of the property that is being queried.defaultValue
- the value to be returned if the specified property
name is not associated with a value in this
ConfigurationService
defaultValue
in case there was no value mapped against
the specified propertyName, or the returned string had zero
length or contained whitespaces only.public boolean getBoolean(java.lang.String propertyName, boolean defaultValue)
ConfigurationService
, the string representation of the value
is parsed into a boolean according to the rules of
Boolean.parseBoolean(String)
. Otherwise,
defaultValue
is returned.getBoolean
in interface ConfigurationService
propertyName
- the name of the property to get the value of as a booleandefaultValue
- the value to be returned if the specified property name is not
associated with a value in this
ConfigurationService
ConfigurationService
as a boolean;
defaultValue
if the property with the specified name
is not associated with a value in this
ConfigurationService
public int getInt(java.lang.String propertyName, int defaultValue)
Integer.parseInt(String)
. If parsing the value as a signed
decimal integer fails or there is no value associated with the specified
property name, defaultValue is returned.getInt
in interface ConfigurationService
propertyName
- the name of the property to get the value of as a
signed decimal integerdefaultValue
- the value to be returned if parsing the value of the
specified property name as a signed decimal integer fails or there is no
value associated with the specified property name in this
ConfigurationServicepublic double getDouble(java.lang.String propertyName, double defaultValue)
Double.parseDouble(String)
. If there is no value, or parsing of the
value fails, defaultValue is returned.getDouble
in interface ConfigurationService
propertyName
- the name of the property.defaultValue
- the default value to be returned.public long getLong(java.lang.String propertyName, long defaultValue)
Long.parseLong(String)
. If parsing the value as a signed
decimal long integer fails or there is no value associated with the
specified property name, defaultValue is returned.getLong
in interface ConfigurationService
propertyName
- the name of the property to get the value of as a
signed decimal long integerdefaultValue
- the value to be returned if parsing the value of the
specified property name as a signed decimal long integer fails or there
is no value associated with the specified property name in this
ConfigurationServicepublic void purgeStoredConfiguration()
purgeStoredConfiguration
in interface ConfigurationService
public void logConfigurationProperties(java.lang.String excludePattern)
logConfigurationProperties
in interface ConfigurationService
excludePattern
- regular expression which detects properties which
values should be masked.
Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under Apache license.