Example #1
0
        private static void printRequestHeader(System.IO.StringWriter s, BasicStream str)
        {
            printIdentityFacetOperation(s, str);

            try
            {
                byte mode = str.readByte();
                s.Write("\nmode = " + (int)mode + ' ');
                switch((Ice.OperationMode)mode)
                {
                case Ice.OperationMode.Normal:
                {
                    s.Write("(normal)");
                    break;
                }

                case Ice.OperationMode.Nonmutating:
                {
                    s.Write("(nonmutating)");
                    break;
                }

                case Ice.OperationMode.Idempotent:
                {
                    s.Write("(idempotent)");
                    break;
                }

                default:
                {
                    s.Write("(unknown)");
                    break;
                }
                }

                int sz = str.readSize();
                s.Write("\ncontext = ");
                while(sz-- > 0)
                {
                    string key = str.readString();
                    string val = str.readString();
                    s.Write(key + '/' + val);
                    if(sz > 0)
                    {
                        s.Write(", ");
                    }
                }

                Ice.EncodingVersion v = str.skipEncaps();
                if(!v.Equals(Ice.Util.Encoding_1_0))
                {
                    s.Write("\nencoding = ");
                    s.Write(Ice.Util.encodingVersionToString(v));
                }
            }
            catch(System.IO.IOException)
            {
                Debug.Assert(false);
            }
        }
Example #2
0
        public Reference create(Ice.Identity ident, BasicStream s)
        {
            //
            // Don't read the identity here. Operations calling this
            // constructor read the identity, and pass it as a parameter.
            //

            if(ident.name.Length == 0 && ident.category.Length == 0)
            {
                return null;
            }

            //
            // For compatibility with the old FacetPath.
            //
            string[] facetPath = s.readStringSeq();
            string facet;
            if(facetPath.Length > 0)
            {
                if(facetPath.Length > 1)
                {
                    throw new Ice.ProxyUnmarshalException();
                }
                facet = facetPath[0];
            }
            else
            {
                facet = "";
            }

            int mode = (int)s.readByte();
            if(mode < 0 || mode > (int)Reference.Mode.ModeLast)
            {
                throw new Ice.ProxyUnmarshalException();
            }

            bool secure = s.readBool();

            EndpointI[] endpoints = null;
            string adapterId = "";

            int sz = s.readSize();
            if(sz > 0)
            {
                endpoints = new EndpointI[sz];
                for(int i = 0; i < sz; i++)
                {
                    endpoints[i] = instance_.endpointFactoryManager().read(s);
                }
            }
            else
            {
                adapterId = s.readString();
            }

            return create(ident, facet, (Reference.Mode)mode, secure, endpoints, adapterId, null);
        }
Example #3
0
        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_.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.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);
                                }
                                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.skipEncaps(); // 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.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__(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;
        }