Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / libjava / classpath / org / omg / CosNaming / NamingContextPOA.java
bloba97888276422534fbcc077c63f7a26e3ab79af46
1 /* NamingContextPOA.java --
2 Copyright (C) 2005 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
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.
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.
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.
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.
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. */
39 package org.omg.CosNaming;
41 import gnu.CORBA.Minor;
43 import org.omg.CORBA.BAD_OPERATION;
44 import org.omg.CORBA.CompletionStatus;
45 import org.omg.CORBA.ObjectHelper;
46 import org.omg.CORBA.portable.InputStream;
47 import org.omg.CORBA.portable.InvokeHandler;
48 import org.omg.CORBA.portable.OutputStream;
49 import org.omg.CORBA.portable.ResponseHandler;
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 import org.omg.PortableServer.POA;
61 import org.omg.PortableServer.Servant;
63 /**
64 * The naming service servant. After implementing the abstract methods the
65 * instance of this class can be connected to an ORB using POA.
67 * @since 1.4
69 * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
71 public abstract class NamingContextPOA
72 extends Servant
73 implements NamingContextOperations, InvokeHandler
75 /** @inheritDoc */
76 public String[] _all_interfaces(POA poa, byte[] object_ID)
78 return new String[] { NamingContextHelper.id() };
81 /**
82 * The server calls this method after receiving the request message from
83 * client. The implementation base calls one of its abstract methods to
84 * perform the requested operation.
86 * @param method the method being invoked.
87 * @param in the stream to read parameters from.
88 * @param rh the handler to get a stream for writing a response.
90 * @return the stream, returned by the handler.
92 public OutputStream _invoke(String method, InputStream in, ResponseHandler rh)
94 OutputStream out = null;
95 Integer call_method = (Integer) _NamingContextImplBase.methods.get(method);
96 if (call_method == null)
97 throw new BAD_OPERATION(Minor.Method, CompletionStatus.COMPLETED_MAYBE);
99 switch (call_method.intValue())
101 case 0: // bind
105 NameComponent[] a_name = NameHelper.read(in);
106 org.omg.CORBA.Object an_object = ObjectHelper.read(in);
107 bind(a_name, an_object);
108 out = rh.createReply();
110 catch (NotFound ex)
112 out = rh.createExceptionReply();
113 NotFoundHelper.write(out, ex);
115 catch (CannotProceed ex)
117 out = rh.createExceptionReply();
118 CannotProceedHelper.write(out, ex);
120 catch (InvalidName ex)
122 out = rh.createExceptionReply();
123 InvalidNameHelper.write(out, ex);
125 catch (AlreadyBound ex)
127 out = rh.createExceptionReply();
128 AlreadyBoundHelper.write(out, ex);
130 break;
133 case 1: // rebind
137 NameComponent[] a_name = NameHelper.read(in);
138 org.omg.CORBA.Object an_object = ObjectHelper.read(in);
139 rebind(a_name, an_object);
140 out = rh.createReply();
142 catch (NotFound ex)
144 out = rh.createExceptionReply();
145 NotFoundHelper.write(out, ex);
147 catch (CannotProceed ex)
149 out = rh.createExceptionReply();
150 CannotProceedHelper.write(out, ex);
152 catch (InvalidName ex)
154 out = rh.createExceptionReply();
155 InvalidNameHelper.write(out, ex);
157 break;
160 case 2: // bind_context
164 NameComponent[] a_name = NameHelper.read(in);
165 NamingContext a_context = NamingContextHelper.read(in);
166 bind_context(a_name, a_context);
167 out = rh.createReply();
169 catch (NotFound ex)
171 out = rh.createExceptionReply();
172 NotFoundHelper.write(out, ex);
174 catch (CannotProceed ex)
176 out = rh.createExceptionReply();
177 CannotProceedHelper.write(out, ex);
179 catch (InvalidName ex)
181 out = rh.createExceptionReply();
182 InvalidNameHelper.write(out, ex);
184 catch (AlreadyBound ex)
186 out = rh.createExceptionReply();
187 AlreadyBoundHelper.write(out, ex);
189 break;
192 case 3: // rebind_context
196 NameComponent[] a_name = NameHelper.read(in);
197 NamingContext a_context = NamingContextHelper.read(in);
198 rebind_context(a_name, a_context);
199 out = rh.createReply();
201 catch (NotFound ex)
203 out = rh.createExceptionReply();
204 NotFoundHelper.write(out, ex);
206 catch (CannotProceed ex)
208 out = rh.createExceptionReply();
209 CannotProceedHelper.write(out, ex);
211 catch (InvalidName ex)
213 out = rh.createExceptionReply();
214 InvalidNameHelper.write(out, ex);
216 break;
219 case 4: // resolve
223 NameComponent[] a_name = NameHelper.read(in);
224 org.omg.CORBA.Object __result = null;
225 __result = resolve(a_name);
226 out = rh.createReply();
227 ObjectHelper.write(out, __result);
229 catch (NotFound ex)
231 out = rh.createExceptionReply();
232 NotFoundHelper.write(out, ex);
234 catch (CannotProceed ex)
236 out = rh.createExceptionReply();
237 CannotProceedHelper.write(out, ex);
239 catch (InvalidName ex)
241 out = rh.createExceptionReply();
242 InvalidNameHelper.write(out, ex);
244 break;
247 case 5: // unbind
251 NameComponent[] a_name = NameHelper.read(in);
252 unbind(a_name);
253 out = rh.createReply();
255 catch (NotFound ex)
257 out = rh.createExceptionReply();
258 NotFoundHelper.write(out, ex);
260 catch (CannotProceed ex)
262 out = rh.createExceptionReply();
263 CannotProceedHelper.write(out, ex);
265 catch (InvalidName ex)
267 out = rh.createExceptionReply();
268 InvalidNameHelper.write(out, ex);
270 break;
273 case 6: // new_context
275 NamingContext __result = null;
276 __result = new_context();
277 out = rh.createReply();
278 NamingContextHelper.write(out, __result);
279 break;
282 case 7: // bind_new_context
286 NameComponent[] a_name = NameHelper.read(in);
287 NamingContext __result = null;
288 __result = bind_new_context(a_name);
289 out = rh.createReply();
290 NamingContextHelper.write(out, __result);
292 catch (NotFound ex)
294 out = rh.createExceptionReply();
295 NotFoundHelper.write(out, ex);
297 catch (AlreadyBound ex)
299 out = rh.createExceptionReply();
300 AlreadyBoundHelper.write(out, ex);
302 catch (CannotProceed ex)
304 out = rh.createExceptionReply();
305 CannotProceedHelper.write(out, ex);
307 catch (InvalidName ex)
309 out = rh.createExceptionReply();
310 InvalidNameHelper.write(out, ex);
312 break;
315 case 8: // destroy
319 destroy();
320 out = rh.createReply();
322 catch (NotEmpty ex)
324 out = rh.createExceptionReply();
325 NotEmptyHelper.write(out, ex);
327 break;
330 case 9: // list
332 int amount = in.read_ulong();
333 BindingListHolder a_list = new BindingListHolder();
334 BindingIteratorHolder an_iter = new BindingIteratorHolder();
335 list(amount, a_list, an_iter);
336 out = rh.createReply();
337 BindingListHelper.write(out, a_list.value);
338 BindingIteratorHelper.write(out, an_iter.value);
339 break;
342 default:
343 throw new BAD_OPERATION(0, CompletionStatus.COMPLETED_MAYBE);
346 return out;
350 * Get the CORBA object that delegates calls to this servant. The servant must
351 * be already connected to an ORB.
353 public NamingContext _this()
355 return NamingContextHelper.narrow(super._this_object());
359 * Get the CORBA object that delegates calls to this servant. Connect to the
360 * given ORB, if needed.
362 public NamingContext _this(org.omg.CORBA.ORB orb)
364 return NamingContextHelper.narrow(super._this_object(orb));