KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > omg > CosNaming > NamingContextPOA


1 package org.omg.CosNaming;
2
3
4 /**
5 * org/omg/CosNaming/NamingContextPOA.java .
6 * Generated by the IDL-to-Java compiler (portable), version "3.2"
7 * from ../../../../src/share/classes/org/omg/CosNaming/nameservice.idl
8 * Saturday, February 9, 2008 9:40:10 AM GMT
9 */

10
11
12 /**
13  * A naming context is an object that contains a set of name bindings in
14  * which each name is unique. Different names can be bound to an object
15  * in the same or different contexts at the same time. <p>
16  *
17  * See <a HREF="http://www.omg.org/technology/documents/formal/naming_service.htm">
18  * CORBA COS
19  * Naming Specification.</a>
20  */

21 public abstract class NamingContextPOA extends org.omg.PortableServer.Servant JavaDoc
22  implements org.omg.CosNaming.NamingContextOperations JavaDoc, org.omg.CORBA.portable.InvokeHandler JavaDoc
23 {
24
25   // Constructors
26

27   private static java.util.Hashtable JavaDoc _methods = new java.util.Hashtable JavaDoc ();
28   static
29   {
30     _methods.put ("bind", new java.lang.Integer JavaDoc (0));
31     _methods.put ("bind_context", new java.lang.Integer JavaDoc (1));
32     _methods.put ("rebind", new java.lang.Integer JavaDoc (2));
33     _methods.put ("rebind_context", new java.lang.Integer JavaDoc (3));
34     _methods.put ("resolve", new java.lang.Integer JavaDoc (4));
35     _methods.put ("unbind", new java.lang.Integer JavaDoc (5));
36     _methods.put ("list", new java.lang.Integer JavaDoc (6));
37     _methods.put ("new_context", new java.lang.Integer JavaDoc (7));
38     _methods.put ("bind_new_context", new java.lang.Integer JavaDoc (8));
39     _methods.put ("destroy", new java.lang.Integer JavaDoc (9));
40   }
41
42   public org.omg.CORBA.portable.OutputStream JavaDoc _invoke (String JavaDoc $method,
43                                 org.omg.CORBA.portable.InputStream JavaDoc in,
44                                 org.omg.CORBA.portable.ResponseHandler JavaDoc $rh)
45   {
46     org.omg.CORBA.portable.OutputStream JavaDoc out = null;
47     java.lang.Integer JavaDoc __method = (java.lang.Integer JavaDoc)_methods.get ($method);
48     if (__method == null)
49       throw new org.omg.CORBA.BAD_OPERATION JavaDoc (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
50
51     switch (__method.intValue ())
52     {
53
54   /**
55  * Creates a binding of a name and an object in the naming context.
56  * Naming contexts that are bound using bind do not participate in name
57  * resolution when compound names are passed to be resolved.
58  *
59  * @param n Name of the object <p>
60  *
61  * @param obj The Object to bind with the given name<p>
62  *
63  * @exception org.omg.CosNaming.NamingContextPackage.NotFound Indicates
64  * the name does not identify a binding.<p>
65  *
66  * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed
67  * Indicates that the implementation has given up for some reason.
68  * The client, however, may be able to continue the operation
69  * at the returned naming context.<p>
70  *
71  * @exception org.omg.CosNaming.NamingContextPackage.InvalidName
72  * Indicates that the name is invalid. <p>
73  *
74  * @exception org.omg.CosNaming.NamingContextPackage.AlreadyBound
75  * Indicates an object is already bound to the specified name.<p>
76  */

77        case 0: // CosNaming/NamingContext/bind
78
{
79          try {
80            org.omg.CosNaming.NameComponent JavaDoc n[] = org.omg.CosNaming.NameHelper.read (in);
81            org.omg.CORBA.Object JavaDoc obj = org.omg.CORBA.ObjectHelper.read (in);
82            this.bind (n, obj);
83            out = $rh.createReply();
84          } catch (org.omg.CosNaming.NamingContextPackage.NotFound JavaDoc $ex) {
85            out = $rh.createExceptionReply ();
86            org.omg.CosNaming.NamingContextPackage.NotFoundHelper.write (out, $ex);
87          } catch (org.omg.CosNaming.NamingContextPackage.CannotProceed JavaDoc $ex) {
88            out = $rh.createExceptionReply ();
89            org.omg.CosNaming.NamingContextPackage.CannotProceedHelper.write (out, $ex);
90          } catch (org.omg.CosNaming.NamingContextPackage.InvalidName JavaDoc $ex) {
91            out = $rh.createExceptionReply ();
92            org.omg.CosNaming.NamingContextPackage.InvalidNameHelper.write (out, $ex);
93          } catch (org.omg.CosNaming.NamingContextPackage.AlreadyBound JavaDoc $ex) {
94            out = $rh.createExceptionReply ();
95            org.omg.CosNaming.NamingContextPackage.AlreadyBoundHelper.write (out, $ex);
96          }
97          break;
98        }
99
100
101   /**
102  * Names an object that is a naming context. Naming contexts that
103  * are bound using bind_context() participate in name resolution
104  * when compound names are passed to be resolved.
105  *
106  * @param n Name of the object <p>
107  *
108  * @param nc NamingContect object to bind with the given name <p>
109  *
110  * @exception org.omg.CosNaming.NamingContextPackage.NotFound Indicates the name does not identify a binding.<p>
111  *
112  * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed Indicates that the implementation has
113  * given up for some reason. The client, however, may be able to
114  * continue the operation at the returned naming context.<p>
115  *
116  * @exception org.omg.CosNaming.NamingContextPackage.InvalidName Indicates that the name is invalid. <p>
117  *
118  * @exception org.omg.CosNaming.NamingContextPackage.AlreadyBound Indicates an object is already
119  * bound to the specified name.<p>
120  */

121        case 1: // CosNaming/NamingContext/bind_context
122
{
123          try {
124            org.omg.CosNaming.NameComponent JavaDoc n[] = org.omg.CosNaming.NameHelper.read (in);
125            org.omg.CosNaming.NamingContext JavaDoc nc = org.omg.CosNaming.NamingContextHelper.read (in);
126            this.bind_context (n, nc);
127            out = $rh.createReply();
128          } catch (org.omg.CosNaming.NamingContextPackage.NotFound JavaDoc $ex) {
129            out = $rh.createExceptionReply ();
130            org.omg.CosNaming.NamingContextPackage.NotFoundHelper.write (out, $ex);
131          } catch (org.omg.CosNaming.NamingContextPackage.CannotProceed JavaDoc $ex) {
132            out = $rh.createExceptionReply ();
133            org.omg.CosNaming.NamingContextPackage.CannotProceedHelper.write (out, $ex);
134          } catch (org.omg.CosNaming.NamingContextPackage.InvalidName JavaDoc $ex) {
135            out = $rh.createExceptionReply ();
136            org.omg.CosNaming.NamingContextPackage.InvalidNameHelper.write (out, $ex);
137          } catch (org.omg.CosNaming.NamingContextPackage.AlreadyBound JavaDoc $ex) {
138            out = $rh.createExceptionReply ();
139            org.omg.CosNaming.NamingContextPackage.AlreadyBoundHelper.write (out, $ex);
140          }
141          break;
142        }
143
144
145   /**
146  * Creates a binding of a name and an object in the naming context
147  * even if the name is already bound in the context. Naming contexts
148  * that are bound using rebind do not participate in name resolution
149  * when compound names are passed to be resolved.
150  *
151  * @param n Name of the object <p>
152  *
153  * @parm obj The Object to rebind with the given name <p>
154  *
155  * @exception org.omg.CosNaming.NamingContextPackage.NotFound Indicates the name does not identify a binding.<p>
156  *
157  * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed Indicates that the implementation has
158  * given up for some reason. The client, however, may be able to
159  * continue the operation at the returned naming context.<p>
160  *
161  * @exception org.omg.CosNaming.NamingContextPackage.InvalidName Indicates that the name is invalid. <p>
162  */

163        case 2: // CosNaming/NamingContext/rebind
164
{
165          try {
166            org.omg.CosNaming.NameComponent JavaDoc n[] = org.omg.CosNaming.NameHelper.read (in);
167            org.omg.CORBA.Object JavaDoc obj = org.omg.CORBA.ObjectHelper.read (in);
168            this.rebind (n, obj);
169            out = $rh.createReply();
170          } catch (org.omg.CosNaming.NamingContextPackage.NotFound JavaDoc $ex) {
171            out = $rh.createExceptionReply ();
172            org.omg.CosNaming.NamingContextPackage.NotFoundHelper.write (out, $ex);
173          } catch (org.omg.CosNaming.NamingContextPackage.CannotProceed JavaDoc $ex) {
174            out = $rh.createExceptionReply ();
175            org.omg.CosNaming.NamingContextPackage.CannotProceedHelper.write (out, $ex);
176          } catch (org.omg.CosNaming.NamingContextPackage.InvalidName JavaDoc $ex) {
177            out = $rh.createExceptionReply ();
178            org.omg.CosNaming.NamingContextPackage.InvalidNameHelper.write (out, $ex);
179          }
180          break;
181        }
182
183
184   /**
185  * Creates a binding of a name and a naming context in the naming
186  * context even if the name is already bound in the context. Naming
187  * contexts that are bound using rebind_context() participate in name
188  * resolution when compound names are passed to be resolved.
189  *
190  * @param n Name of the object <p>
191  *
192  * @param nc NamingContect object to rebind with the given name <p>
193  *
194  * @exception org.omg.CosNaming.NamingContextPackage.NotFound Indicates the name does not identify a binding.<p>
195  *
196  * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed Indicates that the implementation has
197  * given up for some reason. The client, however, may be able to
198  * continue the operation at the returned naming context.<p>
199  *
200  * @exception org.omg.CosNaming.NamingContextPackage.InvalidName Indicates that the name is invalid. <p>
201  */

202        case 3: // CosNaming/NamingContext/rebind_context
203
{
204          try {
205            org.omg.CosNaming.NameComponent JavaDoc n[] = org.omg.CosNaming.NameHelper.read (in);
206            org.omg.CosNaming.NamingContext JavaDoc nc = org.omg.CosNaming.NamingContextHelper.read (in);
207            this.rebind_context (n, nc);
208            out = $rh.createReply();
209          } catch (org.omg.CosNaming.NamingContextPackage.NotFound JavaDoc $ex) {
210            out = $rh.createExceptionReply ();
211            org.omg.CosNaming.NamingContextPackage.NotFoundHelper.write (out, $ex);
212          } catch (org.omg.CosNaming.NamingContextPackage.CannotProceed JavaDoc $ex) {
213            out = $rh.createExceptionReply ();
214            org.omg.CosNaming.NamingContextPackage.CannotProceedHelper.write (out, $ex);
215          } catch (org.omg.CosNaming.NamingContextPackage.InvalidName JavaDoc $ex) {
216            out = $rh.createExceptionReply ();
217            org.omg.CosNaming.NamingContextPackage.InvalidNameHelper.write (out, $ex);
218          }
219          break;
220        }
221
222
223   /**
224  * The resolve operation is the process of retrieving an object
225  * bound to a name in a given context. The given name must exactly
226  * match the bound name. The naming service does not return the type
227  * of the object. Clients are responsible for "narrowing" the object
228  * to the appropriate type. That is, clients typically cast the returned
229  * object from Object to a more specialized interface.
230  *
231  * @param n Name of the object <p>
232  *
233  * @exception org.omg.CosNaming.NamingContextPackage.NotFound Indicates the name does not identify a binding.<p>
234  *
235  * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed Indicates that the implementation has
236  * given up for some reason. The client, however, may be able to
237  * continue the operation at the returned naming context.<p>
238  *
239  * @exception org.omg.CosNaming.NamingContextPackage.InvalidName Indicates that the name is invalid. <p>
240  */

241        case 4: // CosNaming/NamingContext/resolve
242
{
243          try {
244            org.omg.CosNaming.NameComponent JavaDoc n[] = org.omg.CosNaming.NameHelper.read (in);
245            org.omg.CORBA.Object JavaDoc $result = null;
246            $result = this.resolve (n);
247            out = $rh.createReply();
248            org.omg.CORBA.ObjectHelper.write (out, $result);
249          } catch (org.omg.CosNaming.NamingContextPackage.NotFound JavaDoc $ex) {
250            out = $rh.createExceptionReply ();
251            org.omg.CosNaming.NamingContextPackage.NotFoundHelper.write (out, $ex);
252          } catch (org.omg.CosNaming.NamingContextPackage.CannotProceed JavaDoc $ex) {
253            out = $rh.createExceptionReply ();
254            org.omg.CosNaming.NamingContextPackage.CannotProceedHelper.write (out, $ex);
255          } catch (org.omg.CosNaming.NamingContextPackage.InvalidName JavaDoc $ex) {
256            out = $rh.createExceptionReply ();
257            org.omg.CosNaming.NamingContextPackage.InvalidNameHelper.write (out, $ex);
258          }
259          break;
260        }
261
262
263   /**
264  * The unbind operation removes a name binding from a context.
265  *
266  * @param n Name of the object <p>
267  *
268  * @exception org.omg.CosNaming.NamingContextPackage.NotFound Indicates the name does not identify a binding.<p>
269  *
270  * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed Indicates that the implementation has
271  * given up for some reason. The client, however, may be able to
272  * continue the operation at the returned naming context.<p>
273  *
274  * @exception org.omg.CosNaming.NamingContextPackage.InvalidName Indicates that the name is invalid. <p>
275  */

276        case 5: // CosNaming/NamingContext/unbind
277
{
278          try {
279            org.omg.CosNaming.NameComponent JavaDoc n[] = org.omg.CosNaming.NameHelper.read (in);
280            this.unbind (n);
281            out = $rh.createReply();
282          } catch (org.omg.CosNaming.NamingContextPackage.NotFound JavaDoc $ex) {
283            out = $rh.createExceptionReply ();
284            org.omg.CosNaming.NamingContextPackage.NotFoundHelper.write (out, $ex);
285          } catch (org.omg.CosNaming.NamingContextPackage.CannotProceed JavaDoc $ex) {
286            out = $rh.createExceptionReply ();
287            org.omg.CosNaming.NamingContextPackage.CannotProceedHelper.write (out, $ex);
288          } catch (org.omg.CosNaming.NamingContextPackage.InvalidName JavaDoc $ex) {
289            out = $rh.createExceptionReply ();
290            org.omg.CosNaming.NamingContextPackage.InvalidNameHelper.write (out, $ex);
291          }
292          break;
293        }
294
295
296   /**
297  * The list operation allows a client to iterate through a set of
298  * bindings in a naming context. <p>
299  *
300  * The list operation returns at most the requested number of
301  * bindings in BindingList bl.
302  * <ul>
303  * <li>If the naming context contains additional
304  * bindings, the list operation returns a BindingIterator with the
305  * additional bindings.
306  * <li>If the naming context does not contain additional
307  * bindings, the binding iterator is a nil object reference.
308  * </ul>
309  *
310  * @param how_many the maximum number of bindings to return <p>
311  *
312  * @param bl the returned list of bindings <p>
313  *
314  * @param bi the returned binding iterator <p>
315  */

316        case 6: // CosNaming/NamingContext/list
317
{
318          int how_many = in.read_ulong ();
319          org.omg.CosNaming.BindingListHolder JavaDoc bl = new org.omg.CosNaming.BindingListHolder JavaDoc ();
320          org.omg.CosNaming.BindingIteratorHolder JavaDoc bi = new org.omg.CosNaming.BindingIteratorHolder JavaDoc ();
321          this.list (how_many, bl, bi);
322          out = $rh.createReply();
323          org.omg.CosNaming.BindingListHelper.write (out, bl.value);
324          org.omg.CosNaming.BindingIteratorHelper.write (out, bi.value);
325          break;
326        }
327
328
329   /**
330  * This operation returns a naming context implemented by the same
331  * naming server as the context on which the operation was invoked.
332  * The new context is not bound to any name.
333  */

334        case 7: // CosNaming/NamingContext/new_context
335
{
336          org.omg.CosNaming.NamingContext JavaDoc $result = null;
337          $result = this.new_context ();
338          out = $rh.createReply();
339          org.omg.CosNaming.NamingContextHelper.write (out, $result);
340          break;
341        }
342
343
344   /**
345  * This operation creates a new context and binds it to the name
346  * supplied as an argument. The newly-created context is implemented
347  * by the same naming server as the context in which it was bound (that
348  * is, the naming server that implements the context denoted by the
349  * name argument excluding the last component).
350  *
351  * @param n Name of the object <p>
352  *
353  * @exception org.omg.CosNaming.NamingContextPackage.NotFound Indicates the name does not identify a binding.<p>
354  *
355  * @exception org.omg.CosNaming.NamingContextPackage.AlreadyBound Indicates an object is already
356  * bound to the specified name.<p>
357  *
358  * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed Indicates that the implementation has
359  * given up for some reason. The client, however, may be able to
360  * continue the operation at the returned naming context.<p>
361  *
362  * @exception org.omg.CosNaming.NamingContextPackage.InvalidName Indicates that the name is invalid. <p>
363  */

364        case 8: // CosNaming/NamingContext/bind_new_context
365
{
366          try {
367            org.omg.CosNaming.NameComponent JavaDoc n[] = org.omg.CosNaming.NameHelper.read (in);
368            org.omg.CosNaming.NamingContext JavaDoc $result = null;
369            $result = this.bind_new_context (n);
370            out = $rh.createReply();
371            org.omg.CosNaming.NamingContextHelper.write (out, $result);
372          } catch (org.omg.CosNaming.NamingContextPackage.NotFound JavaDoc $ex) {
373            out = $rh.createExceptionReply ();
374            org.omg.CosNaming.NamingContextPackage.NotFoundHelper.write (out, $ex);
375          } catch (org.omg.CosNaming.NamingContextPackage.AlreadyBound JavaDoc $ex) {
376            out = $rh.createExceptionReply ();
377            org.omg.CosNaming.NamingContextPackage.AlreadyBoundHelper.write (out, $ex);
378          } catch (org.omg.CosNaming.NamingContextPackage.CannotProceed JavaDoc $ex) {
379            out = $rh.createExceptionReply ();
380            org.omg.CosNaming.NamingContextPackage.CannotProceedHelper.write (out, $ex);
381          } catch (org.omg.CosNaming.NamingContextPackage.InvalidName JavaDoc $ex) {
382            out = $rh.createExceptionReply ();
383            org.omg.CosNaming.NamingContextPackage.InvalidNameHelper.write (out, $ex);
384          }
385          break;
386        }
387
388
389   /**
390  * The destroy operation deletes a naming context. If the naming
391  * context contains bindings, the NotEmpty exception is raised.
392  *
393  * @exception org.omg.CosNaming.NamingContextPackage.NotEmpty Indicates that the Naming Context contains bindings.
394  */

395        case 9: // CosNaming/NamingContext/destroy
396
{
397          try {
398            this.destroy ();
399            out = $rh.createReply();
400          } catch (org.omg.CosNaming.NamingContextPackage.NotEmpty JavaDoc $ex) {
401            out = $rh.createExceptionReply ();
402            org.omg.CosNaming.NamingContextPackage.NotEmptyHelper.write (out, $ex);
403          }
404          break;
405        }
406
407        default:
408          throw new org.omg.CORBA.BAD_OPERATION JavaDoc (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
409     }
410
411     return out;
412   } // _invoke
413

414   // Type-specific CORBA::Object operations
415
private static String JavaDoc[] __ids = {
416     "IDL:omg.org/CosNaming/NamingContext:1.0"};
417
418   public String JavaDoc[] _all_interfaces (org.omg.PortableServer.POA JavaDoc poa, byte[] objectId)
419   {
420     return (String JavaDoc[])__ids.clone ();
421   }
422
423   public NamingContext JavaDoc _this()
424   {
425     return NamingContextHelper.narrow(
426     super._this_object());
427   }
428
429   public NamingContext JavaDoc _this(org.omg.CORBA.ORB JavaDoc orb)
430   {
431     return NamingContextHelper.narrow(
432     super._this_object(orb));
433   }
434
435
436 } // class NamingContextPOA
437
Popular Tags