javolution.lang
Class Configurable.Logic
java.lang.Object
javolution.lang.Configurable.Logic
- Enclosing class:
- Configurable<T>
public abstract static class Configurable.Logic
- extends java.lang.Object
This class represents a configuration logic capable of setting
Configurable
values. For example:
class MyApplication {
private static final Configuration CONFIGURATION = new Configuration();
public static void main(String[] args) {
CONFIGURATION.run();
...
}
static class Configuration extends Configurable.Logic implements Runnable {
public void run() {
Properties properties = System.getProperties();
// Properties could be loaded automatically if the property names
// were the full names of the configurable fields (ref. Configurable.read(Map)).
String concurrency = properties.get("MAXIMUM_CONCURRENCY");
if (concurrency != null) {
configure(ConcurrentContext.MAXIMUM_CONCURRENCY, TypeFormat.parseInt(concurrency));
}
...
}
}
}
Applications can prevent configuration modifications through
SecurityContext
. For example:
public class MyPolicy extends SecurityContext {
public boolean isModifiable (Configurable cfg) {
return false;
}
}
...
configure(SecurityContext.DEFAULT, MyPolicy.class); // Global setting.
Method Summary |
protected
|
configure(Configurable<T> cfg,
T value)
Sets the run-time value of the specified configurable. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Configurable.Logic
public Configurable.Logic()
configure
protected final <T> void configure(Configurable<T> cfg,
T value)
- Sets the run-time value of the specified configurable. If
configurable value is different from the previous one, then
Configurable.notifyChange()
is called. This method
raises SecurityException
if the specified
configurable is not modifiable
.
- Parameters:
cfg
- the configurable being configurated.value
- the new run-time value.
- Throws:
java.lang.SecurityException
- if the specified configurable cannot
be modified.
Copyright © 2005 - 2007 Javolution.