public void invoke(ServantManager servantManager, Ice.InputStream stream) { _is = stream; int start = _is.pos(); // // Read the current. // var id = new Ice.Identity(); id.ice_readMembers(_is); // // For compatibility with the old FacetPath. // string[] facetPath = _is.ReadStringSeq(); string facet; if (facetPath.Length > 0) { if (facetPath.Length > 1) { throw new Ice.MarshalException(); } facet = facetPath[0]; } else { facet = ""; } string operation = _is.ReadString(); byte mode = _is.ReadByte(); Dictionary <string, string> context = new Dictionary <string, string>(); int sz = _is.ReadSize(); while (sz-- > 0) { string first = _is.ReadString(); string second = _is.ReadString(); context[first] = second; } _current = new Ice.Current(_adapter, id, facet, operation, (Ice.OperationMode)mode, context, _requestId, _connection); Ice.Instrumentation.CommunicatorObserver?obsv = _communicator.Observer; if (obsv != null) { // Read the encapsulation size. int size = _is.ReadInt(); _is.pos(_is.pos() - 4); _observer = obsv.getDispatchObserver(_current, _is.pos() - start + size); if (_observer != null) { _observer.attach(); } } // // Don't put the code above into the try block below. Exceptions // in the code above are considered fatal, and must propagate to // the caller of this operation. // if (servantManager != null) { _servant = servantManager.findServant(_current.Id, _current.Facet); if (_servant == null) { _locator = servantManager.findServantLocator(_current.Id.category); if (_locator == null && _current.Id.category.Length > 0) { _locator = servantManager.findServantLocator(""); } if (_locator != null) { Debug.Assert(_locator != null); try { _servant = _locator.locate(_current, out _cookie); } catch (Exception ex) { skipReadParams(); // Required for batch requests. handleException(ex, false); return; } } } } if (_servant == null) { try { if (servantManager != null && servantManager.hasServant(_current.Id)) { throw new Ice.FacetNotExistException(_current.Id, _current.Facet, _current.Operation); } else { throw new Ice.ObjectNotExistException(_current.Id, _current.Facet, _current.Operation); } } catch (Exception ex) { skipReadParams(); // Required for batch requests handleException(ex, false); return; } } try { Task <Ice.OutputStream>?task = _servant(this, _current); if (task == null) { completed(null, false); } else { if (task.IsCompleted) { _os = task.GetAwaiter().GetResult(); // Get the response completed(null, false); } else { task.ContinueWith((Task <Ice.OutputStream> t) => { try { _os = t.GetAwaiter().GetResult(); completed(null, true); // true = asynchronous } catch (Exception ex) { completed(ex, true); // true = asynchronous } }, CancellationToken.None, TaskContinuationOptions.ExecuteSynchronously, scheduler: TaskScheduler.Current); } } } catch (Exception ex) { completed(ex, false); } }
public void invoke(ServantManager servantManager, BasicStream stream) { _is = stream; int start = _is.pos(); // // Read the current. // current_.id.read__(_is); // // For compatibility with the old FacetPath. // string[] facetPath = _is.readStringSeq(); if (facetPath.Length > 0) { if (facetPath.Length > 1) { throw new Ice.MarshalException(); } current_.facet = facetPath[0]; } else { current_.facet = ""; } current_.operation = _is.readString(); current_.mode = (Ice.OperationMode)(int) _is.readByte(); current_.ctx = new Dictionary <string, string>(); int sz = _is.readSize(); while (sz-- > 0) { string first = _is.readString(); string second = _is.readString(); current_.ctx[first] = second; } Ice.Instrumentation.CommunicatorObserver obsv = instance_.getObserver(); if (obsv != null) { // Read the encapsulation size. int size = _is.readInt(); _is.pos(_is.pos() - 4); observer_ = obsv.getDispatchObserver(current_, _is.pos() - start + size); if (observer_ != null) { observer_.attach(); } } // // Don't put the code above into the try block below. Exceptions // in the code above are considered fatal, and must propagate to // the caller of this operation. // if (servantManager != null) { servant_ = servantManager.findServant(current_.id, current_.facet); if (servant_ == null) { locator_ = servantManager.findServantLocator(current_.id.category); if (locator_ == null && current_.id.category.Length > 0) { locator_ = servantManager.findServantLocator(""); } if (locator_ != null) { try { servant_ = locator_.locate(current_, out cookie_); } catch (Ice.UserException ex) { Ice.EncodingVersion encoding = _is.skipEncaps(); // Required for batch requests. if (observer_ != null) { observer_.userException(); } if (response_) { os_.writeByte(ReplyStatus.replyUserException); os_.startWriteEncaps(encoding, Ice.FormatType.DefaultFormat); os_.writeUserException(ex); os_.endWriteEncaps(); if (observer_ != null) { observer_.reply(os_.size() - Protocol.headerSize - 4); } connection_.sendResponse(os_, compress_); } else { connection_.sendNoResponse(); } if (observer_ != null) { observer_.detach(); observer_ = null; } connection_ = null; return; } catch (System.Exception ex) { _is.skipEncaps(); // Required for batch requests. handleException__(ex); return; } } } } try { if (servant_ != null) { // // DispatchAsync is a "pseudo dispatch status", used internally only // to indicate async dispatch. // if (servant_.dispatch__(this, current_) == Ice.DispatchStatus.DispatchAsync) { // // If this was an asynchronous dispatch, we're done here. // return; } if (locator_ != null && !servantLocatorFinished__()) { return; } } else { // // Skip the input parameters, this is required for reading // the next batch request if dispatching batch requests. // _is.skipEncaps(); if (servantManager != null && servantManager.hasServant(current_.id)) { throw new Ice.FacetNotExistException(current_.id, current_.facet, current_.operation); } else { throw new Ice.ObjectNotExistException(current_.id, current_.facet, current_.operation); } } } catch (System.Exception ex) { if (servant_ != null && locator_ != null && !servantLocatorFinished__()) { return; } handleException__(ex); return; } // // Don't put the code below into the try block above. Exceptions // in the code below are considered fatal, and must propagate to // the caller of this operation. // Debug.Assert(connection_ != null); if (response_) { if (observer_ != null) { observer_.reply(os_.size() - Protocol.headerSize - 4); } connection_.sendResponse(os_, compress_); } else { connection_.sendNoResponse(); } if (observer_ != null) { observer_.detach(); observer_ = null; } connection_ = null; }
public Direct(Ice.Current current, RunDelegate run) { _current = current; _run = run; Ice.ObjectAdapterI adapter = (Ice.ObjectAdapterI)_current.adapter; Debug.Assert(adapter != null); // // Must call incDirectCount() first, because it checks for // adapter deactivation, and prevents deactivation completion // until decDirectCount() is called. This is important, // because getServantManager() may not be called afer // deactivation completion. // adapter.incDirectCount(); ServantManager servantManager = adapter.getServantManager(); Debug.Assert(servantManager != null); _servant = servantManager.findServant(_current.id, _current.facet); if (_servant == null) { _locator = servantManager.findServantLocator(_current.id.category); if (_locator == null && _current.id.category.Length > 0) { _locator = servantManager.findServantLocator(""); } if (_locator != null) { try { _servant = _locator.locate(_current, out _cookie); } catch (System.Exception) { adapter.decDirectCount(); throw; } } } if (_servant == null) { adapter.decDirectCount(); if (servantManager != null && servantManager.hasServant(_current.id)) { Ice.FacetNotExistException ex = new Ice.FacetNotExistException(); ex.id = _current.id; ex.facet = _current.facet; ex.operation = _current.operation; throw ex; } else { Ice.ObjectNotExistException ex = new Ice.ObjectNotExistException(); ex.id = _current.id; ex.facet = _current.facet; ex.operation = _current.operation; throw ex; } } }
public void invoke(ServantManager servantManager, Ice.InputStream stream) { _is = stream; int start = _is.pos(); // // Read the current. // current_.id.read__(_is); // // For compatibility with the old FacetPath. // string[] facetPath = _is.readStringSeq(); if(facetPath.Length > 0) { if(facetPath.Length > 1) { throw new Ice.MarshalException(); } current_.facet = facetPath[0]; } else { current_.facet = ""; } current_.operation = _is.readString(); current_.mode = (Ice.OperationMode)(int)_is.readByte(); current_.ctx = new Dictionary<string, string>(); int sz = _is.readSize(); while(sz-- > 0) { string first = _is.readString(); string second = _is.readString(); current_.ctx[first] = second; } Ice.Instrumentation.CommunicatorObserver obsv = instance_.initializationData().observer; if(obsv != null) { // Read the encapsulation size. int size = _is.readInt(); _is.pos(_is.pos() - 4); observer_ = obsv.getDispatchObserver(current_, _is.pos() - start + size); if(observer_ != null) { observer_.attach(); } } // // Don't put the code above into the try block below. Exceptions // in the code above are considered fatal, and must propagate to // the caller of this operation. // if(servantManager != null) { servant_ = servantManager.findServant(current_.id, current_.facet); if(servant_ == null) { locator_ = servantManager.findServantLocator(current_.id.category); if(locator_ == null && current_.id.category.Length > 0) { locator_ = servantManager.findServantLocator(""); } if(locator_ != null) { try { servant_ = locator_.locate(current_, out cookie_); } catch(Ice.UserException ex) { Ice.EncodingVersion encoding = _is.skipEncapsulation(); // Required for batch requests. if(observer_ != null) { observer_.userException(); } if(response_) { os_.writeByte(ReplyStatus.replyUserException); os_.startEncapsulation(encoding, Ice.FormatType.DefaultFormat); os_.writeException(ex); os_.endEncapsulation(); if(observer_ != null) { observer_.reply(os_.size() - Protocol.headerSize - 4); } responseHandler_.sendResponse(current_.requestId, os_, compress_, false); } else { responseHandler_.sendNoResponse(); } if(observer_ != null) { observer_.detach(); observer_ = null; } responseHandler_ = null; return; } catch(System.Exception ex) { _is.skipEncapsulation(); // Required for batch requests. handleException__(ex, false); return; } } } } try { if(servant_ != null) { // // DispatchAsync is a "pseudo dispatch status", used internally only // to indicate async dispatch. // if(servant_.dispatch__(this, current_) == Ice.DispatchStatus.DispatchAsync) { // // If this was an asynchronous dispatch, we're done here. // return; } if(locator_ != null && !servantLocatorFinished__(false)) { return; } } else { // // Skip the input parameters, this is required for reading // the next batch request if dispatching batch requests. // _is.skipEncapsulation(); if(servantManager != null && servantManager.hasServant(current_.id)) { throw new Ice.FacetNotExistException(current_.id, current_.facet, current_.operation); } else { throw new Ice.ObjectNotExistException(current_.id, current_.facet, current_.operation); } } } catch(System.Exception ex) { if(servant_ != null && locator_ != null && !servantLocatorFinished__(false)) { return; } handleException__(ex, false); return; } // // Don't put the code below into the try block above. Exceptions // in the code below are considered fatal, and must propagate to // the caller of this operation. // Debug.Assert(responseHandler_ != null); if(response_) { if(observer_ != null) { observer_.reply(os_.size() - Protocol.headerSize - 4); } responseHandler_.sendResponse(current_.requestId, os_, compress_, false); } else { responseHandler_.sendNoResponse(); } if(observer_ != null) { observer_.detach(); observer_ = null; } responseHandler_ = null; }
public void invoke(ServantManager servantManager) { // // Read the current. // current_.id.read__(_is); // // For compatibility with the old FacetPath. // string[] facetPath = _is.readStringSeq(); if(facetPath.Length > 0) { if(facetPath.Length > 1) { throw new Ice.MarshalException(); } current_.facet = facetPath[0]; } else { current_.facet = ""; } current_.operation = _is.readString(); current_.mode = (Ice.OperationMode)(int)_is.readByte(); current_.ctx = new Dictionary<string, string>(); int sz = _is.readSize(); while(sz-- > 0) { string first = _is.readString(); string second = _is.readString(); current_.ctx[first] = second; } if(response_) { Debug.Assert(os_.size() == Protocol.headerSize + 4); // Reply status position. os_.writeByte(ReplyStatus.replyOK); os_.startWriteEncaps(); } byte replyStatus = ReplyStatus.replyOK; Ice.DispatchStatus dispatchStatus = Ice.DispatchStatus.DispatchOK; // // Don't put the code above into the try block below. Exceptions // in the code above are considered fatal, and must propagate to // the caller of this operation. // if(servantManager != null) { servant_ = servantManager.findServant(current_.id, current_.facet); if(servant_ == null) { locator_ = servantManager.findServantLocator(current_.id.category); if(locator_ == null && current_.id.category.Length > 0) { locator_ = servantManager.findServantLocator(""); } if(locator_ != null) { try { servant_ = locator_.locate(current_, out cookie_); } catch(Ice.UserException ex) { os_.writeUserException(ex); replyStatus = ReplyStatus.replyUserException; } catch(System.Exception ex) { handleException__(ex); return; } } } } if(servant_ != null) { try { Debug.Assert(replyStatus == ReplyStatus.replyOK); dispatchStatus = servant_.dispatch__(this, current_); if(dispatchStatus == Ice.DispatchStatus.DispatchUserException) { replyStatus = ReplyStatus.replyUserException; } if(dispatchStatus != Ice.DispatchStatus.DispatchAsync) { if(locator_ != null && !servantLocatorFinished__()) { return; } } } catch(System.Exception ex) { if(locator_ != null && !servantLocatorFinished__()) { return; } handleException__(ex); return; } } else if(replyStatus == ReplyStatus.replyOK) { if(servantManager != null && servantManager.hasServant(current_.id)) { replyStatus = ReplyStatus.replyFacetNotExist; } else { replyStatus = ReplyStatus.replyObjectNotExist; } } // // Don't put the code below into the try block above. Exceptions // in the code below are considered fatal, and must propagate to // the caller of this operation. // // // Async dispatch // if(dispatchStatus == Ice.DispatchStatus.DispatchAsync) { // // If this was an asynchronous dispatch, we're done // here. // return; } Debug.Assert(connection_ != null); if(response_) { os_.endWriteEncaps(); if(replyStatus != ReplyStatus.replyOK && replyStatus != ReplyStatus.replyUserException) { Debug.Assert(replyStatus == ReplyStatus.replyObjectNotExist || replyStatus == ReplyStatus.replyFacetNotExist); os_.resize(Protocol.headerSize + 4, false); // Reply status position. os_.writeByte(replyStatus); current_.id.write__(os_); // // For compatibility with the old FacetPath. // if(current_.facet == null || current_.facet.Length == 0) { os_.writeStringSeq(null); } else { string[] facetPath2 = { current_.facet }; os_.writeStringSeq(facetPath2); } os_.writeString(current_.operation); } else { int save = os_.pos(); os_.pos(Protocol.headerSize + 4); // Reply status position. os_.writeByte(replyStatus); os_.pos(save); } connection_.sendResponse(os_, compress_); } else { connection_.sendNoResponse(); } connection_ = null; }
public void invoke(ServantManager servantManager, Ice.InputStream stream) { _is = stream; int start = _is.pos(); // // Read the current. // _current.id.read__(_is); // // For compatibility with the old FacetPath. // string[] facetPath = _is.readStringSeq(); if (facetPath.Length > 0) { if (facetPath.Length > 1) { throw new Ice.MarshalException(); } _current.facet = facetPath[0]; } else { _current.facet = ""; } _current.operation = _is.readString(); _current.mode = (Ice.OperationMode)(int) _is.readByte(); _current.ctx = new Dictionary <string, string>(); int sz = _is.readSize(); while (sz-- > 0) { string first = _is.readString(); string second = _is.readString(); _current.ctx[first] = second; } Ice.Instrumentation.CommunicatorObserver obsv = _instance.initializationData().observer; if (obsv != null) { // Read the encapsulation size. int size = _is.readInt(); _is.pos(_is.pos() - 4); _observer = obsv.getDispatchObserver(_current, _is.pos() - start + size); if (_observer != null) { _observer.attach(); } } // // Don't put the code above into the try block below. Exceptions // in the code above are considered fatal, and must propagate to // the caller of this operation. // if (servantManager != null) { _servant = servantManager.findServant(_current.id, _current.facet); if (_servant == null) { _locator = servantManager.findServantLocator(_current.id.category); if (_locator == null && _current.id.category.Length > 0) { _locator = servantManager.findServantLocator(""); } if (_locator != null) { Debug.Assert(_locator != null); try { _servant = _locator.locate(_current, out _cookie); } catch (System.Exception ex) { skipReadParams(); // Required for batch requests. handleException(ex, false); return; } } } } if (_servant == null) { try { // // Skip the input parameters, this is required for reading // the next batch request if dispatching batch requests. // _is.skipEncapsulation(); if (servantManager != null && servantManager.hasServant(_current.id)) { throw new Ice.FacetNotExistException(_current.id, _current.facet, _current.operation); } else { throw new Ice.ObjectNotExistException(_current.id, _current.facet, _current.operation); } } catch (System.Exception ex) { handleException(ex, false); return; } } try { Task <Ice.OutputStream> task = _servant.dispatch__(this, _current); if (task == null) { completed(null, false); } else { if (task.IsCompleted) { _os = task.GetAwaiter().GetResult(); // Get the response completed(null, false); } else { task.ContinueWith((Task <Ice.OutputStream> t) => { try { _os = t.GetAwaiter().GetResult(); completed(null, true); // true = asynchronous } catch (Exception ex) { completed(ex, true); // true = asynchronous } }, TaskContinuationOptions.ExecuteSynchronously); } } } catch (System.Exception ex) { completed(ex, false); } }