summaryrefslogtreecommitdiff
path: root/java/src/IceInternal/PropertiesAdminI.java
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2012-09-14 11:36:49 +0200
committerBenoit Foucher <benoit@zeroc.com>2012-09-14 11:36:49 +0200
commit4a6fb70ebacad9f412cfb5ac6cb892c6d73e2eae (patch)
tree6021f6dc11029241a65b71c90e78427f1036c759 /java/src/IceInternal/PropertiesAdminI.java
parentFixed metrics tests (diff)
downloadice-4a6fb70ebacad9f412cfb5ac6cb892c6d73e2eae.tar.bz2
ice-4a6fb70ebacad9f412cfb5ac6cb892c6d73e2eae.tar.xz
ice-4a6fb70ebacad9f412cfb5ac6cb892c6d73e2eae.zip
Java & C# PropertiesAdmin fixes
Diffstat (limited to 'java/src/IceInternal/PropertiesAdminI.java')
-rw-r--r--java/src/IceInternal/PropertiesAdminI.java193
1 files changed, 96 insertions, 97 deletions
diff --git a/java/src/IceInternal/PropertiesAdminI.java b/java/src/IceInternal/PropertiesAdminI.java
index 59846b5b975..46dbfcd2d59 100644
--- a/java/src/IceInternal/PropertiesAdminI.java
+++ b/java/src/IceInternal/PropertiesAdminI.java
@@ -30,139 +30,132 @@ public class PropertiesAdminI extends Ice._PropertiesAdminDisp implements Ice.Na
return new java.util.TreeMap<String, String>(_properties.getPropertiesForPrefix(name));
}
- public void
+ synchronized public void
setProperties_async(Ice.AMD_PropertiesAdmin_setProperties cb, java.util.Map<String, String> props,
Ice.Current current)
{
+ java.util.Map<String, String> old = _properties.getPropertiesForPrefix("");
+ final int traceLevel = _properties.getPropertyAsInt("Ice.Trace.Admin.Properties");
+
+ //
+ // Compute the difference between the new property set and the existing property set:
+ //
+ // 1) Any properties in the new set that were not defined in the existing set.
+ //
+ // 2) Any properties that appear in both sets but with different values.
+ //
+ // 3) Any properties not present in the new set but present in the existing set.
+ // In other words, the property has been removed.
+ //
java.util.Map<String, String> added = new java.util.HashMap<String, String>();
java.util.Map<String, String> changed = new java.util.HashMap<String, String>();
java.util.Map<String, String> removed = new java.util.HashMap<String, String>();
- java.util.List<Ice.PropertiesAdminUpdateCallback> callbacks = null;
-
- synchronized(this)
+ for(java.util.Map.Entry<String, String> e : props.entrySet())
{
- java.util.Map<String, String> old = _properties.getPropertiesForPrefix("");
- final int traceLevel = _properties.getPropertyAsInt("Ice.Trace.Admin.Properties");
-
- //
- // Compute the difference between the new property set and the existing property set:
- //
- // 1) Any properties in the new set that were not defined in the existing set.
- //
- // 2) Any properties that appear in both sets but with different values.
- //
- // 3) Any properties not present in the new set but present in the existing set.
- // In other words, the property has been removed.
- //
- for(java.util.Map.Entry<String, String> e : props.entrySet())
+ final String key = e.getKey();
+ final String value = e.getValue();
+ if(!old.containsKey(key))
{
- final String key = e.getKey();
- final String value = e.getValue();
- if(!old.containsKey(key))
+ if(value.length() > 0)
{
- if(value.length() > 0)
+ //
+ // This property is new.
+ //
+ added.put(key, value);
+ }
+ }
+ else
+ {
+ if(!value.equals(old.get(key)))
+ {
+ if(value.length() == 0)
{
//
- // This property is new.
+ // This property was removed.
//
- added.put(key, value);
+ removed.put(key, value);
}
- }
- else
- {
- if(!value.equals(old.get(key)))
+ else
{
- if(value.length() == 0)
- {
- //
- // This property was removed.
- //
- removed.put(key, value);
- }
- else
- {
- //
- // This property has changed.
- //
- changed.put(key, value);
- }
+ //
+ // This property has changed.
+ //
+ changed.put(key, value);
}
-
- old.remove(key);
}
+
+ old.remove(key);
}
+ }
- if(traceLevel > 0 && (!added.isEmpty() || !changed.isEmpty() || !removed.isEmpty()))
- {
- StringBuilder out = new StringBuilder(128);
- out.append("Summary of property changes");
+ if(traceLevel > 0 && (!added.isEmpty() || !changed.isEmpty() || !removed.isEmpty()))
+ {
+ StringBuilder out = new StringBuilder(128);
+ out.append("Summary of property changes");
- if(!added.isEmpty())
+ if(!added.isEmpty())
+ {
+ out.append("\nNew properties:");
+ for(java.util.Map.Entry<String, String> e : added.entrySet())
{
- out.append("\nNew properties:");
- for(java.util.Map.Entry<String, String> e : added.entrySet())
+ out.append("\n ");
+ out.append(e.getKey());
+ if(traceLevel > 1)
{
- out.append("\n ");
- out.append(e.getKey());
- if(traceLevel > 1)
- {
- out.append(" = ");
- out.append(e.getValue());
- }
+ out.append(" = ");
+ out.append(e.getValue());
}
}
+ }
- if(!changed.isEmpty())
+ if(!changed.isEmpty())
+ {
+ out.append("\nChanged properties:");
+ for(java.util.Map.Entry<String, String> e : changed.entrySet())
{
- out.append("\nChanged properties:");
- for(java.util.Map.Entry<String, String> e : changed.entrySet())
+ out.append("\n ");
+ out.append(e.getKey());
+ if(traceLevel > 1)
{
- out.append("\n ");
- out.append(e.getKey());
- if(traceLevel > 1)
- {
- out.append(" = ");
- out.append(e.getValue());
- out.append(" (old value = ");
- out.append(_properties.getProperty(e.getKey()));
- out.append(")");
- }
+ out.append(" = ");
+ out.append(e.getValue());
+ out.append(" (old value = ");
+ out.append(_properties.getProperty(e.getKey()));
+ out.append(")");
}
}
+ }
- if(!removed.isEmpty())
+ if(!removed.isEmpty())
+ {
+ out.append("\nRemoved properties:");
+ for(java.util.Map.Entry<String, String> e : removed.entrySet())
{
- out.append("\nRemoved properties:");
- for(java.util.Map.Entry<String, String> e : removed.entrySet())
- {
- out.append("\n ");
- out.append(e.getKey());
- }
+ out.append("\n ");
+ out.append(e.getKey());
}
-
- _logger.trace(_name, out.toString());
}
- //
- // Update the property set.
- //
+ _logger.trace(_name, out.toString());
+ }
- for(java.util.Map.Entry<String, String> e : added.entrySet())
- {
- _properties.setProperty(e.getKey(), e.getValue());
- }
+ //
+ // Update the property set.
+ //
- for(java.util.Map.Entry<String, String> e : changed.entrySet())
- {
- _properties.setProperty(e.getKey(), e.getValue());
- }
+ for(java.util.Map.Entry<String, String> e : added.entrySet())
+ {
+ _properties.setProperty(e.getKey(), e.getValue());
+ }
- for(java.util.Map.Entry<String, String> e : removed.entrySet())
- {
- _properties.setProperty(e.getKey(), "");
- }
+ for(java.util.Map.Entry<String, String> e : changed.entrySet())
+ {
+ _properties.setProperty(e.getKey(), e.getValue());
+ }
- callbacks = new java.util.ArrayList<Ice.PropertiesAdminUpdateCallback>(_updateCallbacks);
+ for(java.util.Map.Entry<String, String> e : removed.entrySet())
+ {
+ _properties.setProperty(e.getKey(), "");
}
//
@@ -170,8 +163,14 @@ public class PropertiesAdminI extends Ice._PropertiesAdminDisp implements Ice.Na
//
cb.ice_response();
- if(callbacks != null)
+ if(!_updateCallbacks.isEmpty())
{
+ //
+ // Copy the callbacks to allow callbacks to update the callbacks.
+ //
+ java.util.List<Ice.PropertiesAdminUpdateCallback> callbacks =
+ new java.util.ArrayList<Ice.PropertiesAdminUpdateCallback>(_updateCallbacks);
+
java.util.Map<String, String> changes = new java.util.HashMap<String, String>(added);
changes.putAll(changed);
changes.putAll(removed);