diff options
Diffstat (limited to 'csharp/src')
-rw-r--r-- | csharp/src/Ice/ObjectAdapterI.cs | 154 |
1 files changed, 81 insertions, 73 deletions
diff --git a/csharp/src/Ice/ObjectAdapterI.cs b/csharp/src/Ice/ObjectAdapterI.cs index c6794a1a4db..bc818bce88e 100644 --- a/csharp/src/Ice/ObjectAdapterI.cs +++ b/csharp/src/Ice/ObjectAdapterI.cs @@ -41,7 +41,7 @@ namespace Ice lock(this) { checkForDeactivation(); - + // // If we've previously been initialized we just need to activate the // incoming connection factories and we're done. @@ -72,7 +72,7 @@ namespace Ice printAdapterReady = properties.getPropertyAsInt("Ice.PrintAdapterReady") > 0; } } - + try { Ice.Identity dummy = new Ice.Identity(); @@ -94,7 +94,7 @@ namespace Ice } throw; } - + if(printAdapterReady) { System.Console.Out.WriteLine(_name + " ready"); @@ -102,8 +102,8 @@ namespace Ice lock(this) { - Debug.Assert(state_ == StateActivating); - + Debug.Assert(state_ == StateActivating); + foreach(IncomingConnectionFactory icf in _incomingConnectionFactories) { icf.activate(); @@ -113,7 +113,7 @@ namespace Ice System.Threading.Monitor.PulseAll(this); } } - + public void hold() { lock(this) @@ -126,14 +126,14 @@ namespace Ice } } } - + public void waitForHold() { List<IncomingConnectionFactory> incomingConnectionFactories; lock(this) { checkForDeactivation(); - + incomingConnectionFactories = new List<IncomingConnectionFactory>(_incomingConnectionFactories); } @@ -142,14 +142,14 @@ namespace Ice factory.waitUntilHolding(); } } - + public void deactivate() { lock(this) { // // - // Wait for activation to complete. This is necessary to not + // Wait for activation to complete. This is necessary to not // get out of order locator updates. // while(state_ == StateActivating || state_ == StateDeactivating) @@ -174,13 +174,13 @@ namespace Ice // Remove entry from the router manager. // instance_.routerManager().erase(_routerInfo.getRouter()); - + // // Clear this object adapter with the router. // _routerInfo.setAdapter(null); } - + try { updateLocatorRegistry(_locatorInfo, null, false); @@ -217,7 +217,7 @@ namespace Ice System.Threading.Monitor.PulseAll(this); } } - + public void waitForDeactivate() { IncomingConnectionFactory[] incomingConnectionFactories = null; @@ -236,10 +236,10 @@ namespace Ice { return; } - + incomingConnectionFactories = _incomingConnectionFactories.ToArray(); } - + // // Now we wait for until all incoming connection factories are // finished. @@ -289,7 +289,7 @@ namespace Ice // locators. // _servantManager.destroy(); - + // // Destroy the thread pool. // @@ -298,7 +298,7 @@ namespace Ice _threadPool.destroy(); _threadPool.joinWithAllThreads(); } - + if(_objectAdapterFactory != null) { _objectAdapterFactory.removeObjectAdapter(this); @@ -311,7 +311,7 @@ namespace Ice // factories. // _incomingConnectionFactories.Clear(); - + // // Remove object references (some of them cyclic). // @@ -355,7 +355,7 @@ namespace Ice return newProxy(id, facet); } } - + public ObjectPrx addWithUUID(Ice.Object obj) { return addFacetWithUUID(obj, ""); @@ -366,7 +366,7 @@ namespace Ice Identity ident = new Identity(); ident.category = ""; ident.name = Guid.NewGuid().ToString(); - + return addFacet(obj, ident, facet); } @@ -381,7 +381,7 @@ namespace Ice _servantManager.addDefaultServant(servant, category); } } - + public Ice.Object remove(Identity ident) { return removeFacet(ident, ""); @@ -393,7 +393,7 @@ namespace Ice { checkForDeactivation(); checkIdentity(ident); - + return _servantManager.removeServant(ident, facet); } } @@ -456,7 +456,7 @@ namespace Ice return findFacet(@ref.getIdentity(), @ref.getFacet()); } } - + public Ice.Object findDefaultServant(string category) { lock(this) @@ -472,7 +472,7 @@ namespace Ice lock(this) { checkForDeactivation(); - + _servantManager.addServantLocator(locator, prefix); } } @@ -482,60 +482,60 @@ namespace Ice lock(this) { checkForDeactivation(); - + return _servantManager.removeServantLocator(prefix); } } - + public ServantLocator findServantLocator(string prefix) { lock(this) { checkForDeactivation(); - + return _servantManager.findServantLocator(prefix); } } - + public ObjectPrx createProxy(Identity ident) { lock(this) { checkForDeactivation(); checkIdentity(ident); - + return newProxy(ident, ""); } } - + public ObjectPrx createDirectProxy(Identity ident) { lock(this) { checkForDeactivation(); checkIdentity(ident); - + return newDirectProxy(ident, ""); } } - + public ObjectPrx createIndirectProxy(Identity ident) { lock(this) { checkForDeactivation(); checkIdentity(ident); - + return newIndirectProxy(ident, "", _id); } } - + public void setLocator(LocatorPrx locator) { lock(this) { checkForDeactivation(); - + _locatorInfo = instance_.locatorManager().get(locator); } } @@ -545,7 +545,7 @@ namespace Ice lock(this) { checkForDeactivation(); - + if(_locatorInfo == null) { return null; @@ -621,7 +621,7 @@ namespace Ice public bool isLocal(ObjectPrx proxy) { // - // NOTE: it's important that isLocal() doesn't perform any blocking operations as + // NOTE: it's important that isLocal() doesn't perform any blocking operations as // it can be called for AMI invocations if the proxy has no delegate set yet. // @@ -645,7 +645,7 @@ namespace Ice else { EndpointI[] endpoints = r.getEndpoints(); - + lock(this) { checkForDeactivation(); @@ -672,7 +672,7 @@ namespace Ice } } } - + // // Proxies which have at least one endpoint in common with the // router's server proxy endpoints (if any), are also considered @@ -691,7 +691,7 @@ namespace Ice } } } - + return false; } } @@ -724,7 +724,7 @@ namespace Ice p.updateConnectionObservers(); } } - + public void updateThreadObservers() { ThreadPool threadPool = null; @@ -744,20 +744,20 @@ namespace Ice lock(this) { checkForDeactivation(); - + Debug.Assert(_directCount >= 0); ++_directCount; } } - + public void decDirectCount() { lock(this) { // Not check for deactivation here! - + Debug.Assert(instance_ != null); // Must not be called after destroy(). - + Debug.Assert(_directCount > 0); if(--_directCount == 0) { @@ -765,17 +765,17 @@ namespace Ice } } } - + public ThreadPool getThreadPool() { // No mutex lock necessary, _threadPool and instance_ are // immutable after creation until they are removed in // destroy(). - + // Not check for deactivation here! - + Debug.Assert(instance_ != null); // Must not be called after destroy(). - + if(_threadPool != null) { return _threadPool; @@ -784,7 +784,7 @@ namespace Ice { return instance_.serverThreadPool(); } - + } public ServantManager getServantManager() @@ -798,7 +798,7 @@ namespace Ice public ACMConfig getACM() { // Not check for deactivation here! - + Debug.Assert(instance_ != null); // Must not be called after destroy(). return _acm; } @@ -813,7 +813,7 @@ namespace Ice // Only for use by ObjectAdapterFactory // public ObjectAdapterI(Instance instance, Communicator communicator, - ObjectAdapterFactory objectAdapterFactory, string name, + ObjectAdapterFactory objectAdapterFactory, string name, RouterPrx router, bool noConfig) { instance_ = instance; @@ -828,7 +828,7 @@ namespace Ice _directCount = 0; _noConfig = noConfig; _processId = null; - + if(_noConfig) { _id = ""; @@ -877,7 +877,7 @@ namespace Ice _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. @@ -973,12 +973,12 @@ namespace Ice // 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); } } @@ -1003,7 +1003,7 @@ namespace Ice "' without endpoints"); } } - + // // Parse published endpoints. // @@ -1026,7 +1026,7 @@ namespace Ice throw; } } - + /* ~ObjectAdapterI() { @@ -1072,12 +1072,12 @@ namespace Ice return newIndirectProxy(ident, facet, _replicaGroupId); } } - + private ObjectPrx newDirectProxy(Identity ident, string facet) { EndpointI[] endpoints; - // + // // Use the published endpoints, otherwise use the endpoints from all // incoming connection factories. // @@ -1097,14 +1097,14 @@ namespace Ice { 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); } - + private ObjectPrx newIndirectProxy(Identity ident, string facet, string id) { // @@ -1124,13 +1124,13 @@ namespace Ice throw ex; } } - + private static void checkIdentity(Identity ident) { if(ident.name == null || ident.name.Length == 0) { throw new IllegalIdentityException(ident); - } + } if(ident.category == null) { ident.category = ""; @@ -1294,7 +1294,7 @@ namespace Ice } // - // Call on the locator registry outside the synchronization to + // Call on the locator registry outside the synchronization to // blocking other threads that need to lock this OA. // LocatorRegistryPrx locatorRegistry = locatorInfo != null ? locatorInfo.getLocatorRegistry() : null; @@ -1312,7 +1312,7 @@ namespace Ice else if(serverId.Length == 0) { instance_.initializationData().logger.warning( - "object adapter `" + getName() + + "object adapter `" + getName() + "' cannot register the process without a value for Ice.ServerId"); } } @@ -1359,7 +1359,7 @@ namespace Ice s.Append("the replica group `" + _replicaGroupId + "' is not known to the locator registry"); instance_.initializationData().logger.trace(instance_.traceLevels().locationCat, s.ToString()); } - + NotRegisteredException ex1 = new NotRegisteredException(); ex1.kindOfObject = "replica group"; ex1.id = _replicaGroupId; @@ -1379,6 +1379,14 @@ namespace Ice ex1.id = _id; throw; } + catch(ObjectAdapterDeactivatedException) + { + // Expected if collocated call and OA is deactivated, ignore. + } + catch(CommunicatorDestroyedException) + { + // Ignore + } catch(LocalException e) { if(instance_.traceLevels().location >= 1) @@ -1411,7 +1419,7 @@ namespace Ice instance_.initializationData().logger.trace(instance_.traceLevels().locationCat, s.ToString()); } } - + if(registerProcess && serverId.Length > 0) { lock(this) @@ -1453,7 +1461,7 @@ namespace Ice } throw; // TODO: Shall we raise a special exception instead of a non obvious local exception? } - + if(instance_.traceLevels().location >= 1) { System.Text.StringBuilder s = new System.Text.StringBuilder(); @@ -1463,7 +1471,7 @@ namespace Ice } } - static private readonly string[] _suffixes = + static private readonly string[] _suffixes = { "ACM", "ACM.Timeout", @@ -1504,7 +1512,7 @@ namespace Ice "ThreadPool.StackSize", "ThreadPool.Serialize" }; - + private bool filterProperties(List<string> unknownProps) { // @@ -1545,7 +1553,7 @@ namespace Ice return noProps; } - + private const int StateUninitialized = 0; // Just constructed. private const int StateHeld = 1; private const int StateActivating = 2; @@ -1554,7 +1562,7 @@ namespace Ice private const int StateDeactivated = 5; private const int StateDestroying = 6; private const int StateDestroyed = 7; - + private int state_ = StateUninitialized; private Instance instance_; private Communicator _communicator; |