public override void ice_invoke_async(Ice.AMD_Object_ice_invoke cb, byte[] inParams, Ice.Current current) { Ice.Communicator communicator = current.adapter.getCommunicator(); Ice.InputStream inS = Ice.Util.createInputStream(communicator, inParams); Ice.OutputStream outS = Ice.Util.createOutputStream(communicator); if(current.operation.Equals("opOneway")) { cb.ice_response(true, new byte[0]); } else if(current.operation.Equals("opString")) { string s = inS.readString(); outS.writeString(s); outS.writeString(s); cb.ice_response(true, outS.finished()); } else if(current.operation.Equals("opException")) { Test.MyException ex = new Test.MyException(); outS.writeException(ex); cb.ice_response(false, outS.finished()); } else if(current.operation.Equals("shutdown")) { communicator.shutdown(); cb.ice_response(true, null); } else if(current.operation.Equals("ice_isA")) { string s = inS.readString(); if(s.Equals("::Test::MyClass")) { outS.writeBool(true); } else { outS.writeBool(false); } cb.ice_response(true, outS.finished()); } else { Ice.OperationNotExistException ex = new Ice.OperationNotExistException(); ex.id = current.id; ex.facet = current.facet; ex.operation = current.operation; throw ex; } }
public override void findAdapterById_async(Ice.AMD_Locator_findAdapterById response, string adapter, Ice.Current current) { ++_requestCount; if(adapter.Equals("TestAdapter10") || adapter.Equals("TestAdapter10-2")) { Debug.Assert(current.encoding.Equals(Ice.Util.Encoding_1_0)); response.ice_response(_registry.getAdapter("TestAdapter")); return; } // We add a small delay to make sure locator request queuing gets tested when // running the test on a fast machine System.Threading.Thread.Sleep(1); response.ice_response(_registry.getAdapter(adapter)); }
public override void findAdapterById_async(Ice.AMD_Locator_findAdapterById response, string adapter, Ice.Current current) { _controller.checkCallPause(current); Ice.Communicator communicator = current.adapter.getCommunicator(); response.ice_response(current.adapter.createDirectProxy(communicator.stringToIdentity("dummy"))); }
setServerProcessProxy_async(Ice.AMD_LocatorRegistry_setServerProcessProxy cb, string id, Ice.ProcessPrx process, Ice.Current current) { cb.ice_response(); }
setReplicatedAdapterDirectProxy_async(Ice.AMD_LocatorRegistry_setReplicatedAdapterDirectProxy cb, string adapterId, string replicaGroupId, Ice.ObjectPrx proxy, Ice.Current current) { lock(this) { if(proxy != null) { _adapters.Add(adapterId, proxy); HashSet<string> adapterIds; if(!_replicaGroups.TryGetValue(replicaGroupId, out adapterIds)) { adapterIds = new HashSet<string>(); _replicaGroups.Add(replicaGroupId, adapterIds); } adapterIds.Add(adapterId); } else { _adapters.Remove(adapterId); HashSet<string> adapterIds; if(_replicaGroups.TryGetValue(replicaGroupId, out adapterIds)) { adapterIds.Remove(adapterId); if(adapterIds.Count == 0) { _replicaGroups.Remove(replicaGroupId); } } } } cb.ice_response(); }
public override void findObjectById_async(Ice.AMD_Locator_findObjectById response, Ice.Identity id, Ice.Current current) { ++_requestCount; // We add a small delay to make sure locator request queuing gets tested when // running the test on a fast machine System.Threading.Thread.Sleep(1); response.ice_response(_registry.getObject(id)); }
public override void setAdapterDirectProxy_async(Ice.AMD_LocatorRegistry_setAdapterDirectProxy cb, string adapter, Ice.ObjectPrx obj, Ice.Current current) { if(obj != null) { _adapters[adapter] = obj; } else { _adapters.Remove(adapter); } cb.ice_response(); }
public override void ice_invoke_async(Ice.AMD_Object_ice_invoke amdCb, byte[] inEncaps, Ice.Current current) { bool twoway = current.requestId > 0; Ice.ObjectPrx obj = current.con.createProxy(current.id); if(!twoway) { if(_startBatch) { _startBatch = false; _batchProxy = obj.ice_batchOneway(); } if(_batchProxy != null) { obj = _batchProxy; } if(current.facet.Length != 0) { obj = obj.ice_facet(current.facet); } if(_batchProxy != null) { byte[] outEncaps; obj.ice_invoke(current.operation, current.mode, inEncaps, out outEncaps, current.ctx); amdCb.ice_response(true, new byte[0]); } else { Callback cb = new Callback(amdCb, false); obj.ice_oneway().begin_ice_invoke(current.operation, current.mode, inEncaps, current.ctx).whenCompleted(cb.response, cb.exception) .whenSent(cb.sent); } } else { if(current.facet.Length != 0) { obj = obj.ice_facet(current.facet); } Callback cb = new Callback(amdCb, true); obj.begin_ice_invoke(current.operation, current.mode, inEncaps, current.ctx).whenCompleted(cb.response, cb.exception).whenSent(cb.sent); } }
setAdapterDirectProxy_async(Ice.AMD_LocatorRegistry_setAdapterDirectProxy cb, string adapterId, Ice.ObjectPrx proxy, Ice.Current current) { lock(this) { if(proxy != null) { _adapters.Add(adapterId, proxy); } else { _adapters.Remove(adapterId); } cb.ice_response(); } }
public override void findObjectById_async(Ice.AMD_Locator_findObjectById amdCB, Ice.Identity id, Ice.Current current) { amdCB.ice_response(null); }
public override void findAdapterById_async(Ice.AMD_Locator_findAdapterById amdCB, String id, Ice.Current current) { amdCB.ice_response(null); }
public override void findObjectById_async(Ice.AMD_Locator_findObjectById response, Ice.Identity id, Ice.Current current) { _controller.checkCallPause(current); response.ice_response(current.adapter.createDirectProxy(id)); }
public override void setProperties_async(Ice.AMD_PropertiesAdmin_setProperties cb, Dictionary<string, string> props, Ice.Current current) { lock(this) { Dictionary<string, string> old = _properties.getPropertiesForPrefix(""); 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. // Dictionary<string, string> added = new Dictionary<string, string>(); Dictionary<string, string> changed = new Dictionary<string, string>(); Dictionary<string, string> removed = new Dictionary<string, string>(); foreach(KeyValuePair<string, string> e in props) { string key = e.Key; string value = e.Value; if(!old.ContainsKey(key)) { if(value.Length > 0) { // // This property is new. // added.Add(key, value); } } else { string v; if(!old.TryGetValue(key, out v) || !value.Equals(v)) { if(value.Length == 0) { // // This property was removed. // removed.Add(key, value); } else { // // This property has changed. // changed.Add(key, value); } } old.Remove(key); } } if(traceLevel > 0 && (added.Count > 0 || changed.Count > 0 || removed.Count > 0)) { System.Text.StringBuilder message = new System.Text.StringBuilder("Summary of property changes"); if(added.Count > 0) { message.Append("\nNew properties:"); foreach(KeyValuePair<string, string> e in added) { message.Append("\n "); message.Append(e.Key); if(traceLevel > 1) { message.Append(" = "); message.Append(e.Value); } } } if(changed.Count > 0) { message.Append("\nChanged properties:"); foreach(KeyValuePair<string, string> e in changed) { message.Append("\n "); message.Append(e.Key); if(traceLevel > 1) { message.Append(" = "); message.Append(e.Value); message.Append(" (old value = "); message.Append(_properties.getProperty(e.Key)); message.Append(")"); } } } if(removed.Count > 0) { message.Append("\nRemoved properties:"); foreach(KeyValuePair<string, string> e in removed) { message.Append("\n "); message.Append(e.Key); } } _logger.trace(_traceCategory, message.ToString()); } // // Update the property set. // foreach(KeyValuePair<string, string> e in added) { _properties.setProperty(e.Key, e.Value); } foreach(KeyValuePair<string, string> e in changed) { _properties.setProperty(e.Key, e.Value); } foreach(KeyValuePair<string, string> e in removed) { _properties.setProperty(e.Key, ""); } // // Send the response now so that we do not block the client during the call to the update callback. // cb.ice_response(); if(_updateCallbacks.Count > 0) { // // Copy the callbacks to allow callbacks to update the callbacks. // List<Ice.PropertiesAdminUpdateCallback> callbacks = new List<Ice.PropertiesAdminUpdateCallback>(_updateCallbacks); Dictionary<string, string> changes = new Dictionary<string, string>(added); foreach(KeyValuePair<string, string> e in changed) { changes.Add(e.Key, e.Value); } foreach(KeyValuePair<string, string> e in removed) { changes.Add(e.Key, e.Value); } foreach(Ice.PropertiesAdminUpdateCallback callback in callbacks) { try { callback.updated(changes); } catch(System.Exception) { // Ignore. } } } } }