OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [classpath/] [gnu/] [CORBA/] [Interceptor/] [gnuServerRequestInfo.java] - Blame information for rev 769

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 769 jeremybenn
/* gnuServerRequestInfo.java --
2
   Copyright (C) 2005 Free Software Foundation, Inc.
3
 
4
This file is part of GNU Classpath.
5
 
6
GNU Classpath is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2, or (at your option)
9
any later version.
10
 
11
GNU Classpath is distributed in the hope that it will be useful, but
12
WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
General Public License for more details.
15
 
16
You should have received a copy of the GNU General Public License
17
along with GNU Classpath; see the file COPYING.  If not, write to the
18
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19
02110-1301 USA.
20
 
21
Linking this library statically or dynamically with other modules is
22
making a combined work based on this library.  Thus, the terms and
23
conditions of the GNU General Public License cover the whole
24
combination.
25
 
26
As a special exception, the copyright holders of this library give you
27
permission to link this library with independent modules to produce an
28
executable, regardless of the license terms of these independent
29
modules, and to copy and distribute the resulting executable under
30
terms of your choice, provided that you also meet, for each linked
31
independent module, the terms and conditions of the license of that
32
module.  An independent module is a module which is not derived from
33
or based on this library.  If you modify this library, you may extend
34
this exception to your version of the library, but you are not
35
obligated to do so.  If you do not wish to do so, delete this
36
exception statement from your version. */
37
 
38
 
39
package gnu.CORBA.Interceptor;
40
 
41
import gnu.CORBA.GIOP.ReplyHeader;
42
import gnu.CORBA.GIOP.RequestHeader;
43
import gnu.CORBA.ObjectCreator;
44
import gnu.CORBA.Poa.gnuServantObject;
45
import gnu.CORBA.OrbFunctional;
46
import gnu.CORBA.Unexpected;
47
import gnu.CORBA.gnuRequest;
48
 
49
import org.omg.CORBA.ARG_IN;
50
import org.omg.CORBA.ARG_INOUT;
51
import org.omg.CORBA.ARG_OUT;
52
import org.omg.CORBA.Any;
53
import org.omg.CORBA.BAD_PARAM;
54
import org.omg.CORBA.Bounds;
55
import org.omg.CORBA.CompletionStatus;
56
import org.omg.CORBA.ExceptionList;
57
import org.omg.CORBA.INV_POLICY;
58
import org.omg.CORBA.LocalObject;
59
import org.omg.CORBA.NO_RESOURCES;
60
import org.omg.CORBA.NVList;
61
import org.omg.CORBA.Object;
62
import org.omg.CORBA.ParameterMode;
63
import org.omg.CORBA.Policy;
64
import org.omg.CORBA.TCKind;
65
import org.omg.CORBA.TypeCode;
66
import org.omg.Dynamic.Parameter;
67
import org.omg.IOP.ServiceContext;
68
import org.omg.Messaging.SYNC_WITH_TRANSPORT;
69
import org.omg.PortableInterceptor.InvalidSlot;
70
import org.omg.PortableInterceptor.ServerRequestInfo;
71
 
72
/**
73
 * Implementation of the ServerRequestInfo, associacted with gnuServantObject.
74
 *
75
 * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
76
 */
77
public class gnuServerRequestInfo extends LocalObject
78
  implements ServerRequestInfo
79
{
80
  /**
81
   * Use serialVersionUID for interoperability.
82
   */
83
  private static final long serialVersionUID = 1;
84
 
85
  /**
86
   * A local object that will serve the invocation.
87
   */
88
  final gnuServantObject m_object;
89
 
90
  /**
91
   * A message that the given resource is not available using this metod of
92
   * invocation.
93
   */
94
  static final String not_available =
95
    "The used invocation method provides" + "no access to this resource.";
96
 
97
  /**
98
   * An array of slots.
99
   */
100
  Any[] m_slots;
101
 
102
  /**
103
   * The request header.
104
   */
105
  public final RequestHeader m_request_header;
106
 
107
  /**
108
   * The reply header.
109
   */
110
  public final ReplyHeader m_reply_header;
111
 
112
  /**
113
   * The forward reference, if applicable.
114
   */
115
  public Object m_forward_reference;
116
 
117
  /**
118
   * The thrown systen exception.
119
   */
120
  public Exception m_sys_exception;
121
 
122
  /**
123
   * The Any, containing the thrown user exception.
124
   */
125
  public Any m_usr_exception;
126
 
127
  /**
128
   * The associated request, if any.
129
   */
130
  public gnuRequest m_request;
131
 
132
  /**
133
   * Create a new instance at the time when it is known which object will serve
134
   * the invocation.
135
   *
136
   * @param an_object a local object, connected to the local servant that will
137
   * serve the invocation.
138
   */
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
  /**
151
   * Set the give slot.
152
   */
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
  /**
168
   * Get the given slot.
169
   */
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
  /**
185
   * Reset slot data.
186
   */
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
  /**
201
   * Get the object id (not the object IOR key).
202
   */
203
  public byte[] object_id()
204
  {
205
    return m_object.Id;
206
  }
207
 
208
  /**
209
   * Check if the target is an instance of the type, represented by the given
210
   * repository Id.
211
   */
212
  public boolean target_is_a(String id)
213
  {
214
    return m_object._is_a(id);
215
  }
216
 
217
  /**
218
   * Get the POA id.
219
   */
220
  public byte[] adapter_id()
221
  {
222
    return m_object.poa.id();
223
  }
224
 
225
  /**
226
   * Get the POA policy of the given type that applies to the object being
227
   * served (request being handled).
228
   */
229
  public Policy get_server_policy(int type) throws INV_POLICY
230
  {
231
    return m_object.poa._get_policy(type);
232
  }
233
 
234
  /**
235
   * Get the first member of the object repository id array.
236
   */
237
  public String target_most_derived_interface()
238
  {
239
    return m_object._ids() [ 0 ];
240
  }
241
 
242
  /**
243
   * Get the name of the operation being performed.
244
   */
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
  /**
258
   * Not available.
259
   */
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
  /**
288
   * Get reply status.
289
   */
290
  public short reply_status()
291
  {
292
    return (short) m_reply_header.reply_status;
293
  }
294
 
295
  /**
296
   * Get request id. All local requests have request id = -1.
297
   */
298
  public int request_id()
299
  {
300
    return m_request_header.request_id;
301
  }
302
 
303
  /**
304
   * Check if the client expected any response.
305
   */
306
  public boolean response_expected()
307
  {
308
    return m_request_header.isResponseExpected();
309
  }
310
 
311
  /** @inheritDoc */
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
  /**
320
   * Get an exception, wrapped into Any.
321
   */
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
  /** @inheritDoc */
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
  /** @inheritDoc */
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
  /**
364
   * Not available
365
   */
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
  /** @inheritDoc */
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
  /** @inheritDoc */
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
  /**
405
   * Always returns "with transport".
406
   */
407
  public short sync_scope()
408
  {
409
    return SYNC_WITH_TRANSPORT.value;
410
  }
411
 
412
  /** @inheritDoc */
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
  /** @inheritDoc */
459
  public String[] adapter_name()
460
  {
461
    return m_object.poa.getReferenceTemplate().adapter_name();
462
  }
463
 
464
  /** @inheritDoc */
465
  public String orb_id()
466
  {
467
    return m_object.orb.orb_id;
468
  }
469
 
470
  /** @inheritDoc */
471
  public String server_id()
472
  {
473
    return OrbFunctional.server_id;
474
  }
475
 
476
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.