summaryrefslogtreecommitdiff
path: root/java/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/src')
-rw-r--r--java/src/Ice/ObjectAdapterI.java57
-rw-r--r--java/src/IceInternal/OutgoingConnectionFactory.java104
-rw-r--r--java/src/IceInternal/RouterManager.java17
3 files changed, 124 insertions, 54 deletions
diff --git a/java/src/Ice/ObjectAdapterI.java b/java/src/Ice/ObjectAdapterI.java
index d0e65090264..bd644eddd9b 100644
--- a/java/src/Ice/ObjectAdapterI.java
+++ b/java/src/Ice/ObjectAdapterI.java
@@ -529,11 +529,65 @@ public final class ObjectAdapterI extends LocalObjectImpl implements ObjectAdapt
// router's client proxy to use this object adapter for
// callbacks.
//
- _instance.outgoingConnectionFactory().setRouter(routerInfo.getRouter());
+ _instance.outgoingConnectionFactory().setRouterInfo(routerInfo);
}
}
public synchronized void
+ removeRouter(RouterPrx router)
+ {
+ checkForDeactivation();
+
+ IceInternal.RouterInfo routerInfo = _instance.routerManager().erase(router);
+ if(routerInfo != null)
+ {
+ //
+ // Rebuild the router endpoints from our set of router infos.
+ //
+ _routerEndpoints = new java.util.ArrayList();
+ java.util.Iterator p = _routerInfos.iterator();
+ while(p.hasNext())
+ {
+ IceInternal.RouterInfo curr = (IceInternal.RouterInfo)p.next();
+ if(curr == routerInfo)
+ {
+ p.remove();
+ continue;
+ }
+ ObjectPrxHelperBase proxy = (ObjectPrxHelperBase)routerInfo.getServerProxy();
+ IceInternal.EndpointI[] endpoints = proxy.__reference().getEndpoints();
+ for(int i = 0; i < endpoints.length; ++i)
+ {
+ _routerEndpoints.add(endpoints[i]);
+ }
+ }
+
+ java.util.Collections.sort(_routerEndpoints); // Must be sorted.
+ for(int i = 0; i < _routerEndpoints.size() - 1; ++i)
+ {
+ java.lang.Object o1 = _routerEndpoints.get(i);
+ java.lang.Object o2 = _routerEndpoints.get(i + 1);
+ if(o1.equals(o2))
+ {
+ _routerEndpoints.remove(i);
+ }
+ }
+
+ //
+ // Clear this object adapter with the router.
+ //
+ routerInfo.setAdapter(null);
+
+ //
+ // Also modify all existing outgoing connections to the
+ // router's client proxy to use this object adapter for
+ // callbacks.
+ //
+ _instance.outgoingConnectionFactory().setRouterInfo(routerInfo);
+ }
+ }
+
+ public synchronized void
setLocator(LocatorPrx locator)
{
checkForDeactivation();
@@ -1000,6 +1054,7 @@ public final class ObjectAdapterI extends LocalObjectImpl implements ObjectAdapt
final private String _id;
private java.util.ArrayList _incomingConnectionFactories = new java.util.ArrayList();
private java.util.ArrayList _routerEndpoints = new java.util.ArrayList();
+ private java.util.ArrayList _routerInfos = new java.util.ArrayList();
private java.util.ArrayList _publishedEndpoints;
private IceInternal.LocatorInfo _locatorInfo;
private int _directCount;
diff --git a/java/src/IceInternal/OutgoingConnectionFactory.java b/java/src/IceInternal/OutgoingConnectionFactory.java
index 05a5473f4b6..0ec64faa614 100644
--- a/java/src/IceInternal/OutgoingConnectionFactory.java
+++ b/java/src/IceInternal/OutgoingConnectionFactory.java
@@ -398,71 +398,69 @@ public final class OutgoingConnectionFactory
}
public synchronized void
- setRouter(Ice.RouterPrx router)
+ setRouterInfo(IceInternal.RouterInfo routerInfo)
{
if(_destroyed)
{
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();
- DefaultsAndOverrides defaultsAndOverrides = _instance.defaultsAndOverrides();
- EndpointI[] endpoints = ((Ice.ObjectPrxHelperBase)proxy).__reference().getEndpoints();
- for(int i = 0; i < endpoints.length; i++)
- {
- EndpointI endpoint = endpoints[i];
+ assert(routerInfo != null);
- //
- // Modify endpoints with overrides.
- //
- if(defaultsAndOverrides.overrideTimeout)
- {
- endpoint = endpoint.timeout(defaultsAndOverrides.overrideTimeoutValue);
- }
+ //
+ // 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();
+ DefaultsAndOverrides defaultsAndOverrides = _instance.defaultsAndOverrides();
+ EndpointI[] endpoints = ((Ice.ObjectPrxHelperBase)proxy).__reference().getEndpoints();
+ for(int i = 0; i < endpoints.length; i++)
+ {
+ EndpointI endpoint = endpoints[i];
- //
- // The Connection object does not take the compression flag of
- // endpoints into account, but instead gets the information
- // about whether messages should be compressed or not from
- // other sources. In order to allow connection sharing for
- // endpoints that differ in the value of the compression flag
- // only, we always set the compression flag to false here in
- // this connection factory.
- //
- endpoint = endpoint.compress(false);
+ //
+ // Modify endpoints with overrides.
+ //
+ if(defaultsAndOverrides.overrideTimeout)
+ {
+ endpoint = endpoint.timeout(defaultsAndOverrides.overrideTimeoutValue);
+ }
- java.util.LinkedList connectionList = (java.util.LinkedList)_connections.get(endpoints[i]);
- if(connectionList != null)
+ //
+ // The Connection object does not take the compression flag of
+ // endpoints into account, but instead gets the information
+ // about whether messages should be compressed or not from
+ // other sources. In order to allow connection sharing for
+ // endpoints that differ in the value of the compression flag
+ // only, we always set the compression flag to false here in
+ // this connection factory.
+ //
+ endpoint = endpoint.compress(false);
+
+ java.util.LinkedList connectionList = (java.util.LinkedList)_connections.get(endpoints[i]);
+ if(connectionList != null)
+ {
+ java.util.Iterator p = connectionList.iterator();
+
+ while(p.hasNext())
{
- java.util.Iterator p = connectionList.iterator();
-
- while(p.hasNext())
+ Ice.ConnectionI connection = (Ice.ConnectionI)p.next();
+ try
{
- Ice.ConnectionI connection = (Ice.ConnectionI)p.next();
- try
- {
- connection.setAdapter(adapter);
- }
- catch(Ice.LocalException ex)
- {
- //
- // Ignore, the connection is being closed or closed.
- //
- }
+ connection.setAdapter(adapter);
}
- }
- }
- }
+ catch(Ice.LocalException ex)
+ {
+ //
+ // Ignore, the connection is being closed or closed.
+ //
+ }
+ }
+ }
+ }
}
public synchronized void
diff --git a/java/src/IceInternal/RouterManager.java b/java/src/IceInternal/RouterManager.java
index 4dbaeb5a5f3..0fa349216f1 100644
--- a/java/src/IceInternal/RouterManager.java
+++ b/java/src/IceInternal/RouterManager.java
@@ -54,5 +54,22 @@ public final class RouterManager
}
}
+ public RouterInfo
+ erase(Ice.RouterPrx rtr)
+ {
+ RouterInfo info = null;
+ if(rtr != null)
+ {
+ // The router cannot be routed.
+ Ice.RouterPrx router = Ice.RouterPrxHelper.uncheckedCast(rtr.ice_router(null));
+
+ synchronized(this)
+ {
+ info = (RouterInfo)_table.remove(router);
+ }
+ }
+ return info;
+ }
+
private java.util.HashMap _table = new java.util.HashMap();
}