forked from I2P_Developers/i2p.i2p
Moved I2PProperties callback to the RouterContext.
This commit is contained in:
@@ -64,7 +64,7 @@ public class I2PAppContext {
|
||||
/** the context that components without explicit root are bound */
|
||||
protected static I2PAppContext _globalAppContext;
|
||||
|
||||
private I2PProperties _overrideProps;
|
||||
protected I2PProperties _overrideProps;
|
||||
|
||||
private StatManager _statManager;
|
||||
private SessionKeyManager _sessionKeyManager;
|
||||
@@ -480,26 +480,13 @@ 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.
|
||||
* Unimplemented in I2PAppContext: this only makes sense in a router context.
|
||||
* @param callback The implementation of the callback.
|
||||
*/
|
||||
public void addPropertyCallback(I2PPropertyCallback callback) {
|
||||
_overrideProps.addCallBack(callback);
|
||||
}
|
||||
public void addPropertyCallback(I2PPropertyCallback callback) {}
|
||||
|
||||
/**
|
||||
* The statistics component with which we can track various events
|
||||
|
||||
@@ -17,7 +17,6 @@ public class I2PProperties extends Properties {
|
||||
/**
|
||||
* Keep a list of callbacks to contact the interested parties
|
||||
* that want to know about property changes.
|
||||
* @todo Use a map of lists, so we don't need to loop over all the callbacks on every change.
|
||||
*/
|
||||
private final List<I2PPropertyCallback> _callbacks = new CopyOnWriteArrayList<I2PPropertyCallback>();
|
||||
|
||||
@@ -40,9 +39,7 @@ public class I2PProperties extends Properties {
|
||||
public Object setProperty(String key, String value) {
|
||||
Object returnValue = super.setProperty(key, value);
|
||||
for(I2PPropertyCallback callback: _callbacks) {
|
||||
if(callback.getPropertyKey().equals(key)) {
|
||||
callback.propertyChanged(key, value);
|
||||
}
|
||||
callback.propertyChanged(key, value);
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
@@ -51,7 +48,6 @@ public class I2PProperties extends Properties {
|
||||
|
||||
public void propertyChanged(String key, String value);
|
||||
|
||||
public String getPropertyKey();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user