1:
37:
38:
39: package ;
40:
41: import ;
42: import ;
43: import ;
44: import ;
45: import ;
46: import ;
47: import ;
48:
49: import ;
50: import ;
51: import ;
52: import ;
53: import ;
54: import ;
55: import ;
56: import ;
57: import ;
58: import ;
59: import ;
60: import ;
61: import ;
62: import ;
63: import ;
64: import ;
65: import ;
66: import ;
67: import ;
68: import ;
69: import ;
70: import ;
71:
72:
77: public class gnuServerRequestInfo extends LocalObject
78: implements ServerRequestInfo
79: {
80:
83: private static final long serialVersionUID = 1;
84:
85:
88: final gnuServantObject m_object;
89:
90:
94: static final String not_available =
95: "The used invocation method provides" + "no access to this resource.";
96:
97:
100: Any[] m_slots;
101:
102:
105: public final RequestHeader m_request_header;
106:
107:
110: public final ReplyHeader m_reply_header;
111:
112:
115: public Object m_forward_reference;
116:
117:
120: public Exception m_sys_exception;
121:
122:
125: public Any m_usr_exception;
126:
127:
130: public gnuRequest m_request;
131:
132:
139: public gnuServerRequestInfo(gnuServantObject an_object,
140: RequestHeader a_request_header, ReplyHeader a_reply_header
141: )
142: {
143: m_object = an_object;
144: m_request_header = a_request_header;
145: m_reply_header = a_reply_header;
146: m_slots = new Any[ m_object.orb.icSlotSize ];
147: reset();
148: }
149:
150:
153: public void set_slot(int id, Any data) throws InvalidSlot
154: {
155: try
156: {
157: m_slots [ id ] = data;
158: }
159: catch (Exception e)
160: {
161: InvalidSlot ex = new InvalidSlot("Cannot set slot " + id);
162: ex.initCause(e);
163: throw ex;
164: }
165: }
166:
167:
170: public Any get_slot(int id) throws InvalidSlot
171: {
172: try
173: {
174: return m_slots [ id ];
175: }
176: catch (Exception e)
177: {
178: InvalidSlot ex = new InvalidSlot("Cannot get slot " + id);
179: ex.initCause(e);
180: throw ex;
181: }
182: }
183:
184:
187: public void reset()
188: {
189: TypeCode tkNull = m_object.orb.get_primitive_tc(TCKind.tk_null);
190: for (int i = 0; i < m_slots.length; i++)
191: {
192: Any a = m_object.orb.create_any();
193: a.type(tkNull);
194: m_slots [ i ] = a;
195: }
196: m_sys_exception = null;
197: m_usr_exception = null;
198: }
199:
200:
203: public byte[] object_id()
204: {
205: return m_object.Id;
206: }
207:
208:
212: public boolean target_is_a(String id)
213: {
214: return m_object._is_a(id);
215: }
216:
217:
220: public byte[] adapter_id()
221: {
222: return m_object.poa.id();
223: }
224:
225:
229: public Policy get_server_policy(int type) throws INV_POLICY
230: {
231: return m_object.poa._get_policy(type);
232: }
233:
234:
237: public String target_most_derived_interface()
238: {
239: return m_object._ids() [ 0 ];
240: }
241:
242:
245: public String operation()
246: {
247: if (m_request != null)
248: {
249: return m_request.operation();
250: }
251: else
252: {
253: return m_request_header.operation;
254: }
255: }
256:
257:
260: public TypeCode[] exceptions()
261: {
262: if (m_request == null)
263: {
264: throw new NO_RESOURCES(not_available, 1,
265: CompletionStatus.COMPLETED_MAYBE
266: );
267: }
268:
269: m_request.checkDii();
270:
271: ExceptionList ex = m_request.exceptions();
272: TypeCode[] et = new TypeCode[ ex.count() ];
273: try
274: {
275: for (int i = 0; i < et.length; i++)
276: {
277: et [ i ] = ex.item(i);
278: }
279: }
280: catch (Bounds e)
281: {
282: throw new Unexpected(e);
283: }
284: return et;
285: }
286:
287:
290: public short reply_status()
291: {
292: return (short) m_reply_header.reply_status;
293: }
294:
295:
298: public int request_id()
299: {
300: return m_request_header.request_id;
301: }
302:
303:
306: public boolean response_expected()
307: {
308: return m_request_header.isResponseExpected();
309: }
310:
311:
312: public void add_reply_service_context(ServiceContext service_context,
313: boolean replace
314: )
315: {
316: m_reply_header.addContext(service_context, replace);
317: }
318:
319:
322: public Any sending_exception()
323: {
324: if (m_usr_exception != null)
325: {
326: return m_usr_exception;
327: }
328: else if (m_sys_exception != null)
329: {
330: Any a = m_object.orb.create_any();
331: ObjectCreator.insertException(a, m_sys_exception);
332: return a;
333: }
334: else
335: {
336: return null;
337: }
338: }
339:
340: public org.omg.CORBA.Object forward_reference()
341: {
342: return m_forward_reference;
343: }
344:
345:
346: public ServiceContext get_reply_service_context(int ctx_name)
347: throws BAD_PARAM
348: {
349: return gnu.CORBA.GIOP.ServiceContext.findContext(ctx_name,
350: m_reply_header.service_context
351: );
352: }
353:
354:
355: public ServiceContext get_request_service_context(int ctx_name)
356: throws BAD_PARAM
357: {
358: return gnu.CORBA.GIOP.ServiceContext.findContext(ctx_name,
359: m_request_header.service_context
360: );
361: }
362:
363:
366: public String[] operation_context()
367: {
368: if (m_request == null)
369: {
370: throw new NO_RESOURCES(not_available);
371: }
372: else
373: {
374: return m_request.operation_context();
375: }
376: }
377:
378:
379: public Any result()
380: {
381: if (m_request == null)
382: {
383: throw new NO_RESOURCES(not_available);
384: }
385: else
386: {
387: return m_request.return_value();
388: }
389: }
390:
391:
392: public String[] contexts()
393: {
394: if (m_request == null)
395: {
396: throw new NO_RESOURCES(not_available);
397: }
398: else
399: {
400: return m_request.ice_contexts();
401: }
402: }
403:
404:
407: public short sync_scope()
408: {
409: return SYNC_WITH_TRANSPORT.value;
410: }
411:
412:
413: public Parameter[] arguments()
414: {
415: if (m_request == null)
416: {
417: throw new NO_RESOURCES(not_available);
418: }
419:
420: m_request.checkDii();
421:
422: NVList args = m_request.arguments();
423: Parameter[] p = new Parameter[ args.count() ];
424: try
425: {
426: for (int i = 0; i < p.length; i++)
427: {
428: ParameterMode mode;
429:
430: switch (args.item(i).flags())
431: {
432: case ARG_IN.value :
433: mode = ParameterMode.PARAM_IN;
434: break;
435:
436: case ARG_OUT.value :
437: mode = ParameterMode.PARAM_OUT;
438: break;
439:
440: case ARG_INOUT.value :
441: mode = ParameterMode.PARAM_INOUT;
442: break;
443:
444: default :
445: throw new Unexpected();
446: }
447:
448: p [ i ] = new Parameter(args.item(i).value(), mode);
449: }
450: }
451: catch (Bounds e)
452: {
453: throw new Unexpected(e);
454: }
455: return p;
456: }
457:
458:
459: public String[] adapter_name()
460: {
461: return m_object.poa.getReferenceTemplate().adapter_name();
462: }
463:
464:
465: public String orb_id()
466: {
467: return m_object.orb.orb_id;
468: }
469:
470:
471: public String server_id()
472: {
473: return OrbFunctional.server_id;
474: }
475:
476: }