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
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
|
// **********************************************************************
//
// Copyright (c) 2001
// Mutable Realms, 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 = getOutgoing("ice_isA", OperationMode.Nonmutating, __context);
try
{
IceInternal.BasicStream __is = __out.is();
IceInternal.BasicStream __os = __out.os();
__os.writeString(__id);
if(!__out.invoke())
{
throw new UnknownUserException();
}
return __is.readBool();
}
finally
{
reclaimOutgoing(__out);
}
}
public void
ice_ping(java.util.Map __context)
throws LocationForward, IceInternal.NonRepeatable
{
IceInternal.Outgoing __out = getOutgoing("ice_ping", OperationMode.Nonmutating, __context);
try
{
if(!__out.invoke())
{
throw new UnknownUserException();
}
}
finally
{
reclaimOutgoing(__out);
}
}
public String[]
ice_ids(java.util.Map __context)
throws LocationForward, IceInternal.NonRepeatable
{
IceInternal.Outgoing __out = getOutgoing("ice_ids", OperationMode.Nonmutating, __context);
try
{
IceInternal.BasicStream __is = __out.is();
if(!__out.invoke())
{
throw new UnknownUserException();
}
return __is.readStringSeq();
}
finally
{
reclaimOutgoing(__out);
}
}
public String
ice_id(java.util.Map __context)
throws LocationForward, IceInternal.NonRepeatable
{
IceInternal.Outgoing __out = getOutgoing("ice_id", OperationMode.Nonmutating, __context);
try
{
IceInternal.BasicStream __is = __out.is();
if(!__out.invoke())
{
throw new UnknownUserException();
}
return __is.readString();
}
finally
{
reclaimOutgoing(__out);
}
}
public String[]
ice_facets(java.util.Map __context)
throws LocationForward, IceInternal.NonRepeatable
{
IceInternal.Outgoing __out = getOutgoing("ice_facets", OperationMode.Nonmutating, __context);
try
{
IceInternal.BasicStream __is = __out.is();
if(!__out.invoke())
{
throw new UnknownUserException();
}
return __is.readStringSeq();
}
finally
{
reclaimOutgoing(__out);
}
}
public boolean
ice_invoke(String operation, OperationMode mode, byte[] inParams, ByteSeqHolder outParams,
java.util.Map __context)
throws LocationForward, IceInternal.NonRepeatable
{
IceInternal.Outgoing __out = getOutgoing(operation, OperationMode.Nonmutating, __context);
try
{
IceInternal.BasicStream __os = __out.os();
__os.writeBlob(inParams);
boolean ok = __out.invoke();
if(__reference.mode == IceInternal.Reference.ModeTwoway)
{
IceInternal.BasicStream __is = __out.is();
int sz = __is.getReadEncapsSize();
outParams.value = __is.readBlob(sz);
}
return ok;
}
finally
{
reclaimOutgoing(__out);
}
}
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;
__connection.incUsageCount();
}
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)
{
NoEndpointException e = new NoEndpointException();
e.proxy = __reference.toString();
throw e;
}
int j;
for(j = 0; j < connections.length; j++)
{
if(connections[j].endpoint().equals(endpoints[0]))
{
break;
}
}
assert(j < connections.length);
__connection = connections[j];
__connection.incUsageCount();
}
else
{
while(true)
{
IceInternal.Endpoint[] endpoints = null;
BooleanHolder cached = new BooleanHolder();
cached.value = false;
if(__reference.routerInfo != null)
{
//
// If we route, we send everything to the router's client
// proxy endpoints.
//
ObjectPrx proxy = __reference.routerInfo.getClientProxy();
endpoints = ((ObjectPrxHelper)proxy).__reference().endpoints;
}
else if(__reference.endpoints.length > 0)
{
endpoints = __reference.endpoints;
}
else if(__reference.locatorInfo != null)
{
endpoints = __reference.locatorInfo.getEndpoints(__reference, cached);
}
IceInternal.Endpoint[] filteredEndpoints = null;
if(endpoints != null)
{
filteredEndpoints = filterEndpoints(endpoints);
}
if(filteredEndpoints == null || filteredEndpoints.length == 0)
{
NoEndpointException e = new NoEndpointException();
e.proxy = __reference.toString();
throw e;
}
try
{
IceInternal.OutgoingConnectionFactory factory = __reference.instance.outgoingConnectionFactory();
__connection = factory.create(filteredEndpoints);
assert(__connection != null);
__connection.incUsageCount();
}
catch (LocalException ex)
{
if(__reference.routerInfo == null && __reference.endpoints.length == 0)
{
assert(__reference.locatorInfo != null);
__reference.locatorInfo.clearCache(__reference);
if(cached.value)
{
IceInternal.TraceLevels traceLevels = __reference.instance.traceLevels();
Logger logger = __reference.instance.logger();
if(traceLevels.retry >= 2)
{
String s = "connection to cached endpoints failed\n" +
"removing endpoints from cache and trying one more time\n" + ex;
logger.trace(traceLevels.retryCat, s);
}
continue;
}
}
throw ex;
}
break;
}
//
// If we have a router, set 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();
protected IceInternal.Outgoing
getOutgoing(String operation, OperationMode mode, java.util.Map context)
{
IceInternal.Outgoing out;
synchronized(__outgoingMutex)
{
if(__outgoingCache == null)
{
out = new IceInternal.Outgoing(__connection, __reference, operation, mode, context);
}
else
{
out = __outgoingCache;
__outgoingCache = __outgoingCache.next;
out.reset(operation, mode, context);
}
}
return out;
}
protected void
reclaimOutgoing(IceInternal.Outgoing out)
{
synchronized(__outgoingMutex)
{
out.next = __outgoingCache;
__outgoingCache = out;
}
}
protected void
finalize()
throws Throwable
{
if(__connection != null)
{
__connection.decUsageCount();
}
while(__outgoingCache != null)
{
IceInternal.Outgoing next = __outgoingCache.next;
__outgoingCache.destroy();
__outgoingCache.next = null;
__outgoingCache = next;
}
}
private IceInternal.Outgoing __outgoingCache;
private java.lang.Object __outgoingMutex = new java.lang.Object();
}
|