public ConnectionRequestHandler(Reference @ref, Ice.ObjectPrx proxy) { _reference = @ref; _response = _reference.getMode() == Reference.Mode.ModeTwoway; _connection = _reference.getConnection(out _compress); // // If this proxy is for a non-local object, and we are using a router, then // add this proxy to the router info object. // IceInternal.RouterInfo ri = _reference.getRouterInfo(); if (ri != null) { ri.addProxy(proxy); } }
// // Only for use by IceInternal.ObjectAdapterFactory // public ObjectAdapterI(IceInternal.Instance instance, Communicator communicator, IceInternal.ObjectAdapterFactory objectAdapterFactory, string name, RouterPrx router, bool noConfig) { _deactivated = false; instance_ = instance; _communicator = communicator; _objectAdapterFactory = objectAdapterFactory; _hasAcmTimeout = false; _acmTimeout = 0; _servantManager = new IceInternal.ServantManager(instance, name); _activateOneOffDone = false; _name = name; _incomingConnectionFactories = new List<IceInternal.IncomingConnectionFactory>(); _publishedEndpoints = new List<IceInternal.EndpointI>(); _routerEndpoints = new List<IceInternal.EndpointI>(); _routerInfo = null; _directCount = 0; _waitForActivate = false; _waitForHold = 0; _waitForHoldRetry = false; _noConfig = noConfig; _processId = null; if(_noConfig) { _id = ""; _replicaGroupId = ""; _reference = instance_.referenceFactory().create("dummy -t", ""); 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. // _deactivated = true; 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; } try { int threadPoolSize = properties.getPropertyAsInt(_name + ".ThreadPool.Size"); int threadPoolSizeMax = properties.getPropertyAsInt(_name + ".ThreadPool.SizeMax"); if(threadPoolSize > 0 || threadPoolSizeMax > 0) { _threadPool = new IceInternal.ThreadPool(instance_, _name + ".ThreadPool", 0); } _hasAcmTimeout = properties.getProperty(_name + ".ACM").Length > 0; if(_hasAcmTimeout) { _acmTimeout = properties.getPropertyAsInt(_name + ".ACM"); instance_.connectionMonitor().checkIntervalForACM(_acmTimeout); } 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 = instance_.identityToString(router.ice_getIdentity()); throw ex; } // // Add the router's server proxy endpoints to this object // adapter. // IceInternal.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;) { IceInternal.EndpointI e1 = _routerEndpoints[i]; IceInternal.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<IceInternal.EndpointI> endpoints = parseEndpoints(properties.getProperty(_name + ".Endpoints"), true); foreach(IceInternal.EndpointI endp in endpoints) { IceInternal.IncomingConnectionFactory factory = new IceInternal.IncomingConnectionFactory(instance, endp, this, _name); _incomingConnectionFactories.Add(factory); } if(endpoints.Count == 0) { IceInternal.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; } }
public void destroy() { _m.Lock(); try { // // Another thread is in the process of destroying the object // adapter. Wait for it to finish. // while(_destroying) { _m.Wait(); } // // Object adpater is already destroyed. // if(_destroyed) { return; } _destroying = true; } finally { _m.Unlock(); } // // Deactivate and wait for completion. // deactivate(); waitForDeactivate(); // // 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(); } IceInternal.ObjectAdapterFactory objectAdapterFactory; _m.Lock(); try { // // Signal that destroying is complete. // _destroying = false; _destroyed = true; _m.NotifyAll(); // // 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; _routerEndpoints = null; _routerInfo = null; _publishedEndpoints = null; _locatorInfo = null; _reference = null; objectAdapterFactory = _objectAdapterFactory; _objectAdapterFactory = null; } finally { _m.Unlock(); } if(objectAdapterFactory != null) { objectAdapterFactory.removeObjectAdapter(this); } }