1 /* _comTesterImplBase.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)
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
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
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 gnu.classpath.examples.CORBA.SimpleCommunication.communication;
41 import org.omg.CORBA.BAD_OPERATION;
42 import org.omg.CORBA.ByteHolder;
43 import org.omg.CORBA.CompletionStatus;
44 import org.omg.CORBA.DoubleHolder;
45 import org.omg.CORBA.ShortHolder;
46 import org.omg.CORBA.StringHolder;
47 import org.omg.CORBA.StringSeqHelper;
48 import org.omg.CORBA.portable.InputStream;
49 import org.omg.CORBA.portable.InvokeHandler;
50 import org.omg.CORBA.portable.ObjectImpl;
51 import org.omg.CORBA.portable.OutputStream;
52 import org.omg.CORBA.portable.ResponseHandler;
55 * The base for the class that is actually implementing the functionality
56 * of the object on the server side ({@link comServant} of our case).
58 * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
60 public abstract class _comTesterImplBase
62 implements comTester, InvokeHandler
65 * When the server receives the request message from client, it
68 * @param a_method the method name.
69 * @param in the CDR stream, from where the implementing code must
70 * read the method parameters.
71 * @param rh the response handler, used to get the stream where
72 * the returned values must be written.
74 * @return the stream, obtained from the response handler.
76 public OutputStream _invoke(String a_method, InputStream in,
82 /* Get the field value. */
83 if (a_method.equals("_get_theField"))
87 out = rh.createReply();
88 out.write_long(result);
91 /* Set the field value. */
92 if (a_method.equals("_set_theField"))
94 int newTheField = in.read_long();
95 theField(newTheField);
96 out = rh.createReply();
99 /* Logs calls to the file. */
100 if (a_method.equals("sayHello"))
103 out = rh.createReply();
106 /* Passes various parameters in both directions. */
107 if (a_method.equals("passSimple"))
109 ByteHolder an_octet = new ByteHolder();
110 an_octet.value = in.read_octet();
112 int a_long = in.read_long();
113 ShortHolder a_short = new ShortHolder();
114 a_short.value = in.read_short();
116 StringHolder a_string = new StringHolder();
117 a_string.value = in.read_string();
119 DoubleHolder a_double = new DoubleHolder();
120 int result = passSimple(an_octet, a_long, a_short, a_string, a_double);
121 out = rh.createReply();
122 out.write_long(result);
123 out.write_octet(an_octet.value);
124 out.write_short(a_short.value);
125 out.write_string(a_string.value);
126 out.write_double(a_double.value);
129 /* Passes the 'wide' (usually Unicode) string and the ordinary string. */
130 if (a_method.equals("passCharacters"))
132 String wide = in.read_wstring();
133 String narrow = in.read_string();
134 String result = null;
135 result = passCharacters(wide, narrow);
136 out = rh.createReply();
137 out.write_wstring(result);
141 Throws either 'ourUserException' with the 'ourField' field
142 initialised to the passed positive value
143 or system exception (if the parameter is zero or negative).
145 if (a_method.equals("throwException"))
149 int parameter = in.read_long();
150 throwException(parameter);
151 out = rh.createReply();
153 catch (ourUserException exception)
155 out = rh.createExceptionReply();
156 ourUserExceptionHelper.write(out, exception);
160 /* Passes and returns the structures. */
161 if (a_method.equals("passStructure"))
163 passThis in_structure = passThisHelper.read(in);
164 returnThis result = null;
165 result = passStructure(in_structure);
166 out = rh.createReply();
167 returnThisHelper.write(out, result);
170 /* Passes and returns the string sequence. */
171 if (a_method.equals("passStrings"))
173 String[] arg = StringSeqHelper.read(in);
174 String[] result = null;
175 result = passStrings(arg);
176 out = rh.createReply();
177 StringSeqHelper.write(out, result);
180 /** Pass and return the tree structure */
181 if (a_method.equals("passTree"))
183 nodeHolder tree = new nodeHolder();
184 tree.value = nodeHelper.read(in);
186 out = rh.createReply();
187 nodeHelper.write(out, tree.value);
191 throw new BAD_OPERATION("No method: " + a_method, 0,
192 CompletionStatus.COMPLETED_MAYBE
199 * Return an array of this object repository ids.
201 public String[] _ids()
203 // They are the same as for the stub.
204 return _comTesterStub._ids;