1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
|
// **********************************************************************
//
// Copyright (c) 2001
// MutableRealms, Inc.
// Huntsville, AL, USA
//
// All Rights Reserved
//
// **********************************************************************
package Ice;
public class _ObjectDelM implements _ObjectDel
{
public boolean
ice_isA(String __id, java.util.Map __context)
throws LocationForward, IceInternal.NonRepeatable
{
IceInternal.Outgoing __out =
new IceInternal.Outgoing(__connection, __reference, "ice_isA",
true, __context);
IceInternal.BasicStream __is = __out.is();
IceInternal.BasicStream __os = __out.os();
__os.writeString(__id);
if (!__out.invoke())
{
throw new UnknownUserException();
}
return __is.readBool();
}
public void
ice_ping(java.util.Map __context)
throws LocationForward, IceInternal.NonRepeatable
{
IceInternal.Outgoing __out =
new IceInternal.Outgoing(__connection, __reference, "ice_ping",
true, __context);
if (!__out.invoke())
{
throw new UnknownUserException();
}
}
public byte[]
ice_invoke(String operation, boolean nonmutating, byte[] inParams,
java.util.Map __context)
throws LocationForward, IceInternal.NonRepeatable
{
IceInternal.Outgoing __out =
new IceInternal.Outgoing(__connection, __reference, operation,
nonmutating, __context);
IceInternal.BasicStream __os = __out.os();
__os.writeBlob(inParams);
__out.invoke();
if (__reference.mode == IceInternal.Reference.ModeTwoway)
{
IceInternal.BasicStream __is = __out.is();
int sz = __is.getReadEncapsSize();
return __is.readBlob(sz);
}
return null;
}
public void
ice_flush()
{
__connection.flushBatchRequest();
}
//
// 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 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();
//
// Filter out unknown endpoints.
//
for (int i = 0; i < allEndpoints.length; i++)
{
if (!allEndpoints[i].unknown())
{
endpoints.add(allEndpoints[i]);
}
}
switch (__reference.mode)
{
case IceInternal.Reference.ModeTwoway:
case IceInternal.Reference.ModeOneway:
case IceInternal.Reference.ModeBatchOneway:
{
//
// Filter out datagram endpoints.
//
java.util.Iterator i = endpoints.iterator();
while (i.hasNext())
{
IceInternal.Endpoint endpoint = (IceInternal.Endpoint)i.next();
if (endpoint.datagram())
{
i.remove();
}
}
break;
}
case IceInternal.Reference.ModeDatagram:
case IceInternal.Reference.ModeBatchDatagram:
{
//
// Filter out non-datagram endpoints.
//
java.util.Iterator i = endpoints.iterator();
while (i.hasNext())
{
IceInternal.Endpoint endpoint = (IceInternal.Endpoint)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 (__reference.secure)
{
java.util.Iterator i = endpoints.iterator();
while (i.hasNext())
{
IceInternal.Endpoint endpoint = (IceInternal.Endpoint)i.next();
if (!endpoint.secure())
{
i.remove();
}
}
}
else
{
java.util.Collections.sort(endpoints, __comparator);
}
IceInternal.Endpoint[] arr = new IceInternal.Endpoint[endpoints.size()];
endpoints.toArray(arr);
return arr;
}
private static class EndpointComparator implements java.util.Comparator
{
public int
compare(java.lang.Object l, java.lang.Object r)
{
IceInternal.Endpoint le = (IceInternal.Endpoint)l;
IceInternal.Endpoint re = (IceInternal.Endpoint)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 __comparator = new EndpointComparator();
}
|