diff options
author | Mark Spruiell <mes@zeroc.com> | 2002-01-29 06:49:10 +0000 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2002-01-29 06:49:10 +0000 |
commit | 0001dc614d21380fb22a22566a44e6d2eae88542 (patch) | |
tree | c2a50cf5bd26da7ce3844146473989ebac902515 /java/src/IceInternal/OutgoingConnectionFactory.java | |
parent | adding server (diff) | |
download | ice-0001dc614d21380fb22a22566a44e6d2eae88542.tar.bz2 ice-0001dc614d21380fb22a22566a44e6d2eae88542.tar.xz ice-0001dc614d21380fb22a22566a44e6d2eae88542.zip |
align with stable_31
Diffstat (limited to 'java/src/IceInternal/OutgoingConnectionFactory.java')
-rw-r--r-- | java/src/IceInternal/OutgoingConnectionFactory.java | 123 |
1 files changed, 87 insertions, 36 deletions
diff --git a/java/src/IceInternal/OutgoingConnectionFactory.java b/java/src/IceInternal/OutgoingConnectionFactory.java index d5b21e4f4b9..3778936c51d 100644 --- a/java/src/IceInternal/OutgoingConnectionFactory.java +++ b/java/src/IceInternal/OutgoingConnectionFactory.java @@ -12,41 +12,6 @@ package IceInternal; public class OutgoingConnectionFactory { - // - // Only for use by Instance - // - OutgoingConnectionFactory(Instance instance) - { - _instance = instance; - } - - protected void - finalize() - throws Throwable - { - assert(_instance == null); - - super.finalize(); - } - - public synchronized void - destroy() - { - if (_instance == null) - { - return; - } - - java.util.Iterator p = _connections.values().iterator(); - while (p.hasNext()) - { - Connection connection = (Connection)p.next(); - connection.destroy(Connection.CommunicatorDestroyed); - } - _connections.clear(); - _instance = null; - } - public synchronized Connection create(Endpoint[] endpoints) { @@ -58,7 +23,7 @@ public class OutgoingConnectionFactory assert(endpoints.length > 0); // - // First reap destroyed connections + // Reap destroyed connections // java.util.Iterator p = _connections.values().iterator(); while (p.hasNext()) @@ -153,6 +118,92 @@ public class OutgoingConnectionFactory return connection; } + public synchronized void + setRouter(Ice.RouterPrx router) + { + if (_instance == null) + { + throw new Ice.CommunicatorDestroyedException(); + } + + RouterInfo routerInfo = _instance.routerManager().get(router); + if (routerInfo != null) + { + // + // Search for connections to the router's client proxy + // endpoints, and update the object adapter for such + // connections, so that callbacks from the router can be + // received over such connections. + // + Ice.ObjectPrx proxy = routerInfo.getClientProxy(); + Ice.ObjectAdapter adapter = routerInfo.getAdapter(); + Endpoint[] endpoints = ((Ice.ObjectPrxHelper)proxy).__reference().endpoints; + for (int i = 0; i < endpoints.length; i++) + { + Connection connection = + (Connection)_connections.get(endpoints[i]); + if (connection != null) + { + connection.setAdapter(adapter); + } + } + } + } + + public synchronized void + removeAdapter(Ice.ObjectAdapter adapter) + { + if (_instance == null) + { + throw new Ice.CommunicatorDestroyedException(); + } + + java.util.Iterator p = _connections.values().iterator(); + while (p.hasNext()) + { + Connection connection = (Connection)p.next(); + if (connection.getAdapter() == adapter) + { + connection.setAdapter(null); + } + } + } + + // + // Only for use by Instance + // + OutgoingConnectionFactory(Instance instance) + { + _instance = instance; + } + + protected void + finalize() + throws Throwable + { + assert(_instance == null); + + super.finalize(); + } + + public synchronized void + destroy() + { + if (_instance == null) + { + return; + } + + java.util.Iterator p = _connections.values().iterator(); + while (p.hasNext()) + { + Connection connection = (Connection)p.next(); + connection.destroy(Connection.CommunicatorDestroyed); + } + _connections.clear(); + _instance = null; + } + private Instance _instance; private java.util.HashMap _connections = new java.util.HashMap(); } |