public class PropertyManager extends java.lang.Object implements ReplicaMessageListener
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
REVISION |
Modifier and Type | Method and Description |
---|---|
void |
addPropertiesListener(JPropertiesListener listener)
Adds a properties listener.
|
boolean |
containsProperty(java.lang.String name)
Tests if this JProperties contains the given property key/name.
|
boolean |
getBooleanProperty(java.lang.String name,
boolean defaultValue)
Gets the value of a property as a boolean given its key/name.
|
JProperties |
getChannelProperties()
Returns the internal properties used by channel.
|
java.lang.String |
getCustomPropFilePath()
Returns the file path of the custom.prop file.
|
double |
getDoubleProperty(java.lang.String name,
double defaultValue)
Gets the value of a property as a double value given its key/name.
|
float |
getFloatProperty(java.lang.String name,
float defaultValue)
Gets the value of a property as a float value given its key/name.
|
static PropertyManager |
getInstance() |
int[] |
getIntArrayProperty(java.lang.String name,
int[] defaultValue)
Gets the value of a property as a int array.
|
int |
getIntegerProperty(java.lang.String name,
int defaultValue)
Gets the value of a property as an int value given its key/name.
|
java.util.List<java.lang.String> |
getJcmsLanguageList()
Retrieves all the languages in which JCMS is localized.
|
java.util.List<java.lang.String> |
getLanguageList()
Retrieve all the languages of this channel with the main
language as the first one of the list.
|
java.util.List<java.lang.String> |
getLanguageListOrdered()
Retrieve all the languages of this channel in the
exact ordered in which they were specified in the properties.
|
LangProperties |
getLanguageProperties()
Gets the internal language properties used by channel.
As of version 5.5 those properties are the same as getChannelProperties() but may differ in a future revision. |
java.util.List<java.lang.String> |
getLocalizedLanguageList()
Retrieves all the languages specified in the properties in which JCMS is localized.
|
long |
getLongProperty(java.lang.String name,
long defaultValue)
Gets the value of a property as a long value given its key/name.
|
java.util.List<java.lang.String> |
getOtherLanguageList()
Retrieve all the languages of this channel excepted the main language.
|
LangProperties |
getProperties(java.lang.String prefix)
Gets a new LangProperties instance containg all the properties whose name
starts with the given prefix.
|
java.lang.String |
getProperty(java.lang.String name)
Gets value of a property.
|
java.lang.String |
getProperty(java.lang.String name,
java.lang.String defaultValue)
Gets the value of a property given its key/name.
|
java.util.Map<java.lang.String,java.lang.String> |
getSortedProperties(java.lang.String prefix)
Returns a Map containing all the properties whose name
starts with the given prefix sorted by key.
|
java.util.Map<java.lang.String,java.lang.String> |
getSortedProperties(java.lang.String prefix,
boolean trim)
Returns a Map containing all the properties whose name
starts with the given prefix sorted by key.
|
java.lang.String[] |
getStringArrayProperty(java.lang.String name,
java.lang.String[] defaultValue)
Gets the value of a property as a String array.
|
java.util.Map<java.lang.String,java.lang.Object> |
getSubProperties(java.lang.String prefix) |
void |
initReplicaMessageListener() |
void |
loadProperties() |
void |
prepare(Channel channel,
java.lang.String customPropFilePath,
java.lang.String webappPropFilePath) |
void |
processMessage(ReplicaMessage msg)
Process the given ReplicaMessage.
|
void |
reloadLanguageProperties()
Reload languages properties of JCMS (WEB-INF/jalios/languages/{lang}.prop)
and its plugin.
|
void |
reloadLanguageProperties(LangProperties properties)
Reload languages properties of JCMS (WEB-INF/jalios/languages/{lang}.prop)
in the specified LangProperties instance
|
void |
reloadProperties()
Reload all properties and notify all JPropertiesListener.
|
void |
removePropertiesListener(JPropertiesListener listener)
Removes a properties listener.
|
void |
resetLanguageList() |
void |
setProperty(java.lang.String name,
java.lang.String value)
Modify an internal property with the given value.
Do not change any JCMS property at runtime, behaviour of JCMS maybe incorrect if you do so, use the user interface for such task. |
void |
updateAndSaveProperties(JProperties prop)
Updates and save specified properties.
|
void |
updateAndSaveProperties(JProperties prop,
boolean notifyListener)
Updates and saves specified properties.
|
void |
updateAndSaveProperties(JProperties props,
boolean notifyListener,
boolean sync)
Updates and saves specified properties.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
init
public static final java.lang.String REVISION
public static PropertyManager getInstance()
public void prepare(Channel channel, java.lang.String customPropFilePath, java.lang.String webappPropFilePath)
public void reloadLanguageProperties() throws java.io.IOException
java.io.IOException
- If an error occurspublic void reloadLanguageProperties(LangProperties properties) throws java.io.IOException
properties
- the LangProperties instance in which language properties are to be loadedjava.io.IOException
- If an error occurspublic void reloadProperties()
public void loadProperties() throws java.io.IOException
java.io.IOException
public java.lang.String getCustomPropFilePath()
public void updateAndSaveProperties(JProperties prop)
prop
- the properties to be updated/saved.JProperties.updateAndSave(java.io.File)
public void updateAndSaveProperties(JProperties prop, boolean notifyListener)
prop
- the properties to be updated/saved.notifyListener
- if true notify the JPropertyListenersJProperties.updateAndSave(java.io.File)
public void updateAndSaveProperties(JProperties props, boolean notifyListener, boolean sync)
props
- the properties to be updated/saved.notifyListener
- if true notify the JPropertyListenerssync
- if true sync this properties with the other replicasJProperties.updateAndSave(java.io.File)
public boolean containsProperty(java.lang.String name)
name
- the key/name of the property to checkJProperties.containsProperty(java.lang.String)
public java.lang.String getProperty(java.lang.String name)
name
- the key/name of the property to retrieveJProperties.getProperty(java.lang.String)
public java.lang.String getProperty(java.lang.String name, java.lang.String defaultValue)
name
- the key/name of the property to retrievedefaultValue
- the default value to use if the existing value is null.JProperties.getProperty(java.lang.String, java.lang.String)
public boolean getBooleanProperty(java.lang.String name, boolean defaultValue)
name
- the key/name of the property to retrievedefaultValue
- the default value to use if the existing value
is null or is neither "false" nor "true" (case sensitive).JProperties.getBooleanProperty(java.lang.String, boolean)
public int getIntegerProperty(java.lang.String name, int defaultValue)
name
- the key/name of the property to retrievedefaultValue
- the default value to use if the existing value
is null or if Integer.parseInt() throws exception during String
to int conversion.JProperties.getIntegerProperty(java.lang.String, int)
public long getLongProperty(java.lang.String name, long defaultValue)
name
- the key/name of the property to retrievedefaultValue
- the default value to use if the existing value
is null or if Long.parseLong() throws exception during String
to long conversion.JProperties.getLongProperty(java.lang.String, long)
public float getFloatProperty(java.lang.String name, float defaultValue)
name
- the key/name of the property to retrievedefaultValue
- the default value to use if the existing value
is null or if Float.parseFloat() throws exception during String
to float conversion.JProperties.getFloatProperty(java.lang.String, float)
public double getDoubleProperty(java.lang.String name, double defaultValue)
name
- the key/name of the property to retrievedefaultValue
- the default value to use if the existing value
is null or if Double.parseDouble() throws exception during String
to double conversion.JProperties.getDoubleProperty(java.lang.String, double)
public java.lang.String[] getStringArrayProperty(java.lang.String name, java.lang.String[] defaultValue)
The property value must be in one of the following forms:
{delim}
is one character delimiter of your choice.{delim}
is a character from \t\n\r\f
.String[] array = prop.getStringArrayProperty("missingexample", new String[] { "default", "value"}); assertEquals(2, array.length); assertEquals("default", array[0]); assertEquals("value", array[1]); prop.setProperty("example1", "@|abc|def"); String[] array1 = prop.getStringArrayProperty("example1", new String[] { }); assertEquals(2, array1.length); assertEquals("abc", array1[0]); assertEquals("def", array1[1]); prop.setProperty("example2", "foo bar\tzig"); String[] array2 = prop.getStringArrayProperty("example2", new String[] { }); assertEquals(3, array2.length); assertEquals("foo", array2[0]); assertEquals("bar", array2[1]); assertEquals("zig", array2[2]);
name
- the key/name of the property to retrievedefaultValue
- the default value to use if the existing value
is null or no values could be found in the conversion.JProperties.getStringArrayProperty(java.lang.String,java.lang.String[])
public int[] getIntArrayProperty(java.lang.String name, int[] defaultValue)
getStringArrayProperty(String, String[])
.name
- the key/name of the property to retrievedefaultValue
- the default value to use if the existing value
is null or no values could be found in the conversion.JProperties.getIntArrayProperty(java.lang.String,int[])
public JProperties getChannelProperties()
getLanguageProperties()
but may differ in a future revision.
Do not change any JCMS property at runtime, behaviour of JCMS maybe
incorrect if you do so, use the user interface for such task.
However you can modify any of your own properties.public LangProperties getLanguageProperties()
getChannelProperties()
but may differ in a future revision.
Do not change any JCMS property at runtime, behaviour of JCMS maybe
incorrect if you do so, use the user interface for such task.
However you can modify any of your own properties.public LangProperties getProperties(java.lang.String prefix)
prefix
- the prefixLangProperties.getProperties(java.lang.String)
public java.util.Map<java.lang.String,java.lang.String> getSortedProperties(java.lang.String prefix)
prefix
- the prefixLangProperties.getProperties(java.lang.String)
public java.util.Map<java.lang.String,java.lang.String> getSortedProperties(java.lang.String prefix, boolean trim)
prefix
- the prefixtrim
- boolean true to remove prefix from keygetSortedProperties(java.lang.String)
public java.util.Map<java.lang.String,java.lang.Object> getSubProperties(java.lang.String prefix)
prefix
- the prefixJProperties.getSubProperties(java.lang.String)
public void setProperty(java.lang.String name, java.lang.String value)
name
- the name/key of the property to changevalue
- the new value of this propertJProperties.setProperty(String, String)
public void addPropertiesListener(JPropertiesListener listener)
listener
- the properties listenerpublic void removePropertiesListener(JPropertiesListener listener)
listener
- the properties listenerpublic java.util.List<java.lang.String> getLanguageList()
public java.util.List<java.lang.String> getLanguageListOrdered()
public java.util.List<java.lang.String> getOtherLanguageList()
public java.util.List<java.lang.String> getLocalizedLanguageList()
public java.util.List<java.lang.String> getJcmsLanguageList()
public void resetLanguageList()
public void initReplicaMessageListener()
public void processMessage(ReplicaMessage msg)
ReplicaMessageListener
processMessage
in interface ReplicaMessageListener
msg
- the ReplicaMessage to processCopyright © 2001-2021 Jalios SA. All Rights Reserved.