forked from I2P_Developers/i2p.i2p
Added support for callbacks when changes in I2PAppContext properties occur.
This commit is contained in:
@ -27,11 +27,13 @@ import net.i2p.util.Clock;
|
||||
import net.i2p.util.ConcurrentHashSet;
|
||||
import net.i2p.util.FileUtil;
|
||||
import net.i2p.util.FortunaRandomSource;
|
||||
import net.i2p.util.I2PProperties;
|
||||
import net.i2p.util.KeyRing;
|
||||
import net.i2p.util.LogManager;
|
||||
//import net.i2p.util.PooledRandomSource;
|
||||
import net.i2p.util.RandomSource;
|
||||
import net.i2p.util.SecureDirectory;
|
||||
import net.i2p.util.I2PProperties.I2PPropertyCallback;
|
||||
|
||||
/**
|
||||
* <p>Provide a base scope for accessing singletons that I2P exposes. Rather than
|
||||
@ -62,7 +64,7 @@ public class I2PAppContext {
|
||||
/** the context that components without explicit root are bound */
|
||||
protected static I2PAppContext _globalAppContext;
|
||||
|
||||
private Properties _overrideProps;
|
||||
private I2PProperties _overrideProps;
|
||||
|
||||
private StatManager _statManager;
|
||||
private SessionKeyManager _sessionKeyManager;
|
||||
@ -165,7 +167,7 @@ public class I2PAppContext {
|
||||
_globalAppContext = this;
|
||||
}
|
||||
}
|
||||
_overrideProps = envProps;
|
||||
_overrideProps = new I2PProperties(envProps);
|
||||
_statManager = null;
|
||||
_sessionKeyManager = null;
|
||||
_namingService = null;
|
||||
@ -478,6 +480,27 @@ public class I2PAppContext {
|
||||
return names;
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify the configuration attributes of this context, changing
|
||||
* one of the properties provided during the context construction.
|
||||
* @param propName The name of the property.
|
||||
* @param value The new value for the property.
|
||||
*/
|
||||
public void setProperty(String propName, String value) {
|
||||
if(_overrideProps != null) {
|
||||
_overrideProps.setProperty(propName, value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a callback, which will fire upon changes in the property
|
||||
* given in the specific callback.
|
||||
* @param callback The implementation of the callback.
|
||||
*/
|
||||
public void addPropertyCallback(I2PPropertyCallback callback) {
|
||||
_overrideProps.addCallBack(callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* The statistics component with which we can track various events
|
||||
* over time.
|
||||
|
Reference in New Issue
Block a user