summaryrefslogtreecommitdiff
path: root/java/src/Ice/_ObjectDelM.java
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2002-01-29 06:49:10 +0000
committerMark Spruiell <mes@zeroc.com>2002-01-29 06:49:10 +0000
commit0001dc614d21380fb22a22566a44e6d2eae88542 (patch)
treec2a50cf5bd26da7ce3844146473989ebac902515 /java/src/Ice/_ObjectDelM.java
parentadding server (diff)
downloadice-0001dc614d21380fb22a22566a44e6d2eae88542.tar.bz2
ice-0001dc614d21380fb22a22566a44e6d2eae88542.tar.xz
ice-0001dc614d21380fb22a22566a44e6d2eae88542.zip
align with stable_31
Diffstat (limited to 'java/src/Ice/_ObjectDelM.java')
-rw-r--r--java/src/Ice/_ObjectDelM.java158
1 files changed, 117 insertions, 41 deletions
diff --git a/java/src/Ice/_ObjectDelM.java b/java/src/Ice/_ObjectDelM.java
index 9763adbe677..e6681e4f301 100644
--- a/java/src/Ice/_ObjectDelM.java
+++ b/java/src/Ice/_ObjectDelM.java
@@ -17,8 +17,8 @@ public class _ObjectDelM implements _ObjectDel
throws LocationForward, IceInternal.NonRepeatable
{
IceInternal.Outgoing __out =
- new IceInternal.Outgoing(__connection, __reference, false,
- "ice_isA", true, __context);
+ new IceInternal.Outgoing(__connection, __reference, "ice_isA",
+ true, __context);
IceInternal.BasicStream __is = __out.is();
IceInternal.BasicStream __os = __out.os();
__os.writeString(__id);
@@ -34,8 +34,8 @@ public class _ObjectDelM implements _ObjectDel
throws LocationForward, IceInternal.NonRepeatable
{
IceInternal.Outgoing __out =
- new IceInternal.Outgoing(__connection, __reference, false,
- "ice_ping", true, __context);
+ new IceInternal.Outgoing(__connection, __reference, "ice_ping",
+ true, __context);
if (!__out.invoke())
{
throw new UnknownUserException();
@@ -48,8 +48,8 @@ public class _ObjectDelM implements _ObjectDel
throws LocationForward, IceInternal.NonRepeatable
{
IceInternal.Outgoing __out =
- new IceInternal.Outgoing(__connection, __reference, false,
- operation, nonmutating, __context);
+ new IceInternal.Outgoing(__connection, __reference, operation,
+ nonmutating, __context);
IceInternal.BasicStream __os = __out.os();
__os.writeBlob(inParams);
__out.invoke();
@@ -68,21 +68,114 @@ public class _ObjectDelM implements _ObjectDel
__connection.flushBatchRequest();
}
- protected IceInternal.Connection __connection;
- protected IceInternal.Reference __reference;
-
//
// Only for use by ObjectPrx
//
final void
+ __copyFrom(_ObjectDelM from)
+ {
+ //
+ // No need to synchronize "from", as the delegate is immutable
+ // after creation.
+ //
+
+ //
+ // No need to synchronize, as this operation is only called
+ // upon initialization.
+ //
+
+ __reference = from.__reference;
+ __connection = from.__connection;
+ }
+
+ protected IceInternal.Connection __connection;
+ protected IceInternal.Reference __reference;
+
+ public void
setup(IceInternal.Reference ref)
{
//
// No need to synchronize, as this operation is only called
- // upon initial initialization.
+ // upon initialization.
//
__reference = ref;
+ if (__reference.reverseAdapter != null)
+ {
+ //
+ // If we have a reverse object adapter, we use the incoming
+ // connections from such object adapter.
+ //
+ ObjectAdapterI adapter = (ObjectAdapterI)__reference.reverseAdapter;
+ IceInternal.Connection[] connections =
+ adapter.getIncomingConnections();
+
+ IceInternal.Endpoint[] endpoints =
+ new IceInternal.Endpoint[connections.length];
+ for (int i = 0; i < connections.length; i++)
+ {
+ endpoints[i] = connections[i].endpoint();
+ }
+ endpoints = filterEndpoints(endpoints);
+
+ if (endpoints.length == 0)
+ {
+ throw new NoEndpointException();
+ }
+
+ int j;
+ for (j = 0; j < connections.length; j++)
+ {
+ if (connections[j].endpoint().equals(endpoints[0]))
+ {
+ break;
+ }
+ }
+ assert(j < connections.length);
+ __connection = connections[j];
+ }
+ else
+ {
+ IceInternal.Endpoint[] endpoints = null;
+ if (__reference.routerInfo != null)
+ {
+ //
+ // If we route, we send everything to the router's client
+ // proxy endpoints.
+ //
+ ObjectPrx proxy = __reference.routerInfo.getClientProxy();
+ endpoints = filterEndpoints(((ObjectPrxHelper)proxy).__reference().endpoints);
+ }
+ else
+ {
+ endpoints = filterEndpoints(__reference.endpoints);
+ }
+
+ if (endpoints.length == 0)
+ {
+ throw new NoEndpointException();
+ }
+
+ IceInternal.OutgoingConnectionFactory factory =
+ __reference.instance.outgoingConnectionFactory();
+ __connection = factory.create(endpoints);
+ assert(__connection != null);
+
+ //
+ // If we have a router, add the object adapter for this router (if
+ // any) to the new connection, so that callbacks from the router
+ // can be received over this new connection.
+ //
+ if (__reference.routerInfo != null)
+ {
+ __connection.setAdapter(__reference.routerInfo.getAdapter());
+ }
+ }
+ }
+
+ private IceInternal.Endpoint[]
+ filterEndpoints(IceInternal.Endpoint[] allEndpoints)
+ {
java.util.ArrayList endpoints = new java.util.ArrayList();
switch (__reference.mode)
{
@@ -90,11 +183,14 @@ public class _ObjectDelM implements _ObjectDel
case IceInternal.Reference.ModeOneway:
case IceInternal.Reference.ModeBatchOneway:
{
- for (int i = 0; i < __reference.endpoints.length; i++)
+ //
+ // Filter out datagram endpoints.
+ //
+ for (int i = 0; i < allEndpoints.length; i++)
{
- if (!__reference.endpoints[i].datagram())
+ if (!allEndpoints[i].datagram())
{
- endpoints.add(__reference.endpoints[i]);
+ endpoints.add(allEndpoints[i]);
}
}
break;
@@ -103,11 +199,14 @@ public class _ObjectDelM implements _ObjectDel
case IceInternal.Reference.ModeDatagram:
case IceInternal.Reference.ModeBatchDatagram:
{
- for (int i = 0; i < __reference.endpoints.length; i++)
+ //
+ // Filter out non-datagram endpoints.
+ //
+ for (int i = 0; i < allEndpoints.length; i++)
{
- if (__reference.endpoints[i].datagram())
+ if (allEndpoints[i].datagram())
{
- endpoints.add(__reference.endpoints[i]);
+ endpoints.add(allEndpoints[i]);
}
}
break;
@@ -117,7 +216,7 @@ public class _ObjectDelM implements _ObjectDel
//
// Randomize the order of endpoints.
//
- random_shuffle(endpoints);
+ java.util.Collections.shuffle(endpoints);
IceInternal.Endpoint[] arr;
@@ -148,15 +247,7 @@ public class _ObjectDelM implements _ObjectDel
java.util.Arrays.sort((java.lang.Object[])arr, __comparator);
}
- if (arr.length == 0)
- {
- throw new NoEndpointException();
- }
-
- IceInternal.OutgoingConnectionFactory factory =
- __reference.instance.outgoingConnectionFactory();
- __connection = factory.create(arr);
- assert(__connection != null);
+ return arr;
}
private static class EndpointComparator implements java.util.Comparator
@@ -183,19 +274,4 @@ public class _ObjectDelM implements _ObjectDel
}
}
private static EndpointComparator __comparator = new EndpointComparator();
-
- private static java.util.Random __random = new java.util.Random();
-
- private static void
- random_shuffle(java.util.ArrayList arr)
- {
- final int sz = arr.size();
- for (int i = 0; i < sz; i++)
- {
- int pos = Math.abs(__random.nextInt() % sz);
- java.lang.Object tmp = arr.get(pos);
- arr.set(pos, arr.get(i));
- arr.set(i, tmp);
- }
- }
}