Property Manager
Since Kernel 2.0.5, there is a
registry for global configuration. It is actually a facade in front of system properties and has been added for several reasons:
- It manages a cache of the system properties, indeed system properties are expensive to retrieve as it involves security check and a synchronized map.
- In future versions it could be extended to take configuration from some other place.
- In future versions it will contain privileged code block in order to make exo products executable under a java security manager.
The API is quite simple and similar to
java.lang.System for property access, it is also possible to programmatically refresh the property cache, here is an excerpt of the API:
package org.exoplatform.commons.utils;
public class PropertyManager {
public static String getProperty(String propertyName) { ... }
public static void setProperty(String propertyName, String propertyValue) { ... }
public static boolean isDevelopping() { ... }
public synchronized static boolean getUseCache() { ... }
public synchronized static void refresh() { ... }
}
The property manager has a
cache that is
enabled by default. The default behavior can be changed by configuring the system property
exo.developping. If the
exo.developping is set to
true then cache is
disabled; otherwise the cache is enabled.
When the property manager is refreshed by a call to the
refresh() method then the cache usage is reconfigured. If the exo.developping property has changed the call to the refresh() method takes this into account.
The property manager is also exposed by an
MBean, therefore you also can call refresh() by JMX. Using
JMX you also can set the value of any property (setProperty()) and get the current value (getProperty()).