internal WSEndpoint(ProtocolInstance instance, EndpointI del, BasicStream s) { _instance = instance; _delegate = (IPEndpointI)del; _resource = s.readString(); }
public Reference create(Ice.Identity ident, string facet, Reference tmpl, EndpointI[] endpoints) { if(ident.name.Length == 0 && ident.category.Length == 0) { return null; } return create(ident, facet, tmpl.getMode(), tmpl.getSecure(), endpoints, null, null); }
public List<Connector> resolve(string host, int port, Ice.EndpointSelectionType selType, EndpointI endpoint) { // // Try to get the addresses without DNS lookup. If this doesn't // work, we retry with DNS lookup (and observer). // NetworkProxy networkProxy = _instance.networkProxy(); if(networkProxy == null) { List<EndPoint> addrs = Network.getAddresses(host, port, _protocol, selType, _preferIPv6, false); if(addrs.Count > 0) { return endpoint.connectors(addrs, null); } } Ice.Instrumentation.CommunicatorObserver obsv = _instance.getObserver(); Ice.Instrumentation.Observer observer = null; if(obsv != null) { observer = obsv.getEndpointLookupObserver(endpoint); if(observer != null) { observer.attach(); } } List<Connector> connectors = null; try { if(networkProxy != null) { networkProxy = networkProxy.resolveHost(); } connectors = endpoint.connectors(Network.getAddresses(host, port, _protocol, selType, _preferIPv6, true), networkProxy); } catch(Ice.LocalException ex) { if(observer != null) { observer.failed(ex.ice_name()); } throw ex; } finally { if(observer != null) { observer.detach(); } } return connectors; }
public void destroy() { lock(this) { _clientEndpoints = new EndpointI[0]; _serverEndpoints = new EndpointI[0]; _adapter = null; _identities.Clear(); } }
public IceInternal.EndpointI read(Ice.InputStream s) { short type = s.readShort(); Debug.Assert(type == _factory.type()); s.startEncapsulation(); IceInternal.EndpointI endpoint = new EndpointI(_factory.read(s)); s.endEncapsulation(); return endpoint; }
public IceInternal.EndpointI read(IceInternal.BasicStream s) { short type = s.readShort(); Debug.Assert(type == _factory.type()); s.startReadEncaps(); IceInternal.EndpointI endpoint = new EndpointI(_factory.read(s)); s.endReadEncaps(); return endpoint; }
internal WSEndpoint(ProtocolInstance instance, EndpointI del, List<string> args) { _instance = instance; _delegate = (IPEndpointI)del; initWithOptions(args); if(_resource == null) { _resource = "/"; } }
internal AcceptorI(EndpointI endpoint, Instance instance, IceInternal.Acceptor del, string adapterName) { _endpoint = endpoint; _delegate = del; _instance = instance; _adapterName = adapterName; // // .NET requires that a certificate be supplied. // if (instance.certs().Count == 0) { Ice.SecurityException ex = new Ice.SecurityException(); ex.reason = "IceSSL: certificate required for server endpoint"; throw ex; } }
// // 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); } }
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); }
// // Return an acceptor for this endpoint, or null if no acceptors // is available. In case an acceptor 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 Acceptor acceptor(ref EndpointI endpoint, string adapterName) { #if SILVERLIGHT throw new Ice.FeatureNotSupportedException("server endpoint not supported for `" + ToString() + "'"); #else TcpAcceptor p = new TcpAcceptor(_instance, _host, _port); endpoint = new TcpEndpointI(_instance, _host, p.effectivePort(), _timeout, connectionId_, _compress); return p; #endif }
public InfoI(EndpointI e) { _endpoint = e; }
// // Only for use by ObjectAdapterFactory // public ObjectAdapterI(Instance instance, Communicator communicator, ObjectAdapterFactory objectAdapterFactory, string name, RouterPrx router, bool noConfig) { instance_ = instance; _communicator = communicator; _objectAdapterFactory = objectAdapterFactory; _servantManager = new ServantManager(instance, name); _name = name; _incomingConnectionFactories = new List <IncomingConnectionFactory>(); _publishedEndpoints = new List <EndpointI>(); _routerEndpoints = new List <EndpointI>(); _routerInfo = null; _directCount = 0; _noConfig = noConfig; if (_noConfig) { _id = ""; _replicaGroupId = ""; _reference = instance_.referenceFactory().create("dummy -t", ""); _acm = instance_.serverACM(); return; } Properties properties = instance_.initializationData().properties; List <string> unknownProps = new List <string>(); bool noProps = filterProperties(unknownProps); // // Warn about unknown object adapter properties. // if (unknownProps.Count != 0 && properties.getPropertyAsIntWithDefault("Ice.Warn.UnknownProperties", 1) > 0) { StringBuilder message = new StringBuilder("found unknown properties for object adapter `"); message.Append(_name); message.Append("':"); foreach (string s in unknownProps) { message.Append("\n "); message.Append(s); } instance_.initializationData().logger.warning(message.ToString()); } // // Make sure named adapter has configuration. // if (router == null && noProps) { // // These need to be set to prevent warnings/asserts in the destructor. // state_ = StateDestroyed; instance_ = null; _incomingConnectionFactories = null; InitializationException ex = new InitializationException(); ex.reason = "object adapter `" + _name + "' requires configuration"; throw ex; } _id = properties.getProperty(_name + ".AdapterId"); _replicaGroupId = properties.getProperty(_name + ".ReplicaGroupId"); // // Setup a reference to be used to get the default proxy options // when creating new proxies. By default, create twoway proxies. // string proxyOptions = properties.getPropertyWithDefault(_name + ".ProxyOptions", "-t"); try { _reference = instance_.referenceFactory().create("dummy " + proxyOptions, ""); } catch (ProxyParseException) { InitializationException ex = new InitializationException(); ex.reason = "invalid proxy options `" + proxyOptions + "' for object adapter `" + _name + "'"; throw ex; } _acm = new ACMConfig(properties, communicator.getLogger(), _name + ".ACM", instance_.serverACM()); { int defaultMessageSizeMax = instance.messageSizeMax() / 1024; int num = properties.getPropertyAsIntWithDefault(_name + ".MessageSizeMax", defaultMessageSizeMax); if (num < 1 || num > 0x7fffffff / 1024) { _messageSizeMax = 0x7fffffff; } else { _messageSizeMax = num * 1024; // Property is in kilobytes, _messageSizeMax in bytes } } try { int threadPoolSize = properties.getPropertyAsInt(_name + ".ThreadPool.Size"); int threadPoolSizeMax = properties.getPropertyAsInt(_name + ".ThreadPool.SizeMax"); if (threadPoolSize > 0 || threadPoolSizeMax > 0) { _threadPool = new ThreadPool(instance_, _name + ".ThreadPool", 0); } if (router == null) { router = RouterPrxHelper.uncheckedCast( instance_.proxyFactory().propertyToProxy(_name + ".Router")); } if (router != null) { _routerInfo = instance_.routerManager().get(router); if (_routerInfo != null) { // // Make sure this router is not already registered with another adapter. // if (_routerInfo.getAdapter() != null) { Ice.AlreadyRegisteredException ex = new Ice.AlreadyRegisteredException(); ex.kindOfObject = "object adapter with router"; ex.id = Ice.Util.identityToString(router.ice_getIdentity()); throw ex; } // // Add the router's server proxy endpoints to this object // adapter. // EndpointI[] endpoints = _routerInfo.getServerEndpoints(); for (int i = 0; i < endpoints.Length; ++i) { _routerEndpoints.Add(endpoints[i]); } _routerEndpoints.Sort(); // Must be sorted. // // Remove duplicate endpoints, so we have a list of unique endpoints. // for (int i = 0; i < _routerEndpoints.Count - 1;) { EndpointI e1 = _routerEndpoints[i]; EndpointI e2 = _routerEndpoints[i + 1]; if (e1.Equals(e2)) { _routerEndpoints.RemoveAt(i); } else { ++i; } } // // Associate this object adapter with the router. This way, // new outgoing connections to the router's client proxy will // use this object adapter for callbacks. // _routerInfo.setAdapter(this); // // Also modify all existing outgoing connections to the // router's client proxy to use this object adapter for // callbacks. // instance_.outgoingConnectionFactory().setRouterInfo(_routerInfo); } } else { // // Parse the endpoints, but don't store them in the adapter. The connection // factory might change it, for example, to fill in the real port number. // List <EndpointI> endpoints = parseEndpoints(properties.getProperty(_name + ".Endpoints"), true); foreach (EndpointI endp in endpoints) { IncomingConnectionFactory factory = new IncomingConnectionFactory(instance, endp, this); _incomingConnectionFactories.Add(factory); } if (endpoints.Count == 0) { TraceLevels tl = instance_.traceLevels(); if (tl.network >= 2) { instance_.initializationData().logger.trace(tl.networkCat, "created adapter `" + _name + "' without endpoints"); } } // // Parse published endpoints. // _publishedEndpoints = parsePublishedEndpoints(); } if (properties.getProperty(_name + ".Locator").Length > 0) { setLocator(LocatorPrxHelper.uncheckedCast( instance_.proxyFactory().propertyToProxy(_name + ".Locator"))); } else { setLocator(instance_.referenceFactory().getDefaultLocator()); } } catch (LocalException) { destroy(); throw; } }
internal Acceptor(EndpointI endpoint, IceInternal.Acceptor acceptor) { _endpoint = endpoint; _acceptor = acceptor; }
private ObjectPrx newDirectProxy(Identity ident, string facet) { EndpointI[] endpoints; // // Use the published endpoints, otherwise use the endpoints from all // incoming connection factories. // int sz = _publishedEndpoints.Count; endpoints = new EndpointI[sz + _routerEndpoints.Count]; for(int i = 0; i < sz; ++i) { endpoints[i] = _publishedEndpoints[i]; } // // Now we also add the endpoints of the router's server proxy, if // any. This way, object references created by this object adapter // will also point to the router's server proxy endpoints. // for(int i = 0; i < _routerEndpoints.Count; ++i) { endpoints[sz + i] = _routerEndpoints[i]; } // // Create a reference and return a proxy for this reference. // Reference reference = instance_.referenceFactory().create(ident, facet, _reference, endpoints); return instance_.proxyFactory().referenceToProxy(reference); }
// // Check whether the endpoint is equivalent to another one. // public override bool equivalent(EndpointI endpoint) { return false; }
// // 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 = null; return null; }
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; }
public override int CompareTo(EndpointI obj) { if(!(obj is TcpEndpointI)) { return type() < obj.type() ? -1 : 1; } TcpEndpointI p = (TcpEndpointI)obj; if(this == p) { return 0; } if(_timeout < p._timeout) { return -1; } else if(p._timeout < _timeout) { return 1; } if(!_compress && p._compress) { return -1; } else if(!p._compress && _compress) { return 1; } return base.CompareTo(p); }
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); }
public WSEndpoint endpoint(EndpointI delEndp) { return new WSEndpoint(_instance, delEndp, _resource); }
internal WSEndpoint(ProtocolInstance instance, EndpointI del, string res) { _instance = instance; _delegate = (IPEndpointI)del; _resource = res; }
// // Check whether the endpoint is equivalent to another one. // public override bool equivalent(EndpointI endpoint) { if(!(endpoint is TcpEndpointI)) { return false; } TcpEndpointI tcpEndpointI = (TcpEndpointI)endpoint; return tcpEndpointI._host.Equals(_host) && tcpEndpointI._port == _port; }
// // Compare endpoints for sorting purposes // public override int CompareTo(EndpointI obj) { if(!(obj is TcpEndpointI)) { return type() < obj.type() ? -1 : 1; } TcpEndpointI p = (TcpEndpointI)obj; if(this == p) { return 0; } else { int r = base.CompareTo(p); if(r != 0) { return r; } } if(_port < p._port) { return -1; } else if(p._port < _port) { return 1; } if(_timeout < p._timeout) { return -1; } else if(p._timeout < _timeout) { return 1; } if(!_compress && p._compress) { return -1; } else if(!p._compress && _compress) { return 1; } return string.Compare(_host, p._host, StringComparison.Ordinal); }
// // 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; } }
// // Return an acceptor for this endpoint, or null if no acceptors // is available. In case an acceptor 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 Acceptor acceptor(ref EndpointI endpoint, string adapterName) { endpoint = null; return null; }
private void getEndpointsTrace(Reference @ref, EndpointI[] endpoints, bool cached) { if(endpoints != null && endpoints.Length > 0) { if(cached) { trace("found endpoints in locator table", @ref, endpoints); } else { trace("retrieved endpoints from locator, adding to locator table", @ref, endpoints); } } else { Instance instance = @ref.getInstance(); System.Text.StringBuilder s = new System.Text.StringBuilder(); s.Append("no endpoints configured for "); if(@ref.getAdapterId().Length > 0) { s.Append("adapter\n"); s.Append("adapter = " + @ref.getAdapterId()); } else { s.Append("object\n"); s.Append("object = " + instance.identityToString(@ref.getIdentity())); } instance.initializationData().logger.trace(instance.traceLevels().locationCat, s.ToString()); } }
// // 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; }
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); }
public override bool equivalent(EndpointI endpoint) { if(!(endpoint is IPEndpointI)) { return false; } IPEndpointI ipEndpointI = (IPEndpointI)endpoint; return ipEndpointI.type() == type() && ipEndpointI.host_.Equals(host_) && ipEndpointI.port_ == port_ && Network.addressEquals(ipEndpointI.sourceAddr_, sourceAddr_); }
public void destroy() { // // Deactivate and wait for completion. // deactivate(); waitForDeactivate(); lock (this) { // // Only a single thread is allowed to destroy the object // adapter. Other threads wait for the destruction to be // completed. // while (_state == StateDestroying) { System.Threading.Monitor.Wait(this); } if (_state == StateDestroyed) { return; } _state = StateDestroying; } // // Now it's also time to clean up our servants and servant // locators. // _servantManager.destroy(); // // Destroy the thread pool. // if (_threadPool != null) { _threadPool.destroy(); _threadPool.joinWithAllThreads(); } if (_objectAdapterFactory != null) { _objectAdapterFactory.removeObjectAdapter(this); } lock (this) { // // We're done, now we can throw away all incoming connection // factories. // _incomingConnectionFactories.Clear(); // // Remove object references (some of them cyclic). // _instance = null; _threadPool = null; _routerInfo = null; _publishedEndpoints = new EndpointI[0]; _locatorInfo = null; _reference = null; _objectAdapterFactory = null; _state = StateDestroyed; System.Threading.Monitor.PulseAll(this); } }
private List <EndpointI> parseEndpoints(string endpts, bool oaEndpoints) { int beg; int end = 0; string delim = " \t\n\r"; List <EndpointI> endpoints = new List <EndpointI>(); while (end < endpts.Length) { beg = IceUtilInternal.StringUtil.findFirstNotOf(endpts, delim, end); if (beg == -1) { break; } end = beg; while (true) { end = endpts.IndexOf((System.Char) ':', end); if (end == -1) { end = endpts.Length; break; } else { bool quoted = false; int quote = beg; while (true) { quote = endpts.IndexOf((System.Char) '\"', quote); if (quote == -1 || end < quote) { break; } else { quote = endpts.IndexOf((System.Char) '\"', ++quote); if (quote == -1) { break; } else if (end < quote) { quoted = true; break; } ++quote; } } if (!quoted) { break; } ++end; } } if (end == beg) { ++end; continue; } string s = endpts.Substring(beg, (end) - (beg)); EndpointI endp = instance_.endpointFactoryManager().create(s, oaEndpoints); if (endp == null) { Ice.EndpointParseException e2 = new Ice.EndpointParseException(); e2.str = "invalid object adapter endpoint `" + s + "'"; throw e2; } endpoints.Add(endp); ++end; } return(endpoints); }
private Reference create(Ice.Identity ident, string facet, Reference.Mode mode, bool secure, EndpointI[] endpoints, string adapterId, string propertyPrefix) { DefaultsAndOverrides defaultsAndOverrides = instance_.defaultsAndOverrides(); // // Default local proxy options. // LocatorInfo locatorInfo = instance_.locatorManager().get(_defaultLocator); RouterInfo routerInfo = instance_.routerManager().get(_defaultRouter); bool collocOptimized = defaultsAndOverrides.defaultCollocationOptimization; bool cacheConnection = true; bool preferSecure = defaultsAndOverrides.defaultPreferSecure; Ice.EndpointSelectionType endpointSelection = defaultsAndOverrides.defaultEndpointSelection; int locatorCacheTimeout = defaultsAndOverrides.defaultLocatorCacheTimeout; // // Override the defaults with the proxy properties if a property prefix is defined. // if(propertyPrefix != null && propertyPrefix.Length > 0) { Ice.Properties properties = instance_.initializationData().properties; // // Warn about unknown properties. // if(properties.getPropertyAsIntWithDefault("Ice.Warn.UnknownProperties", 1) > 0) { checkForUnknownProperties(propertyPrefix); } string property; property = propertyPrefix + ".Locator"; Ice.LocatorPrx locator = Ice.LocatorPrxHelper.uncheckedCast(_communicator.propertyToProxy(property)); if(locator != null) { locatorInfo = instance_.locatorManager().get(locator); } property = propertyPrefix + ".Router"; Ice.RouterPrx router = Ice.RouterPrxHelper.uncheckedCast(_communicator.propertyToProxy(property)); if(router != null) { if(propertyPrefix.EndsWith(".Router", StringComparison.Ordinal)) { string s = "`" + property + "=" + properties.getProperty(property) + "': cannot set a router on a router; setting ignored"; instance_.initializationData().logger.warning(s); } else { routerInfo = instance_.routerManager().get(router); } } property = propertyPrefix + ".CollocationOptimized"; collocOptimized = properties.getPropertyAsIntWithDefault(property, collocOptimized ? 1 : 0) > 0; property = propertyPrefix + ".ConnectionCached"; cacheConnection = properties.getPropertyAsIntWithDefault(property, cacheConnection ? 1 : 0) > 0; property = propertyPrefix + ".PreferSecure"; preferSecure = properties.getPropertyAsIntWithDefault(property, preferSecure ? 1 : 0) > 0; property = propertyPrefix + ".EndpointSelection"; if(properties.getProperty(property).Length > 0) { string type = properties.getProperty(property); if(type.Equals("Random")) { endpointSelection = Ice.EndpointSelectionType.Random; } else if(type.Equals("Ordered")) { endpointSelection = Ice.EndpointSelectionType.Ordered; } else { throw new Ice.EndpointSelectionTypeParseException("illegal value `" + type + "'; expected `Random' or `Ordered'"); } } property = propertyPrefix + ".LocatorCacheTimeout"; locatorCacheTimeout = properties.getPropertyAsIntWithDefault(property, locatorCacheTimeout); } // // Create new reference // return updateCache(new RoutableReference(instance_, _communicator, ident, facet, mode, secure, endpoints, adapterId, locatorInfo, routerInfo, collocOptimized, cacheConnection, preferSecure, endpointSelection, locatorCacheTimeout)); }
private void trace(string msg, Reference r, EndpointI[] endpoints) { System.Text.StringBuilder s = new System.Text.StringBuilder(); s.Append(msg + "\n"); if(r.getAdapterId().Length > 0) { s.Append("adapter = " + r.getAdapterId() + "\n"); } else { s.Append("object = " + r.getInstance().identityToString(r.getIdentity()) + "\n"); } s.Append("endpoints = "); int sz = endpoints.Length; for (int i = 0; i < sz; i++) { s.Append(endpoints[i].ToString()); if(i + 1 < sz) { s.Append(":"); } } r.getInstance().initializationData().logger.trace(r.getInstance().traceLevels().locationCat, s.ToString()); }
public override bool equivalent(EndpointI endpoint) { if(!(endpoint is WSEndpoint)) { return false; } WSEndpoint wsEndpointI = (WSEndpoint)endpoint; return _delegate.equivalent(wsEndpointI._delegate); }