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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libjava/] [classpath/] [org/] [omg/] [CosNaming/] [_NamingContextStub.java] - Blame information for rev 14

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 14 jlechner
/* _NamingContextStub.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 org.omg.CosNaming;
40
 
41
import org.omg.CORBA.MARSHAL;
42
import org.omg.CORBA.ORB;
43
import org.omg.CORBA.ObjectHelper;
44
import org.omg.CORBA.portable.ApplicationException;
45
import org.omg.CORBA.portable.Delegate;
46
import org.omg.CORBA.portable.InputStream;
47
import org.omg.CORBA.portable.ObjectImpl;
48
import org.omg.CORBA.portable.OutputStream;
49
import org.omg.CORBA.portable.RemarshalException;
50
import org.omg.CosNaming.NamingContextPackage.AlreadyBound;
51
import org.omg.CosNaming.NamingContextPackage.AlreadyBoundHelper;
52
import org.omg.CosNaming.NamingContextPackage.CannotProceed;
53
import org.omg.CosNaming.NamingContextPackage.CannotProceedHelper;
54
import org.omg.CosNaming.NamingContextPackage.InvalidName;
55
import org.omg.CosNaming.NamingContextPackage.InvalidNameHelper;
56
import org.omg.CosNaming.NamingContextPackage.NotEmpty;
57
import org.omg.CosNaming.NamingContextPackage.NotEmptyHelper;
58
import org.omg.CosNaming.NamingContextPackage.NotFound;
59
import org.omg.CosNaming.NamingContextPackage.NotFoundHelper;
60
 
61
/**
62
 * The naming context stub (proxy), used on the client side.
63
 * The {@link NamingContext} methods contain the code for remote
64
 * invocaton.
65
 *
66
 * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
67
 */
68
public class _NamingContextStub
69
  extends ObjectImpl
70
  implements NamingContext
71
{
72
  /**
73
   * Use serialVersionUID (v1.4) for interoperability.
74
   */
75
  private static final long serialVersionUID = 6835430958405349379L;
76
 
77
  /**
78
   * Create the naming context stub.
79
   */
80
  public _NamingContextStub()
81
  {
82
    super();
83
  }
84
 
85
  /**
86
   * Create the naming context stub with the given delegate.
87
   */
88
  public _NamingContextStub(Delegate delegate)
89
  {
90
    super();
91
    _set_delegate(delegate);
92
  }
93
 
94
  /**
95
   * Return the array of repository ids for this object.
96
   */
97
  public String[] _ids()
98
  {
99
    return new String[] { NamingContextHelper.id() };
100
  }
101
 
102
  /** {@inheritDoc} */
103
  public void bind(NameComponent[] a_name, org.omg.CORBA.Object an_object)
104
            throws NotFound, CannotProceed, InvalidName, AlreadyBound
105
  {
106
    InputStream in = null;
107
    try
108
      {
109
        OutputStream out = _request("bind", true);
110
        NameHelper.write(out, a_name);
111
        ObjectHelper.write(out, an_object);
112
        in = _invoke(out);
113
      }
114
    catch (ApplicationException ex)
115
      {
116
        in = ex.getInputStream();
117
 
118
        String id = ex.getId();
119
        throw5(in, id);
120
      }
121
    catch (RemarshalException remarsh)
122
      {
123
        bind(a_name, an_object);
124
      }
125
    finally
126
      {
127
        _releaseReply(in);
128
      }
129
  }
130
 
131
  /** {@inheritDoc} */
132
  public void bind_context(NameComponent[] a_name, NamingContext a_context)
133
                    throws NotFound, CannotProceed, InvalidName, AlreadyBound
134
  {
135
    InputStream in = null;
136
    try
137
      {
138
        OutputStream out = _request("bind_context", true);
139
        NameHelper.write(out, a_name);
140
        NamingContextHelper.write(out, a_context);
141
        in = _invoke(out);
142
      }
143
    catch (ApplicationException ex)
144
      {
145
        in = ex.getInputStream();
146
 
147
        String id = ex.getId();
148
        throw5(in, id);
149
      }
150
    catch (RemarshalException remarsh)
151
      {
152
        bind_context(a_name, a_context);
153
      }
154
    finally
155
      {
156
        _releaseReply(in);
157
      }
158
  }
159
 
160
  /** {@inheritDoc} */
161
  public NamingContext bind_new_context(NameComponent[] a_name)
162
                                 throws NotFound, AlreadyBound, CannotProceed,
163
                                        InvalidName
164
  {
165
    InputStream in = null;
166
    try
167
      {
168
        OutputStream out = _request("bind_new_context", true);
169
        NameHelper.write(out, a_name);
170
        in = _invoke(out);
171
 
172
        NamingContext __result = NamingContextHelper.read(in);
173
        return __result;
174
      }
175
    catch (ApplicationException ex)
176
      {
177
        in = ex.getInputStream();
178
 
179
        String id = ex.getId();
180
        throw5(in, id);
181
        throw new InternalError();
182
      }
183
    catch (RemarshalException remarsh)
184
      {
185
        return bind_new_context(a_name);
186
      }
187
    finally
188
      {
189
        _releaseReply(in);
190
      }
191
  }
192
 
193
  /** {@inheritDoc} */
194
  public void destroy()
195
               throws NotEmpty
196
  {
197
    InputStream in = null;
198
    try
199
      {
200
        OutputStream out = _request("destroy", true);
201
        in = _invoke(out);
202
      }
203
    catch (ApplicationException ex)
204
      {
205
        in = ex.getInputStream();
206
 
207
        String id = ex.getId();
208
        if (id.equals(NotEmptyHelper.id()))
209
          throw NotEmptyHelper.read(in);
210
        else
211
          throw new MARSHAL(id);
212
      }
213
    catch (RemarshalException remarsh)
214
      {
215
        destroy();
216
      }
217
    finally
218
      {
219
        _releaseReply(in);
220
      }
221
  }
222
 
223
  /** {@inheritDoc} */
224
  public void list(int amount, BindingListHolder a_list,
225
                   BindingIteratorHolder an_iter
226
                  )
227
  {
228
    InputStream in = null;
229
    try
230
      {
231
        OutputStream out = _request("list", true);
232
        out.write_ulong(amount);
233
        in = _invoke(out);
234
        a_list.value = BindingListHelper.read(in);
235
        an_iter.value = BindingIteratorHelper.read(in);
236
      }
237
    catch (ApplicationException ex)
238
      {
239
        in = ex.getInputStream();
240
        throw new MARSHAL(ex.getId());
241
      }
242
    catch (RemarshalException remarsh)
243
      {
244
        list(amount, a_list, an_iter);
245
      }
246
    finally
247
      {
248
        _releaseReply(in);
249
      }
250
  }
251
 
252
  /** {@inheritDoc} */
253
  public NamingContext new_context()
254
  {
255
    InputStream in = null;
256
    try
257
      {
258
        OutputStream out = _request("new_context", true);
259
        in = _invoke(out);
260
 
261
        NamingContext __result = NamingContextHelper.read(in);
262
        return __result;
263
      }
264
    catch (ApplicationException ex)
265
      {
266
        in = ex.getInputStream();
267
        throw new MARSHAL(ex.getId());
268
      }
269
    catch (RemarshalException remarsh)
270
      {
271
        return new_context();
272
      }
273
    finally
274
      {
275
        _releaseReply(in);
276
      }
277
  }
278
 
279
  /** {@inheritDoc} */
280
  public void rebind(NameComponent[] a_name, org.omg.CORBA.Object an_object)
281
              throws NotFound, CannotProceed, InvalidName
282
  {
283
    InputStream in = null;
284
    try
285
      {
286
        OutputStream out = _request("rebind", true);
287
        NameHelper.write(out, a_name);
288
        ObjectHelper.write(out, an_object);
289
        in = _invoke(out);
290
      }
291
    catch (ApplicationException ex)
292
      {
293
        in = ex.getInputStream();
294
 
295
        String id = ex.getId();
296
        throw4(in, id);
297
      }
298
    catch (RemarshalException remarsh)
299
      {
300
        rebind(a_name, an_object);
301
      }
302
    finally
303
      {
304
        _releaseReply(in);
305
      }
306
  }
307
 
308
  /** {@inheritDoc} */
309
  public void rebind_context(NameComponent[] a_name, NamingContext a_context)
310
                      throws NotFound, CannotProceed, InvalidName
311
  {
312
    InputStream in = null;
313
    try
314
      {
315
        OutputStream out = _request("rebind_context", true);
316
        NameHelper.write(out, a_name);
317
        NamingContextHelper.write(out, a_context);
318
        in = _invoke(out);
319
      }
320
    catch (ApplicationException ex)
321
      {
322
        in = ex.getInputStream();
323
 
324
        String id = ex.getId();
325
        throw4(in, id);
326
      }
327
    catch (RemarshalException remarsh)
328
      {
329
        rebind_context(a_name, a_context);
330
      }
331
    finally
332
      {
333
        _releaseReply(in);
334
      }
335
  }
336
 
337
  /** {@inheritDoc} */
338
  public org.omg.CORBA.Object resolve(NameComponent[] a_name)
339
                               throws NotFound, CannotProceed, InvalidName
340
  {
341
    InputStream in = null;
342
    try
343
      {
344
        OutputStream out = _request("resolve", true);
345
        NameHelper.write(out, a_name);
346
        in = _invoke(out);
347
 
348
        org.omg.CORBA.Object __result = ObjectHelper.read(in);
349
        return __result;
350
      }
351
    catch (ApplicationException ex)
352
      {
353
        in = ex.getInputStream();
354
 
355
        String id = ex.getId();
356
        throw4(in, id);
357
        throw new InternalError();
358
      }
359
    catch (RemarshalException remarsh)
360
      {
361
        return resolve(a_name);
362
      }
363
    finally
364
      {
365
        _releaseReply(in);
366
      }
367
  }
368
 
369
  /** {@inheritDoc} */
370
  public void unbind(NameComponent[] a_name)
371
              throws NotFound, CannotProceed, InvalidName
372
  {
373
    InputStream in = null;
374
    try
375
      {
376
        OutputStream out = _request("unbind", true);
377
        NameHelper.write(out, a_name);
378
        in = _invoke(out);
379
      }
380
    catch (ApplicationException ex)
381
      {
382
        in = ex.getInputStream();
383
 
384
        String id = ex.getId();
385
        if (id.equals(NotFoundHelper.id()))
386
          throw NotFoundHelper.read(in);
387
        else if (id.equals(CannotProceedHelper.id()))
388
          throw CannotProceedHelper.read(in);
389
        else if (id.equals(InvalidNameHelper.id()))
390
          throw InvalidNameHelper.read(in);
391
        else
392
          throw new MARSHAL(id);
393
      }
394
    catch (RemarshalException remarsh)
395
      {
396
        unbind(a_name);
397
      }
398
    finally
399
      {
400
        _releaseReply(in);
401
      }
402
  }
403
 
404
  /**
405
   * Throw one of the three possible exceptions, as specified in
406
   * the passed exception repository id.
407
   *
408
   * This method should never return normally.
409
   *
410
   * @param in the stream to read the exception from.
411
   * @param id the exception id.
412
   *
413
   * @throws InvalidName if the id matches.
414
   * @throws CannotProceed if the id matches.
415
   * @throws NotFound if the id matches.
416
   * @throws MARSHAL if the id does not match any of the previous 4 exceptions.
417
   */
418
  protected void throw4(InputStream in, String id)
419
                 throws MARSHAL, InvalidName, CannotProceed, NotFound
420
  {
421
    if (id.equals(NotFoundHelper.id()))
422
      throw NotFoundHelper.read(in);
423
    else if (id.equals(CannotProceedHelper.id()))
424
      throw CannotProceedHelper.read(in);
425
    else if (id.equals(InvalidNameHelper.id()))
426
      throw InvalidNameHelper.read(in);
427
    else
428
      throw new MARSHAL(id);
429
  }
430
 
431
  /**
432
   * Throw one of the five possible exceptions, as specified in
433
   * the passed exception repository id.
434
   *
435
   * This method should never return normally.
436
   *
437
   * @param in the stream to read the exception from.
438
   * @param id the exception id.
439
   *
440
   * @throws AlreadyBound if the id matches.
441
   * @throws InvalidName if the id matches.
442
   * @throws CannotProceed if the id matches.
443
   * @throws NotFound if the id matches.
444
   * @throws MARSHAL if the id does not match any of the previous 4 exceptions.
445
   */
446
  protected void throw5(InputStream in, String id)
447
                 throws MARSHAL, AlreadyBound, InvalidName, CannotProceed,
448
                        NotFound
449
  {
450
    if (id.equals(AlreadyBoundHelper.id()))
451
      throw AlreadyBoundHelper.read(in);
452
    else
453
      throw4(in, id);
454
  }
455
}

powered by: WebSVN 2.1.0

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