예제 #1
0
    public override IceInternal.Acceptor acceptor(ref IceInternal.EndpointI endpoint, string adapterName)
    {
        Acceptor p = new Acceptor(_endpoint.acceptor(ref endpoint, adapterName));

        endpoint = new EndpointI(endpoint);
        return(p);
    }
예제 #2
0
    public override int CompareTo(IceInternal.EndpointI obj)
    {
        EndpointI p = null;

        try
        {
            p = (EndpointI)obj;
        }
        catch (System.InvalidCastException)
        {
            try
            {
                return(type() < obj.type() ? -1 : 1);
            }
            catch (System.InvalidCastException)
            {
                Debug.Assert(false);
            }
        }

        if (this == p)
        {
            return(0);
        }

        return(_endpoint.CompareTo(p._endpoint));
    }
예제 #3
0
 public override bool equivalent(IceInternal.EndpointI endpoint)
 {
     if (!(endpoint is EndpointI))
     {
         return(false);
     }
     return(((EndpointI)endpoint)._endpoint.equivalent(_endpoint));
 }
예제 #4
0
 public EndpointI endpoint(IceInternal.EndpointI delEndp)
 {
     if (delEndp == _endpoint)
     {
         return(this);
     }
     else
     {
         return(new EndpointI(delEndp));
     }
 }
예제 #5
0
 public override IceInternal.EndpointI timeout(int timeout)
 {
     IceInternal.EndpointI endpoint = _endpoint.timeout(timeout);
     if (endpoint == _endpoint)
     {
         return(this);
     }
     else
     {
         return(new EndpointI(endpoint));
     }
 }
예제 #6
0
 public override IceInternal.EndpointI connectionId(string connectionId)
 {
     IceInternal.EndpointI endpoint = _endpoint.connectionId(connectionId);
     if (endpoint == _endpoint)
     {
         return(this);
     }
     else
     {
         return(new EndpointI(endpoint));
     }
 }
예제 #7
0
 public override IceInternal.EndpointI compress(bool compress)
 {
     IceInternal.EndpointI endpoint = _endpoint.compress(compress);
     if (endpoint == _endpoint)
     {
         return(this);
     }
     else
     {
         return(new EndpointI(endpoint));
     }
 }
예제 #8
0
    public override List <IceInternal.EndpointI> expandHost(out IceInternal.EndpointI publish)
    {
        List <IceInternal.EndpointI> endps = new List <IceInternal.EndpointI>();

        foreach (IceInternal.EndpointI endpt in _endpoint.expandHost(out publish))
        {
            endps.Add(endpt == _endpoint ? this : new EndpointI(endpt));
        }
        if (publish != null)
        {
            publish = publish == _endpoint ? this : new EndpointI(publish);
        }
        return(endps);
    }
예제 #9
0
    public override bool equivalent(IceInternal.EndpointI endpoint)
    {
        EndpointI testEndpoint = null;

        try
        {
            testEndpoint = (EndpointI)endpoint;
        }
        catch (System.InvalidCastException)
        {
            return(false);
        }
        return(testEndpoint._endpoint.equivalent(_endpoint));
    }
예제 #10
0
    public override int CompareTo(IceInternal.EndpointI obj)
    {
        if (ReferenceEquals(this, obj))
        {
            return(0);
        }

        if (!(obj is EndpointI))
        {
            return(type() < obj.type() ? -1 : 1);
        }

        return(_endpoint.CompareTo(((EndpointI)obj)._endpoint));
    }
예제 #11
0
        public override List <EndpointI> expandHost(out EndpointI publish)
        {
            //
            // If this endpoint has an empty host (wildcard address), don't expand, just return
            // this endpoint.
            //
            var endpoints = new List <EndpointI>();

            if (host_.Length == 0)
            {
                publish = null;
                endpoints.Add(this);
                return(endpoints);
            }

            //
            // If using a fixed port, this endpoint can be used as the published endpoint to
            // access the returned endpoints. Otherwise, we'll publish each individual expanded
            // endpoint.
            //
            publish = port_ > 0 ? this : null;

            List <EndPoint> addresses = Network.getAddresses(host_,
                                                             port_,
                                                             instance_.protocolSupport(),
                                                             Ice.EndpointSelectionType.Ordered,
                                                             instance_.preferIPv6(),
                                                             true);

            if (addresses.Count == 1)
            {
                endpoints.Add(this);
            }
            else
            {
                foreach (EndPoint addr in addresses)
                {
                    endpoints.Add(createEndpoint(Network.endpointAddressToString(addr),
                                                 Network.endpointPort(addr),
                                                 connectionId_));
                }
            }
            return(endpoints);
        }
예제 #12
0
    //
    // Return a server side transceiver for this endpoint, or null if a
    // transceiver can only be created by an acceptor. In case a
    // transceiver is created, this operation also returns a new
    // "effective" endpoint, which might differ from this endpoint,
    // for example, if a dynamic port number is assigned.
    //
    public override IceInternal.Transceiver transceiver(ref IceInternal.EndpointI endpoint)
    {
        IceInternal.Transceiver transceiver = _endpoint.transceiver(ref endpoint);
        if (endpoint == _endpoint)
        {
            endpoint = this;
        }
        else
        {
            endpoint = new EndpointI(endpoint);
        }

        if (transceiver != null)
        {
            return(new Transceiver(transceiver));
        }
        else
        {
            return(null);
        }
    }
예제 #13
0
        public override int CompareTo(EndpointI obj)
        {
            if (!(obj is IPEndpointI))
            {
                return(type() < obj.type() ? -1 : 1);
            }

            IPEndpointI p = (IPEndpointI)obj;

            if (this == p)
            {
                return(0);
            }

            int v = string.Compare(host_, p.host_, StringComparison.Ordinal);

            if (v != 0)
            {
                return(v);
            }

            if (port_ < p.port_)
            {
                return(-1);
            }
            else if (p.port_ < port_)
            {
                return(1);
            }

            int rc = string.Compare(Network.endpointAddressToString(sourceAddr_),
                                    Network.endpointAddressToString(p.sourceAddr_), StringComparison.Ordinal);

            if (rc != 0)
            {
                return(rc);
            }

            return(string.Compare(connectionId_, p.connectionId_, StringComparison.Ordinal));
        }
예제 #14
0
        public override int CompareTo(EndpointI obj)
        {
            if (!(obj is EndpointI))
            {
                return(type() < obj.type() ? -1 : 1);
            }

            WSEndpoint p = (WSEndpoint)obj;

            if (this == p)
            {
                return(0);
            }

            int v = string.Compare(_resource, p._resource, StringComparison.Ordinal);

            if (v != 0)
            {
                return(v);
            }

            return(_delegate.CompareTo(p._delegate));
        }
예제 #15
0
 override protected EndpointI readWithUnderlying(EndpointI underlying, Ice.InputStream s)
 {
     return(new WSEndpoint(instance_, underlying, s));
 }
예제 #16
0
        public Reference create(Ice.Identity ident, Ice.InputStream 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();

            Ice.ProtocolVersion protocol;
            Ice.EncodingVersion encoding;
            if (!s.getEncoding().Equals(Ice.Util.Encoding_1_0))
            {
                protocol = new Ice.ProtocolVersion();
                protocol.read__(s);
                encoding = new Ice.EncodingVersion();
                encoding.read__(s);
            }
            else
            {
                protocol = Ice.Util.Protocol_1_0;
                encoding = Ice.Util.Encoding_1_0;
            }

            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, protocol, encoding, endpoints, adapterId, null));
        }
예제 #17
0
        public Reference create(string s, string propertyPrefix)
        {
            if (s.Length == 0)
            {
                return(null);
            }

            const string delim = " \t\n\r";

            int beg;
            int end = 0;

            beg = IceUtilInternal.StringUtil.findFirstNotOf(s, delim, end);
            if (beg == -1)
            {
                Ice.ProxyParseException e = new Ice.ProxyParseException();
                e.str = "no non-whitespace characters found in `" + s + "'";
                throw e;
            }

            //
            // Extract the identity, which may be enclosed in single
            // or double quotation marks.
            //
            string idstr = null;

            end = IceUtilInternal.StringUtil.checkQuote(s, beg);
            if (end == -1)
            {
                Ice.ProxyParseException e = new Ice.ProxyParseException();
                e.str = "mismatched quotes around identity in `" + s + "'";
                throw e;
            }
            else if (end == 0)
            {
                end = IceUtilInternal.StringUtil.findFirstOf(s, delim + ":@", beg);
                if (end == -1)
                {
                    end = s.Length;
                }
                idstr = s.Substring(beg, end - beg);
            }
            else
            {
                beg++; // Skip leading quote
                idstr = s.Substring(beg, end - beg);
                end++; // Skip trailing quote
            }

            if (beg == end)
            {
                Ice.ProxyParseException e = new Ice.ProxyParseException();
                e.str = "no identity in `" + s + "'";
                throw e;
            }

            //
            // Parsing the identity may raise IdentityParseException.
            //
            Ice.Identity ident = instance_.stringToIdentity(idstr);

            if (ident.name.Length == 0)
            {
                //
                // An identity with an empty name and a non-empty
                // category is illegal.
                //
                if (ident.category.Length > 0)
                {
                    Ice.IllegalIdentityException e = new Ice.IllegalIdentityException();
                    e.id = ident;
                    throw e;
                }
                //
                // Treat a stringified proxy containing two double
                // quotes ("") the same as an empty string, i.e.,
                // a null proxy, but only if nothing follows the
                // quotes.
                //
                else if (IceUtilInternal.StringUtil.findFirstNotOf(s, delim, end) != -1)
                {
                    Ice.ProxyParseException e = new Ice.ProxyParseException();
                    e.str = "invalid characters after identity in `" + s + "'";
                    throw e;
                }
                else
                {
                    return(null);
                }
            }

            string facet = "";

            Reference.Mode mode   = Reference.Mode.ModeTwoway;
            bool           secure = false;

            Ice.EncodingVersion encoding = instance_.defaultsAndOverrides().defaultEncoding;
            Ice.ProtocolVersion protocol = Ice.Util.Protocol_1_0;
            string adapter = "";

            while (true)
            {
                beg = IceUtilInternal.StringUtil.findFirstNotOf(s, delim, end);
                if (beg == -1)
                {
                    break;
                }

                if (s[beg] == ':' || s[beg] == '@')
                {
                    break;
                }

                end = IceUtilInternal.StringUtil.findFirstOf(s, delim + ":@", beg);
                if (end == -1)
                {
                    end = s.Length;
                }

                if (beg == end)
                {
                    break;
                }

                string option = s.Substring(beg, end - beg);
                if (option.Length != 2 || option[0] != '-')
                {
                    Ice.ProxyParseException e = new Ice.ProxyParseException();
                    e.str = "expected a proxy option but found `" + option + "' in `" + s + "'";
                    throw e;
                }

                //
                // Check for the presence of an option argument. The
                // argument may be enclosed in single or double
                // quotation marks.
                //
                string argument    = null;
                int    argumentBeg = IceUtilInternal.StringUtil.findFirstNotOf(s, delim, end);
                if (argumentBeg != -1)
                {
                    char ch = s[argumentBeg];
                    if (ch != '@' && ch != ':' && ch != '-')
                    {
                        beg = argumentBeg;
                        end = IceUtilInternal.StringUtil.checkQuote(s, beg);
                        if (end == -1)
                        {
                            Ice.ProxyParseException e = new Ice.ProxyParseException();
                            e.str = "mismatched quotes around value for " + option + " option in `" + s + "'";
                            throw e;
                        }
                        else if (end == 0)
                        {
                            end = IceUtilInternal.StringUtil.findFirstOf(s, delim + ":@", beg);
                            if (end == -1)
                            {
                                end = s.Length;
                            }
                            argument = s.Substring(beg, end - beg);
                        }
                        else
                        {
                            beg++; // Skip leading quote
                            argument = s.Substring(beg, end - beg);
                            end++; // Skip trailing quote
                        }
                    }
                }

                //
                // If any new options are added here,
                // IceInternal::Reference::toString() and its derived classes must be updated as well.
                //
                switch (option[1])
                {
                case 'f':
                {
                    if (argument == null)
                    {
                        Ice.ProxyParseException e = new Ice.ProxyParseException();
                        e.str = "no argument provided for -f option in `" + s + "'";
                        throw e;
                    }

                    try
                    {
                        facet = IceUtilInternal.StringUtil.unescapeString(argument, 0, argument.Length);
                    }
                    catch (System.ArgumentException argEx)
                    {
                        Ice.ProxyParseException e = new Ice.ProxyParseException();
                        e.str = "invalid facet in `" + s + "': " + argEx.Message;
                        throw e;
                    }
                    break;
                }

                case 't':
                {
                    if (argument != null)
                    {
                        Ice.ProxyParseException e = new Ice.ProxyParseException();
                        e.str = "unexpected argument `" + argument + "' provided for -t option in `" + s + "'";
                        throw e;
                    }
                    mode = Reference.Mode.ModeTwoway;
                    break;
                }

                case 'o':
                {
                    if (argument != null)
                    {
                        Ice.ProxyParseException e = new Ice.ProxyParseException();
                        e.str = "unexpected argument `" + argument + "' provided for -o option in `" + s + "'";
                        throw e;
                    }
                    mode = Reference.Mode.ModeOneway;
                    break;
                }

                case 'O':
                {
                    if (argument != null)
                    {
                        Ice.ProxyParseException e = new Ice.ProxyParseException();
                        e.str = "unexpected argument `" + argument + "' provided for -O option in `" + s + "'";
                        throw e;
                    }
                    mode = Reference.Mode.ModeBatchOneway;
                    break;
                }

                case 'd':
                {
                    if (argument != null)
                    {
                        Ice.ProxyParseException e = new Ice.ProxyParseException();
                        e.str = "unexpected argument `" + argument + "' provided for -d option in `" + s + "'";
                        throw e;
                    }
                    mode = Reference.Mode.ModeDatagram;
                    break;
                }

                case 'D':
                {
                    if (argument != null)
                    {
                        Ice.ProxyParseException e = new Ice.ProxyParseException();
                        e.str = "unexpected argument `" + argument + "' provided for -D option in `" + s + "'";
                        throw e;
                    }
                    mode = Reference.Mode.ModeBatchDatagram;
                    break;
                }

                case 's':
                {
                    if (argument != null)
                    {
                        Ice.ProxyParseException e = new Ice.ProxyParseException();
                        e.str = "unexpected argument `" + argument + "' provided for -s option in `" + s + "'";
                        throw e;
                    }
                    secure = true;
                    break;
                }

                case 'e':
                {
                    if (argument == null)
                    {
                        throw new Ice.ProxyParseException("no argument provided for -e option `" + s + "'");
                    }

                    try
                    {
                        encoding = Ice.Util.stringToEncodingVersion(argument);
                    }
                    catch (Ice.VersionParseException e)
                    {
                        throw new Ice.ProxyParseException("invalid encoding version `" + argument + "' in `" + s +
                                                          "':\n" + e.str);
                    }
                    break;
                }

                case 'p':
                {
                    if (argument == null)
                    {
                        throw new Ice.ProxyParseException("no argument provided for -p option `" + s + "'");
                    }

                    try
                    {
                        protocol = Ice.Util.stringToProtocolVersion(argument);
                    }
                    catch (Ice.VersionParseException e)
                    {
                        throw new Ice.ProxyParseException("invalid protocol version `" + argument + "' in `" + s +
                                                          "':\n" + e.str);
                    }
                    break;
                }

                default:
                {
                    Ice.ProxyParseException e = new Ice.ProxyParseException();
                    e.str = "unknown option `" + option + "' in `" + s + "'";
                    throw e;
                }
                }
            }

            if (beg == -1)
            {
                return(create(ident, facet, mode, secure, protocol, encoding, null, null, propertyPrefix));
            }

            List <EndpointI> endpoints = new List <EndpointI>();

            if (s[beg] == ':')
            {
                List <string> unknownEndpoints = new List <string>();
                end = beg;

                while (end < s.Length && s[end] == ':')
                {
                    beg = end + 1;

                    end = beg;
                    while (true)
                    {
                        end = s.IndexOf(':', end);
                        if (end == -1)
                        {
                            end = s.Length;
                            break;
                        }
                        else
                        {
                            bool quoted = false;
                            int  quote  = beg;
                            while (true)
                            {
                                quote = s.IndexOf((System.Char) '\"', quote);
                                if (quote == -1 || end < quote)
                                {
                                    break;
                                }
                                else
                                {
                                    quote = s.IndexOf((System.Char) '\"', ++quote);
                                    if (quote == -1)
                                    {
                                        break;
                                    }
                                    else if (end < quote)
                                    {
                                        quoted = true;
                                        break;
                                    }
                                    ++quote;
                                }
                            }
                            if (!quoted)
                            {
                                break;
                            }
                            ++end;
                        }
                    }

                    string    es   = s.Substring(beg, end - beg);
                    EndpointI endp = instance_.endpointFactoryManager().create(es, false);
                    if (endp != null)
                    {
                        endpoints.Add(endp);
                    }
                    else
                    {
                        unknownEndpoints.Add(es);
                    }
                }
                if (endpoints.Count == 0)
                {
                    Debug.Assert(unknownEndpoints.Count > 0);
                    Ice.EndpointParseException e2 = new Ice.EndpointParseException();
                    e2.str = "invalid endpoint `" + unknownEndpoints[0] + "' in `" + s + "'";
                    throw e2;
                }
                else if (unknownEndpoints.Count != 0 &&
                         instance_.initializationData().properties.getPropertyAsIntWithDefault(
                             "Ice.Warn.Endpoints", 1) > 0)
                {
                    StringBuilder msg = new StringBuilder("Proxy contains unknown endpoints:");
                    int           sz  = unknownEndpoints.Count;
                    for (int idx = 0; idx < sz; ++idx)
                    {
                        msg.Append(" `");
                        msg.Append((string)unknownEndpoints[idx]);
                        msg.Append("'");
                    }
                    instance_.initializationData().logger.warning(msg.ToString());
                }

                EndpointI[] ep = endpoints.ToArray();
                return(create(ident, facet, mode, secure, protocol, encoding, ep, null, propertyPrefix));
            }
            else if (s[beg] == '@')
            {
                beg = IceUtilInternal.StringUtil.findFirstNotOf(s, delim, beg + 1);
                if (beg == -1)
                {
                    Ice.ProxyParseException e = new Ice.ProxyParseException();
                    e.str = "missing adapter id in `" + s + "'";
                    throw e;
                }

                string adapterstr = null;
                end = IceUtilInternal.StringUtil.checkQuote(s, beg);
                if (end == -1)
                {
                    Ice.ProxyParseException e = new Ice.ProxyParseException();
                    e.str = "mismatched quotes around adapter id in `" + s + "'";
                    throw e;
                }
                else if (end == 0)
                {
                    end = IceUtilInternal.StringUtil.findFirstOf(s, delim, beg);
                    if (end == -1)
                    {
                        end = s.Length;
                    }
                    adapterstr = s.Substring(beg, end - beg);
                }
                else
                {
                    beg++; // Skip leading quote
                    adapterstr = s.Substring(beg, end - beg);
                    end++; // Skip trailing quote
                }

                if (end != s.Length && IceUtilInternal.StringUtil.findFirstNotOf(s, delim, end) != -1)
                {
                    Ice.ProxyParseException e = new Ice.ProxyParseException();
                    e.str = "invalid trailing characters after `" + s.Substring(0, end + 1) + "' in `" + s + "'";
                    throw e;
                }

                try
                {
                    adapter = IceUtilInternal.StringUtil.unescapeString(adapterstr, 0, adapterstr.Length);
                }
                catch (System.ArgumentException argEx)
                {
                    Ice.ProxyParseException e = new Ice.ProxyParseException();
                    e.str = "invalid adapter id in `" + s + "': " + argEx.Message;
                    throw e;
                }
                if (adapter.Length == 0)
                {
                    Ice.ProxyParseException e = new Ice.ProxyParseException();
                    e.str = "empty adapter id in `" + s + "'";
                    throw e;
                }
                return(create(ident, facet, mode, secure, protocol, encoding, null, adapter, propertyPrefix));
            }

            Ice.ProxyParseException ex = new Ice.ProxyParseException();
            ex.str = "malformed proxy `" + s + "'";
            throw ex;
        }
예제 #18
0
 internal EndpointI(IceInternal.EndpointI endpoint)
 {
     _endpoint      = endpoint;
     _configuration = Configuration.getInstance();
 }
예제 #19
0
 public InfoI(EndpointI e)
 {
     _endpoint = e;
 }
예제 #20
0
        public void resolve(string host, int port, Ice.EndpointSelectionType selType, EndpointI endpoint,
                            EndpointI_connectors callback)
        {
            //
            // Try to get the addresses without DNS lookup. If this doesn't work, we queue a resolve
            // entry and the thread will take care of getting the endpoint addresses.
            //
            NetworkProxy networkProxy = _instance.networkProxy();

            if (networkProxy == null)
            {
                try
                {
                    List <EndPoint> addrs = Network.getAddresses(host, port, _protocol, selType, _preferIPv6, false);
                    if (addrs.Count > 0)
                    {
                        callback.connectors(endpoint.connectors(addrs, null));
                        return;
                    }
                }
                catch (Ice.LocalException ex)
                {
                    callback.exception(ex);
                    return;
                }
            }

            _m.Lock();
            try
            {
                Debug.Assert(!_destroyed);

                ResolveEntry entry = new ResolveEntry();
                entry.host     = host;
                entry.port     = port;
                entry.selType  = selType;
                entry.endpoint = endpoint;
                entry.callback = callback;

                Ice.Instrumentation.CommunicatorObserver obsv = _instance.getObserver();
                if (obsv != null)
                {
                    entry.observer = obsv.getEndpointLookupObserver(endpoint);
                    if (entry.observer != null)
                    {
                        entry.observer.attach();
                    }
                }

                _queue.AddLast(entry);
                _m.Notify();
            }
            finally
            {
                _m.Unlock();
            }
        }
예제 #21
0
        //
        // Compare endpoints for sorting purposes
        //
        public override int CompareTo(EndpointI obj)
        {
            if (!(obj is OpaqueEndpointI))
            {
                return(type() < obj.type() ? -1 : 1);
            }

            OpaqueEndpointI p = (OpaqueEndpointI)obj;

            if (this == p)
            {
                return(0);
            }

            if (_type < p._type)
            {
                return(-1);
            }
            else if (p._type < _type)
            {
                return(1);
            }

            if (_rawEncoding.major < p._rawEncoding.major)
            {
                return(-1);
            }
            else if (p._rawEncoding.major < _rawEncoding.major)
            {
                return(1);
            }

            if (_rawEncoding.minor < p._rawEncoding.minor)
            {
                return(-1);
            }
            else if (p._rawEncoding.minor < _rawEncoding.minor)
            {
                return(1);
            }

            if (_rawBytes.Length < p._rawBytes.Length)
            {
                return(-1);
            }
            else if (p._rawBytes.Length < _rawBytes.Length)
            {
                return(1);
            }
            for (int i = 0; i < _rawBytes.Length; i++)
            {
                if (_rawBytes[i] < p._rawBytes[i])
                {
                    return(-1);
                }
                else if (p._rawBytes[i] < _rawBytes[i])
                {
                    return(1);
                }
            }

            return(0);
        }
예제 #22
0
 //
 // Check whether the endpoint is equivalent to another one.
 //
 public override bool equivalent(EndpointI endpoint)
 {
     return(false);
 }
예제 #23
0
 public WSEndpoint endpoint(EndpointI delEndp)
 {
     return(new WSEndpoint(_instance, delEndp, _resource));
 }
예제 #24
0
        public EndpointI create(string str, bool oaEndpoint)
        {
            string[] arr = IceUtilInternal.StringUtil.splitString(str, " \t\r\n");
            if (arr == null)
            {
                Ice.EndpointParseException e = new Ice.EndpointParseException();
                e.str = "mismatched quote";
                throw e;
            }

            if (arr.Length == 0)
            {
                Ice.EndpointParseException e = new Ice.EndpointParseException();
                e.str = "value has no non-whitespace characters";
                throw e;
            }

            List <string> v        = new List <string>(arr);
            string        protocol = v[0];

            v.RemoveAt(0);

            if (protocol.Equals("default"))
            {
                protocol = _instance.defaultsAndOverrides().defaultProtocol;
            }

            EndpointFactory factory = null;

            lock (this)
            {
                for (int i = 0; i < _factories.Count; i++)
                {
                    EndpointFactory f = _factories[i];
                    if (f.protocol().Equals(protocol))
                    {
                        factory = f;
                    }
                }
            }

            if (factory != null)
            {
                EndpointI e = factory.create(v, oaEndpoint);
                if (v.Count > 0)
                {
                    Ice.EndpointParseException ex = new Ice.EndpointParseException();
                    ex.str = "unrecognized argument `" + v[0] + "' in endpoint `" + str + "'";
                    throw ex;
                }
                return(e);

                // Code below left in place for debugging.

                /*
                 * EndpointI e = f.create(s.Substring(m.Index + m.Length), oaEndpoint);
                 * BasicStream bs = new BasicStream(_instance, true);
                 * e.streamWrite(bs);
                 * Buffer buf = bs.getBuffer();
                 * buf.b.position(0);
                 * short type = bs.readShort();
                 * EndpointI ue = new IceInternal.OpaqueEndpointI(type, bs);
                 * System.Console.Error.WriteLine("Normal: " + e);
                 * System.Console.Error.WriteLine("Opaque: " + ue);
                 * return e;
                 */
            }

            //
            // If the stringified endpoint is opaque, create an unknown endpoint,
            // then see whether the type matches one of the known endpoints.
            //
            if (protocol.Equals("opaque"))
            {
                EndpointI ue = new OpaqueEndpointI(v);
                if (v.Count > 0)
                {
                    Ice.EndpointParseException ex = new Ice.EndpointParseException();
                    ex.str = "unrecognized argument `" + v[0] + "' in endpoint `" + str + "'";
                    throw ex;
                }
                factory = get(ue.type());
                if (factory != null)
                {
                    //
                    // Make a temporary stream, write the opaque endpoint data into the stream,
                    // and ask the factory to read the endpoint data from that stream to create
                    // the actual endpoint.
                    //
                    Ice.OutputStream os = new Ice.OutputStream(_instance, Ice.Util.currentProtocolEncoding);
                    os.writeShort(ue.type());
                    ue.streamWrite(os);
                    Ice.InputStream iss =
                        new Ice.InputStream(_instance, Ice.Util.currentProtocolEncoding, os.getBuffer(), true);
                    iss.pos(0);
                    iss.readShort(); // type
                    iss.startEncapsulation();
                    EndpointI e = factory.read(iss);
                    iss.endEncapsulation();
                    return(e);
                }
                return(ue); // Endpoint is opaque, but we don't have a factory for its type.
            }

            return(null);
        }
예제 #25
0
 internal WSEndpoint(ProtocolInstance instance, EndpointI del, string res)
 {
     _instance = instance;
     _delegate = (IPEndpointI)del;
     _resource = res;
 }
예제 #26
0
파일: EndpointI.cs 프로젝트: zhoushiyi/ice
 public EndpointI endpoint(IceInternal.EndpointI delEndp)
 {
     return(new EndpointI(delEndp));
 }
예제 #27
0
 override protected EndpointI createWithUnderlying(EndpointI underlying, List <string> args, bool oaEndpoint)
 {
     return(new WSEndpoint(instance_, underlying, args));
 }
예제 #28
0
        internal ConnectionI(Communicator communicator, IceInternal.Instance instance,
                             IceInternal.ACMMonitor monitor, IceInternal.Transceiver transceiver,
                             IceInternal.Connector connector, IceInternal.EndpointI endpoint, ObjectAdapterI adapter)
        {
            _communicator = communicator;
            _instance = instance;
            _monitor = monitor;
            _transceiver = transceiver;
            _desc = transceiver.ToString();
            _type = transceiver.protocol();
            _connector = connector;
            _endpoint = endpoint;
            _adapter = adapter;
            InitializationData initData = instance.initializationData();
            _logger = initData.logger; // Cached for better performance.
            _traceLevels = instance.traceLevels(); // Cached for better performance.
            _timer = instance.timer();
            _writeTimeout = new TimeoutCallback(this);
            _writeTimeoutScheduled = false;
            _readTimeout = new TimeoutCallback(this);
            _readTimeoutScheduled = false;
            _warn = initData.properties.getPropertyAsInt("Ice.Warn.Connections") > 0;
            _warnUdp = initData.properties.getPropertyAsInt("Ice.Warn.Datagrams") > 0;
            _cacheBuffers = instance.cacheMessageBuffers() > 0;
            if(_monitor != null && _monitor.getACM().timeout > 0)
            {
                _acmLastActivity = IceInternal.Time.currentMonotonicTimeMillis();
            }
            else
            {
                _acmLastActivity = -1;
            }
            _nextRequestId = 1;
            _messageSizeMax = adapter != null ? adapter.messageSizeMax() : instance.messageSizeMax();
            _batchRequestQueue = new IceInternal.BatchRequestQueue(instance, _endpoint.datagram());
            _readStream = new InputStream(instance, Util.currentProtocolEncoding);
            _readHeader = false;
            _readStreamPos = -1;
            _writeStream = new OutputStream(instance, Util.currentProtocolEncoding);
            _writeStreamPos = -1;
            _dispatchCount = 0;
            _state = StateNotInitialized;

            _compressionLevel = initData.properties.getPropertyAsIntWithDefault("Ice.Compression.Level", 1);
            if(_compressionLevel < 1)
            {
                _compressionLevel = 1;
            }
            else if(_compressionLevel > 9)
            {
                _compressionLevel = 9;
            }

            if(adapter != null)
            {
                _servantManager = adapter.getServantManager();
            }

            try
            {
                if(adapter != null)
                {
                    _threadPool = adapter.getThreadPool();
                }
                else
                {
                    _threadPool = instance.clientThreadPool();
                }
                _threadPool.initialize(this);
            }
            catch(LocalException)
            {
                throw;
            }
            catch(System.Exception ex)
            {
                throw new SyscallException(ex);
            }
        }
예제 #29
0
 abstract protected EndpointI createWithUnderlying(EndpointI underlying, List <string> args, bool oaEndpoint);
예제 #30
0
 //
 // Return a server side transceiver for this endpoint, or null if a
 // transceiver can only be created by an acceptor. In case a
 // transceiver is created, this operation also returns a new
 // "effective" endpoint, which might differ from this endpoint,
 // for example, if a dynamic port number is assigned.
 //
 public override Transceiver transceiver(ref EndpointI endpoint)
 {
     endpoint = this;
     return(null);
 }
예제 #31
0
 abstract protected EndpointI readWithUnderlying(EndpointI underlying, Ice.InputStream s);