summaryrefslogtreecommitdiff
path: root/java/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/src')
-rw-r--r--java/src/Ice/ConnectionI.java1
-rw-r--r--java/src/Ice/ObjectPrx.java6
-rw-r--r--java/src/Ice/ObjectPrxHelperBase.java145
-rw-r--r--java/src/IceInternal/DirectReference.java11
-rw-r--r--java/src/IceInternal/FixedReference.java104
-rw-r--r--java/src/IceInternal/IndirectReference.java14
-rw-r--r--java/src/IceInternal/OutgoingConnectionFactory.java4
-rw-r--r--java/src/IceInternal/Reference.java272
-rw-r--r--java/src/IceInternal/RoutableReference.java175
9 files changed, 444 insertions, 288 deletions
diff --git a/java/src/Ice/ConnectionI.java b/java/src/Ice/ConnectionI.java
index d478eba4750..a398fb5db1b 100644
--- a/java/src/Ice/ConnectionI.java
+++ b/java/src/Ice/ConnectionI.java
@@ -1419,6 +1419,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne
// Don't warn about certain expected exceptions.
//
if(!(_exception instanceof CloseConnectionException ||
+ _exception instanceof ForcedCloseConnectionException ||
_exception instanceof ConnectionTimeoutException ||
_exception instanceof CommunicatorDestroyedException ||
_exception instanceof ObjectAdapterDeactivatedException ||
diff --git a/java/src/Ice/ObjectPrx.java b/java/src/Ice/ObjectPrx.java
index 5c534f3dfb6..07a6954d633 100644
--- a/java/src/Ice/ObjectPrx.java
+++ b/java/src/Ice/ObjectPrx.java
@@ -57,6 +57,12 @@ public interface ObjectPrx
int ice_getLocatorCacheTimeout();
ObjectPrx ice_locatorCacheTimeout(int newTimeout);
+ boolean ice_getCacheConnection();
+ ObjectPrx ice_cacheConnection(boolean newCache);
+
+ EndpointSelectionType ice_getEndpointSelection();
+ ObjectPrx ice_endpointSelection(EndpointSelectionType newType);
+
ObjectPrx ice_twoway();
boolean ice_isTwoway();
ObjectPrx ice_oneway();
diff --git a/java/src/Ice/ObjectPrxHelperBase.java b/java/src/Ice/ObjectPrxHelperBase.java
index ea1c40ad67e..125e227438e 100644
--- a/java/src/Ice/ObjectPrxHelperBase.java
+++ b/java/src/Ice/ObjectPrxHelperBase.java
@@ -310,8 +310,10 @@ public class ObjectPrxHelperBase implements ObjectPrx
}
else
{
+ IceInternal.EndpointI[] edpts = new IceInternal.EndpointI[newEndpoints.length];
+ edpts = (IceInternal.EndpointI[])java.util.Arrays.asList(newEndpoints).toArray(edpts);
ObjectPrxHelperBase proxy = new ObjectPrxHelperBase();
- proxy.setup(_reference.changeEndpoints((IceInternal.EndpointI[])newEndpoints));
+ proxy.setup(_reference.changeEndpoints(edpts));
return proxy;
}
}
@@ -337,6 +339,48 @@ public class ObjectPrxHelperBase implements ObjectPrx
}
}
+ public final boolean
+ ice_getCacheConnection()
+ {
+ return _reference.getCacheConnection();
+ }
+
+ public final ObjectPrx
+ ice_cacheConnection(boolean newCache)
+ {
+ if(newCache == _reference.getCacheConnection())
+ {
+ return this;
+ }
+ else
+ {
+ ObjectPrxHelperBase proxy = new ObjectPrxHelperBase();
+ proxy.setup(_reference.changeCacheConnection(newCache));
+ return proxy;
+ }
+ }
+
+ public final Ice.EndpointSelectionType
+ ice_getEndpointSelection()
+ {
+ return _reference.getEndpointSelection();
+ }
+
+ public final ObjectPrx
+ ice_endpointSelection(Ice.EndpointSelectionType newType)
+ {
+ if(newType == _reference.getEndpointSelection())
+ {
+ return this;
+ }
+ else
+ {
+ ObjectPrxHelperBase proxy = new ObjectPrxHelperBase();
+ proxy.setup(_reference.changeEndpointSelection(newType));
+ return proxy;
+ }
+ }
+
public final ObjectPrx
ice_twoway()
{
@@ -636,18 +680,21 @@ public class ObjectPrxHelperBase implements ObjectPrx
_reference = ref;
- if(delegateD != null)
- {
- _ObjectDelD delegate = __createDelegateD();
- delegate.__copyFrom(delegateD);
- _delegate = delegate;
- }
- else if(delegateM != null)
- {
- _ObjectDelM delegate = __createDelegateM();
- delegate.__copyFrom(delegateM);
- _delegate = delegate;
- }
+ if(_reference.getCacheConnection())
+ {
+ if(delegateD != null)
+ {
+ _ObjectDelD delegate = __createDelegateD();
+ delegate.__copyFrom(delegateD);
+ _delegate = delegate;
+ }
+ else if(delegateM != null)
+ {
+ _ObjectDelM delegate = __createDelegateM();
+ delegate.__copyFrom(delegateM);
+ _delegate = delegate;
+ }
+ }
}
public final int
@@ -702,45 +749,53 @@ public class ObjectPrxHelperBase implements ObjectPrx
public final synchronized _ObjectDel
__getDelegate()
{
- if(_delegate == null)
+ if(_delegate != null)
{
- if(_reference.getCollocationOptimization())
+ return _delegate;
+ }
+
+ _ObjectDel delegate = null;
+ if(_reference.getCollocationOptimization())
+ {
+ ObjectAdapter adapter = _reference.getInstance().objectAdapterFactory().findObjectAdapter(this);
+ if(adapter != null)
{
- ObjectAdapter adapter = _reference.getInstance().objectAdapterFactory().findObjectAdapter(this);
- if(adapter != null)
- {
- _ObjectDelD delegate = __createDelegateD();
- delegate.setup(_reference, adapter);
- _delegate = delegate;
- }
+ _ObjectDelD d = __createDelegateD();
+ d.setup(_reference, adapter);
+ delegate = d;
}
+ }
- if(_delegate == null)
- {
- _ObjectDelM delegate = __createDelegateM();
- delegate.setup(_reference);
- _delegate = delegate;
-
- //
- // If this proxy is for a non-local object, and we are
- // using a router, then add this proxy to the router info
- // object.
- //
- try
- {
- IceInternal.RoutableReference rr = (IceInternal.RoutableReference)_reference;
- if(rr != null && rr.getRouterInfo() != null)
- {
- rr.getRouterInfo().addProxy(this);
- }
- }
- catch(ClassCastException e)
+ if(delegate == null)
+ {
+ _ObjectDelM d = __createDelegateM();
+ d.setup(_reference);
+ delegate = d;
+
+ //
+ // If this proxy is for a non-local object, and we are
+ // using a router, then add this proxy to the router info
+ // object.
+ //
+ try
+ {
+ IceInternal.RoutableReference rr = (IceInternal.RoutableReference)_reference;
+ if(rr != null && rr.getRouterInfo() != null)
{
+ rr.getRouterInfo().addProxy(this);
}
- }
- }
+ }
+ catch(ClassCastException e)
+ {
+ }
+ }
+
+ if(_reference.getCacheConnection())
+ {
+ _delegate = delegate;
+ }
- return _delegate;
+ return delegate;
}
protected _ObjectDelM
diff --git a/java/src/IceInternal/DirectReference.java b/java/src/IceInternal/DirectReference.java
index fcee0d693b0..e5ac9fa6262 100644
--- a/java/src/IceInternal/DirectReference.java
+++ b/java/src/IceInternal/DirectReference.java
@@ -122,6 +122,7 @@ public class DirectReference extends RoutableReference
{
return this;
}
+
DirectReference r = (DirectReference)getInstance().referenceFactory().copy(this);
r._endpoints = newEndpoints;
return r;
@@ -179,16 +180,8 @@ public class DirectReference extends RoutableReference
{
endpts = _endpoints;
}
- EndpointI[] filteredEndpoints = filterEndpoints(endpts);
- if(filteredEndpoints.length == 0)
- {
- Ice.NoEndpointException ex = new Ice.NoEndpointException();
- ex.proxy = toString();
- throw ex;
- }
- OutgoingConnectionFactory factory = getInstance().outgoingConnectionFactory();
- Ice.ConnectionI connection = factory.create(filteredEndpoints, comp);
+ Ice.ConnectionI connection = createConnection(endpts, comp);
//
// If we have a router, set the object adapter for this router
diff --git a/java/src/IceInternal/FixedReference.java b/java/src/IceInternal/FixedReference.java
index 4dd59e8d116..026aae68d68 100644
--- a/java/src/IceInternal/FixedReference.java
+++ b/java/src/IceInternal/FixedReference.java
@@ -174,5 +174,109 @@ public class FixedReference extends Reference
return java.util.Arrays.equals(_fixedConnections, rhs._fixedConnections);
}
+ //
+ // Filter connections based on criteria from this reference.
+ //
+ private Ice.ConnectionI[]
+ filterConnections(Ice.ConnectionI[] allConnections)
+ {
+ java.util.ArrayList connections = new java.util.ArrayList(allConnections.length);
+
+ switch(getMode())
+ {
+ case Reference.ModeTwoway:
+ case Reference.ModeOneway:
+ case Reference.ModeBatchOneway:
+ {
+ //
+ // Filter out datagram connections.
+ //
+ for(int i = 0; i < allConnections.length; ++i)
+ {
+ if(!allConnections[i].endpoint().datagram())
+ {
+ connections.add(allConnections[i]);
+ }
+ }
+
+ break;
+ }
+
+ case Reference.ModeDatagram:
+ case Reference.ModeBatchDatagram:
+ {
+ //
+ // Filter out non-datagram connections.
+ //
+ for(int i = 0; i < allConnections.length; i++)
+ {
+ if(allConnections[i].endpoint().datagram())
+ {
+ connections.add(allConnections[i]);
+ }
+ }
+
+ break;
+ }
+ }
+
+ //
+ // Randomize the order of connections.
+ //
+ java.util.Collections.shuffle(connections);
+
+ //
+ // If a secure connection is requested, remove all non-secure
+ // endpoints. Otherwise make non-secure endpoints preferred over
+ // secure endpoints by partitioning the endpoint vector, so that
+ // non-secure endpoints come first.
+ //
+ if(getSecure())
+ {
+ java.util.Iterator i = connections.iterator();
+ while(i.hasNext())
+ {
+ Ice.ConnectionI connection = (Ice.ConnectionI)i.next();
+ if(!connection.endpoint().secure())
+ {
+ i.remove();
+ }
+ }
+ }
+ else
+ {
+ java.util.Collections.sort(connections, _connectionComparator);
+ }
+
+ Ice.ConnectionI[] arr = new Ice.ConnectionI[connections.size()];
+ connections.toArray(arr);
+ return arr;
+ }
+
+ static class ConnectionComparator implements java.util.Comparator
+ {
+ public int
+ compare(java.lang.Object l, java.lang.Object r)
+ {
+ Ice.ConnectionI lc = (Ice.ConnectionI)l;
+ Ice.ConnectionI rc = (Ice.ConnectionI)r;
+ boolean ls = lc.endpoint().secure();
+ boolean rs = rc.endpoint().secure();
+ if((ls && rs) || (!ls && !rs))
+ {
+ return 0;
+ }
+ else if(!ls && rs)
+ {
+ return -1;
+ }
+ else
+ {
+ return 1;
+ }
+ }
+ }
+
+ private static ConnectionComparator _connectionComparator = new ConnectionComparator();
private Ice.ConnectionI _fixedConnections[];
}
diff --git a/java/src/IceInternal/IndirectReference.java b/java/src/IceInternal/IndirectReference.java
index d0c56776594..a1a563240cb 100644
--- a/java/src/IceInternal/IndirectReference.java
+++ b/java/src/IceInternal/IndirectReference.java
@@ -220,20 +220,16 @@ public class IndirectReference extends RoutableReference
{
endpts[i] = endpts[i].connectionId(_connectionId);
}
- EndpointI[] filteredEndpoints = filterEndpoints(endpts);
- if(filteredEndpoints.length == 0)
- {
- Ice.NoEndpointException ex = new Ice.NoEndpointException();
- ex.proxy = toString();
- throw ex;
- }
try
{
- OutgoingConnectionFactory factory = getInstance().outgoingConnectionFactory();
- connection = factory.create(filteredEndpoints, comp);
+ connection = createConnection(endpts, comp);
assert(connection != null);
}
+ catch(Ice.NoEndpointException ex)
+ {
+ throw ex; // No need to retry if there's no endpoints.
+ }
catch(Ice.LocalException ex)
{
if(getRouterInfo() == null)
diff --git a/java/src/IceInternal/OutgoingConnectionFactory.java b/java/src/IceInternal/OutgoingConnectionFactory.java
index 0ec64faa614..d5e4c47fefa 100644
--- a/java/src/IceInternal/OutgoingConnectionFactory.java
+++ b/java/src/IceInternal/OutgoingConnectionFactory.java
@@ -91,7 +91,7 @@ public final class OutgoingConnectionFactory
}
public Ice.ConnectionI
- create(EndpointI[] endpts, Ice.BooleanHolder compress)
+ create(EndpointI[] endpts, boolean hasMore, Ice.BooleanHolder compress)
{
assert(endpts.length > 0);
EndpointI[] endpoints = new EndpointI[endpts.length];
@@ -341,7 +341,7 @@ public final class OutgoingConnectionFactory
{
StringBuffer s = new StringBuffer();
s.append("connection to endpoint failed");
- if(i < endpoints.length - 1)
+ if(hasMore || i < endpoints.length - 1)
{
s.append(", trying next endpoint\n");
}
diff --git a/java/src/IceInternal/Reference.java b/java/src/IceInternal/Reference.java
index b225a0ab97b..7c81088d05d 100644
--- a/java/src/IceInternal/Reference.java
+++ b/java/src/IceInternal/Reference.java
@@ -48,6 +48,18 @@ public abstract class Reference implements Cloneable
return _context;
}
+ public final boolean
+ getCacheConnection()
+ {
+ return _cacheConnection;
+ }
+
+ public final Ice.EndpointSelectionType
+ getEndpointSelection()
+ {
+ return _endpointSelection;
+ }
+
public final Reference
defaultContext()
{
@@ -128,6 +140,29 @@ public abstract class Reference implements Cloneable
return r;
}
+ public final Reference
+ changeCacheConnection(boolean newCache)
+ {
+ if(newCache == _cacheConnection)
+ {
+ return this;
+ }
+ Reference r = _instance.referenceFactory().copy(this);
+ r._cacheConnection = newCache;
+ return r;
+ }
+
+ public final Reference
+ changeEndpointSelection(Ice.EndpointSelectionType newType)
+ {
+ if(newType == _endpointSelection)
+ {
+ return this;
+ }
+ Reference r = _instance.referenceFactory().copy(this);
+ r._endpointSelection = newType;
+ return r;
+ }
public abstract Reference changeSecure(boolean newSecure);
public abstract Reference changeRouter(Ice.RouterPrx newRouter);
@@ -329,6 +364,16 @@ public abstract class Reference implements Cloneable
return false;
}
+ if(_cacheConnection != r._cacheConnection)
+ {
+ return false;
+ }
+
+ if(_endpointSelection != r._endpointSelection)
+ {
+ return false;
+ }
+
return true;
}
@@ -356,6 +401,8 @@ public abstract class Reference implements Cloneable
private java.util.Map _context;
private static java.util.HashMap _emptyContext = new java.util.HashMap();
private String _facet;
+ private boolean _cacheConnection;
+ private Ice.EndpointSelectionType _endpointSelection;
private int _hashValue;
private boolean _hashInitialized;
@@ -381,229 +428,8 @@ public abstract class Reference implements Cloneable
_identity = ident;
_context = ctx == null ? _emptyContext : ctx;
_facet = fac;
+ _cacheConnection = true;
+ _endpointSelection = Ice.EndpointSelectionType.Random;
_hashInitialized = false;
}
-
- //
- // Filter endpoints based on criteria from this reference.
- //
- protected EndpointI[]
- filterEndpoints(EndpointI[] allEndpoints)
- {
- java.util.ArrayList endpoints = new java.util.ArrayList();
-
- //
- // Filter out unknown endpoints.
- //
- for(int i = 0; i < allEndpoints.length; i++)
- {
- if(!allEndpoints[i].unknown())
- {
- endpoints.add(allEndpoints[i]);
- }
- }
-
- switch(_mode)
- {
- case Reference.ModeTwoway:
- case Reference.ModeOneway:
- case Reference.ModeBatchOneway:
- {
- //
- // Filter out datagram endpoints.
- //
- java.util.Iterator i = endpoints.iterator();
- while(i.hasNext())
- {
- EndpointI endpoint = (EndpointI)i.next();
- if(endpoint.datagram())
- {
- i.remove();
- }
- }
- break;
- }
-
- case Reference.ModeDatagram:
- case Reference.ModeBatchDatagram:
- {
- //
- // Filter out non-datagram endpoints.
- //
- java.util.Iterator i = endpoints.iterator();
- while(i.hasNext())
- {
- EndpointI endpoint = (EndpointI)i.next();
- if(!endpoint.datagram())
- {
- i.remove();
- }
- }
- break;
- }
- }
-
- //
- // Randomize the order of endpoints.
- //
- java.util.Collections.shuffle(endpoints);
-
- //
- // If a secure connection is requested, remove all non-secure
- // endpoints. Otherwise make non-secure endpoints preferred over
- // secure endpoints by partitioning the endpoint vector, so that
- // non-secure endpoints come first.
- //
- if(getSecure())
- {
- java.util.Iterator i = endpoints.iterator();
- while(i.hasNext())
- {
- EndpointI endpoint = (EndpointI)i.next();
- if(!endpoint.secure())
- {
- i.remove();
- }
- }
- }
- else
- {
- java.util.Collections.sort(endpoints, _endpointComparator);
- }
-
- EndpointI[] arr = new EndpointI[endpoints.size()];
- endpoints.toArray(arr);
- return arr;
- }
-
- static class EndpointComparator implements java.util.Comparator
- {
- public int
- compare(java.lang.Object l, java.lang.Object r)
- {
- IceInternal.EndpointI le = (IceInternal.EndpointI)l;
- IceInternal.EndpointI re = (IceInternal.EndpointI)r;
- boolean ls = le.secure();
- boolean rs = re.secure();
- if((ls && rs) || (!ls && !rs))
- {
- return 0;
- }
- else if(!ls && rs)
- {
- return -1;
- }
- else
- {
- return 1;
- }
- }
- }
-
- private static EndpointComparator _endpointComparator = new EndpointComparator();
-
- //
- // Filter connections based on criteria from this reference.
- //
- public Ice.ConnectionI[]
- filterConnections(Ice.ConnectionI[] allConnections)
- {
- java.util.ArrayList connections = new java.util.ArrayList(allConnections.length);
-
- switch(_mode)
- {
- case Reference.ModeTwoway:
- case Reference.ModeOneway:
- case Reference.ModeBatchOneway:
- {
- //
- // Filter out datagram connections.
- //
- for(int i = 0; i < allConnections.length; ++i)
- {
- if(!allConnections[i].endpoint().datagram())
- {
- connections.add(allConnections[i]);
- }
- }
-
- break;
- }
-
- case Reference.ModeDatagram:
- case Reference.ModeBatchDatagram:
- {
- //
- // Filter out non-datagram connections.
- //
- for(int i = 0; i < allConnections.length; i++)
- {
- if(allConnections[i].endpoint().datagram())
- {
- connections.add(allConnections[i]);
- }
- }
-
- break;
- }
- }
-
- //
- // Randomize the order of connections.
- //
- java.util.Collections.shuffle(connections);
-
- //
- // If a secure connection is requested, remove all non-secure
- // endpoints. Otherwise make non-secure endpoints preferred over
- // secure endpoints by partitioning the endpoint vector, so that
- // non-secure endpoints come first.
- //
- if(getSecure())
- {
- java.util.Iterator i = connections.iterator();
- while(i.hasNext())
- {
- Ice.ConnectionI connection = (Ice.ConnectionI)i.next();
- if(!connection.endpoint().secure())
- {
- i.remove();
- }
- }
- }
- else
- {
- java.util.Collections.sort(connections, _connectionComparator);
- }
-
- Ice.ConnectionI[] arr = new Ice.ConnectionI[connections.size()];
- connections.toArray(arr);
- return arr;
- }
-
- static class ConnectionComparator implements java.util.Comparator
- {
- public int
- compare(java.lang.Object l, java.lang.Object r)
- {
- Ice.ConnectionI lc = (Ice.ConnectionI)l;
- Ice.ConnectionI rc = (Ice.ConnectionI)r;
- boolean ls = lc.endpoint().secure();
- boolean rs = rc.endpoint().secure();
- if((ls && rs) || (!ls && !rs))
- {
- return 0;
- }
- else if(!ls && rs)
- {
- return -1;
- }
- else
- {
- return 1;
- }
- }
- }
-
- private static ConnectionComparator _connectionComparator = new ConnectionComparator();
}
diff --git a/java/src/IceInternal/RoutableReference.java b/java/src/IceInternal/RoutableReference.java
index 00dbec6508a..f515adaeb7b 100644
--- a/java/src/IceInternal/RoutableReference.java
+++ b/java/src/IceInternal/RoutableReference.java
@@ -121,6 +121,181 @@ public abstract class RoutableReference extends Reference
_collocationOptimization = collocationOpt;
}
+ protected Ice.ConnectionI
+ createConnection(EndpointI[] allEndpoints, Ice.BooleanHolder compress)
+ {
+ java.util.ArrayList endpoints = new java.util.ArrayList();
+
+ //
+ // Filter out unknown endpoints.
+ //
+ for(int i = 0; i < allEndpoints.length; i++)
+ {
+ if(!allEndpoints[i].unknown())
+ {
+ endpoints.add(allEndpoints[i]);
+ }
+ }
+
+ //
+ // Filter out endpoints according to the mode of the reference.
+ //
+ switch(getMode())
+ {
+ case Reference.ModeTwoway:
+ case Reference.ModeOneway:
+ case Reference.ModeBatchOneway:
+ {
+ //
+ // Filter out datagram endpoints.
+ //
+ java.util.Iterator i = endpoints.iterator();
+ while(i.hasNext())
+ {
+ EndpointI endpoint = (EndpointI)i.next();
+ if(endpoint.datagram())
+ {
+ i.remove();
+ }
+ }
+ break;
+ }
+
+ case Reference.ModeDatagram:
+ case Reference.ModeBatchDatagram:
+ {
+ //
+ // Filter out non-datagram endpoints.
+ //
+ java.util.Iterator i = endpoints.iterator();
+ while(i.hasNext())
+ {
+ EndpointI endpoint = (EndpointI)i.next();
+ if(!endpoint.datagram())
+ {
+ i.remove();
+ }
+ }
+ break;
+ }
+ }
+
+ //
+ // Sort the endpoints according to the endpoint selection type.
+ //
+ switch(getEndpointSelection().value())
+ {
+ case Ice.EndpointSelectionType._Random:
+ java.util.Collections.shuffle(endpoints);
+ break;
+ case Ice.EndpointSelectionType._Ordered:
+ // Nothing to do.
+ break;
+ default:
+ assert(false);
+ break;
+ }
+
+ //
+ // If a secure connection is requested, remove all non-secure
+ // endpoints. Otherwise make non-secure endpoints preferred over
+ // secure endpoints by partitioning the endpoint vector, so that
+ // non-secure endpoints come first.
+ //
+ if(getSecure())
+ {
+ java.util.Iterator i = endpoints.iterator();
+ while(i.hasNext())
+ {
+ EndpointI endpoint = (EndpointI)i.next();
+ if(!endpoint.secure())
+ {
+ i.remove();
+ }
+ }
+ }
+ else
+ {
+ java.util.Collections.sort(endpoints, _endpointComparator);
+ }
+
+ if(endpoints.size() == 0)
+ {
+ Ice.NoEndpointException ex = new Ice.NoEndpointException();
+ ex.proxy = toString();
+ throw ex;
+ }
+
+ //
+ // Finally, create the connection.
+ //
+ OutgoingConnectionFactory factory = getInstance().outgoingConnectionFactory();
+ if(getCacheConnection() || endpoints.size() == 1)
+ {
+ //
+ // Get an existing connection or create one if there's no
+ // existing connection to one of the given endpoints.
+ //
+ return factory.create((EndpointI[])endpoints.toArray(new EndpointI[endpoints.size()]), false, compress);
+ }
+ else
+ {
+ //
+ // Go through the list of endpoints and try to create the
+ // connection until it succeeds. This is different from just
+ // calling create() with the given endpoints since this might
+ // create a new connection even if there's an existing
+ // connection for one of the endpoints.
+ //
+
+ Ice.LocalException exception = null;
+ EndpointI[] endpoint = new EndpointI[1];
+
+ java.util.Iterator i = endpoints.iterator();
+ while(i.hasNext())
+ {
+ try
+ {
+ endpoint[0] = (EndpointI)i.next();
+ return factory.create(endpoint, i.hasNext(), compress);
+ }
+ catch(Ice.LocalException ex)
+ {
+ exception = ex;
+ }
+ }
+
+ assert(exception != null);
+ throw exception;
+ }
+ }
+
+ static class EndpointComparator implements java.util.Comparator
+ {
+ public int
+ compare(java.lang.Object l, java.lang.Object r)
+ {
+ IceInternal.EndpointI le = (IceInternal.EndpointI)l;
+ IceInternal.EndpointI re = (IceInternal.EndpointI)r;
+ boolean ls = le.secure();
+ boolean rs = re.secure();
+ if((ls && rs) || (!ls && !rs))
+ {
+ return 0;
+ }
+ else if(!ls && rs)
+ {
+ return -1;
+ }
+ else
+ {
+ return 1;
+ }
+ }
+ }
+
+ private static EndpointComparator _endpointComparator = new EndpointComparator();
+
private boolean _secure;
private RouterInfo _routerInfo; // Null if no router is used.
private boolean _collocationOptimization;