summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorAudrius Meskauskas <audriusa@Bioinformatics.org>2005-05-15 02:36:35 +0000
committerAudrius Meskauskas <audriusa@Bioinformatics.org>2005-05-15 02:36:35 +0000
commit467fda964152024e721a49131515d3269512ded0 (patch)
tree852987386cef0675c3fe66ec8bbe0cf17a129d9e /examples
parent9d73465b2160dbf3c3f3e514898ae1998307f49a (diff)
downloadclasspath-467fda964152024e721a49131515d3269512ded0.tar.gz
2005-05-15 Audrius Meskauskas, Lithuania <AudriusA@Bioinformatics.org>
* examples/gnu/classpath/examples/CORBA/NamingService/Demo.java, examples/gnu/classpath/examples/CORBA/SimpleCommunication/Demo.java, examples/gnu/classpath/examples/CORBA/SimpleCommunication/comServer.java, examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/passThisHelper.java, examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/passThisHolder.java, examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/returnThis.java, examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/passThis.java, examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/returnThisHelper.java, examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/returnThisHolder.java, examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/DirectTest.java, examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/RequestTest.java, examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/comServant.java, examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/ourUserException.java, examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/node.java, examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/nodeHelper.java, examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/nodeHolder.java, examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_comTesterStub.java, examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/ourUserExceptionHelper.java, examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_comTesterImplBase.java, examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/comTester.java: New IIOP (CORBA) examples. The examples stayed uncommitted after the previous submission. Probably too many files at once.
Diffstat (limited to 'examples')
-rw-r--r--examples/gnu/classpath/examples/CORBA/NamingService/Demo.java199
-rw-r--r--examples/gnu/classpath/examples/CORBA/SimpleCommunication/Demo.java89
-rw-r--r--examples/gnu/classpath/examples/CORBA/SimpleCommunication/comServer.java118
-rw-r--r--examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/DirectTest.java344
-rw-r--r--examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/RequestTest.java258
-rw-r--r--examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_comTesterImplBase.java206
-rw-r--r--examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_comTesterStub.java426
-rw-r--r--examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/comServant.java236
-rw-r--r--examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/comTester.java111
-rw-r--r--examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/node.java55
-rw-r--r--examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/nodeHelper.java160
-rw-r--r--examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/nodeHolder.java100
-rw-r--r--examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/ourUserException.java70
-rw-r--r--examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/ourUserExceptionHelper.java107
-rw-r--r--examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/passThis.java61
-rw-r--r--examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/passThisHelper.java102
-rw-r--r--examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/passThisHolder.java37
-rw-r--r--examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/returnThis.java66
-rw-r--r--examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/returnThisHelper.java115
-rw-r--r--examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/returnThisHolder.java60
20 files changed, 2920 insertions, 0 deletions
diff --git a/examples/gnu/classpath/examples/CORBA/NamingService/Demo.java b/examples/gnu/classpath/examples/CORBA/NamingService/Demo.java
new file mode 100644
index 000000000..1d6403535
--- /dev/null
+++ b/examples/gnu/classpath/examples/CORBA/NamingService/Demo.java
@@ -0,0 +1,199 @@
+/* Demo.java -- Shows how to use Classpath transient naming service.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.examples.CORBA.NamingService;
+
+import gnu.CORBA.IOR;
+import gnu.CORBA.NamingService.NamingServiceTransient;
+
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.Object;
+import org.omg.CosNaming.Binding;
+import org.omg.CosNaming.BindingHolder;
+import org.omg.CosNaming.BindingIterator;
+import org.omg.CosNaming.BindingIteratorHolder;
+import org.omg.CosNaming.BindingListHolder;
+import org.omg.CosNaming.NameComponent;
+import org.omg.CosNaming.NamingContext;
+import org.omg.CosNaming.NamingContextExt;
+import org.omg.CosNaming.NamingContextExtHelper;
+import org.omg.CosNaming.NamingContextHelper;
+
+/**
+ * A simple test of the naming service.
+ *
+ * The main class of the GNU Classpath transient naming service is
+ * {@link gnu.CORBA.NamingService}. This class must be started
+ * before starting this example.
+ *
+ * This example should interoperate as with GNU Classpath naming
+ * service, as with Sun Microsystems transient and persistent
+ * naming services, included in releases 1.3 and 1.4 (tnameserv and
+ * orbd). To work with this example, the naming service must
+ * be started on the local host, at the port 900.
+ *
+ * The persistent naming service is currently under development.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class Demo
+{
+ public static void main(final String[] args)
+ {
+ // We create the following naming graph:
+ // <ROOT CONTEXT>
+ // |
+ // +--- <c.d context>
+ // | |
+ // | +--- obj
+ // |
+ // +--- xobj
+ //
+ // Where both obj and xobj are CORBA objects, representing the
+ // default naming service.
+ //
+ System.out.println("Starting the GNU Classpath " +
+ "built-in transient naming service"
+ );
+
+ new Thread()
+ {
+ public void run()
+ {
+ NamingServiceTransient.main(args);
+ }
+ }.start();
+
+ System.out.println("Waiting for three seconds for naming service to start:");
+ try
+ {
+ Thread.sleep(3000);
+ }
+ catch (InterruptedException ex)
+ {
+ }
+
+ try
+ {
+ ORB orb = ORB.init(args, null);
+
+ Object no = orb.resolve_initial_references("NameService");
+
+ System.out.println("Naming service IOR:" + orb.object_to_string(no));
+
+ System.out.println(IOR.parse(orb.object_to_string(no)));
+
+ NamingContextExt namer = NamingContextExtHelper.narrow(no);
+
+ System.out.println("Naming service: " + namer.getClass().getName());
+
+ NamingContext second = namer.new_context();
+
+ namer.rebind_context(namer.to_name("c.d"), second);
+ namer.rebind(namer.to_name("xobj"), no);
+
+ second.rebind(namer.to_name("obj"), no);
+
+ NamingContext nsec =
+ NamingContextHelper.narrow(namer.resolve_str("c.d"));
+
+ System.out.println(namer.resolve(namer.to_name("c.d/obj")));
+
+ // In all cases, this must be the same object (the naming
+ // service itself).
+ System.out.println(nsec.resolve(new NameComponent[]
+ {
+ new NameComponent("obj", "")
+ }
+ )
+ );
+ System.out.println(namer.resolve_str("xobj"));
+
+ // In all cases, this must be the same object (the naming
+ // service itself).
+ System.out.println(namer.resolve(new NameComponent[]
+ {
+ new NameComponent("c", "d"),
+ new NameComponent("obj", "")
+ }
+ )
+ );
+
+ System.out.println(namer.resolve_str("c.d/obj"));
+
+ System.out.println("Test binding list iterator:");
+
+ BindingListHolder lh = new BindingListHolder();
+ BindingIteratorHolder lih = new BindingIteratorHolder();
+
+ namer.list(0, lh, lih);
+
+ BindingIterator iter = lih.value;
+ BindingHolder binding = new BindingHolder();
+
+ while (iter.next_one(binding))
+ {
+ Binding b = binding.value;
+ System.out.println("NAME: " + namer.to_string(b.binding_name) +
+ " TYPE " + b.binding_type.value()
+ );
+ }
+
+ System.out.println("Testing binding list:");
+
+ iter.destroy();
+
+ namer.list(Integer.MAX_VALUE, lh, lih);
+
+ for (int i = 0; i < lh.value.length; i++)
+ {
+ Binding b = lh.value [ i ];
+ System.out.println("NAME: " + namer.to_string(b.binding_name) +
+ " TYPE " + b.binding_type.value()
+ );
+ }
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ System.exit(1);
+ }
+
+ System.exit(0);
+ }
+}
diff --git a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/Demo.java b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/Demo.java
new file mode 100644
index 000000000..70cdb1d27
--- /dev/null
+++ b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/Demo.java
@@ -0,0 +1,89 @@
+/* Demo.java -- Demonstrates simple CORBA client-server communications.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.examples.CORBA.SimpleCommunication;
+
+import gnu.classpath.examples.CORBA.SimpleCommunication.communication.DirectTest;
+import gnu.classpath.examples.CORBA.SimpleCommunication.communication.RequestTest;
+
+
+/**
+ * This sample illustrates the CORBA communication between server
+ * and client. In this simple example both server and client are
+ * started on the same virtual machine. For the real interoperability
+ * tests, however, the server is started on the platform (library+jvm) of
+ * one vendor, and the client on the platform of another vendor.
+ *
+ * The interoperability is currently tested with Sun Microystems
+ * jre 1.4.
+ *
+ * This example required the current folder to be writable to pass
+ * the IOR references via shared file.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class Demo
+{
+ public static void main(final String[] args)
+ {
+ // Start the server.
+ new Thread()
+ {
+ public void run()
+ {
+ comServer.start_server(args);
+ }
+ }.start();
+
+ System.out.println("Waiting for three seconds for the server to start...");
+
+ // Pause some time for the server to start.
+ try {
+ Thread.sleep(3000);
+ }
+ catch (InterruptedException ex) {
+ }
+
+ // Test the stream oriented communication.
+ DirectTest.main(args);
+ // Test the request oriented communication.
+ RequestTest.main(args);
+
+ System.exit(0);
+ }
+}
diff --git a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/comServer.java b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/comServer.java
new file mode 100644
index 000000000..262fbcd99
--- /dev/null
+++ b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/comServer.java
@@ -0,0 +1,118 @@
+/* comServer.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.examples.CORBA.SimpleCommunication;
+
+import gnu.classpath.examples.CORBA.SimpleCommunication.communication.comServant;
+
+import org.omg.CORBA.ORB;
+
+import java.io.FileOutputStream;
+import java.io.PrintStream;
+
+/**
+ * This is the server class that handles the client requests,
+ * delegating the functionality to the {@link comServant}.
+ *
+ * When starting, the server writes the IOR.txt file into the current
+ * folder. With the information, stored in this file, the server
+ * should be reachable over Internet, unless blocked by security tools.
+ *
+ * This code is tested for interoperability with Sun Microsystems
+ * java implementation 1.4.2 (08.b03). Server, client of both can
+ * be started either on Sun's or on Classpath CORBA implementation,
+ * in any combinations.
+ *
+ * BE SURE TO START THIS SERVER BEFORE STARTING THE CLIENT.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class comServer
+{
+
+ public static void main(String[] args)
+ {
+ start_server(args);
+ }
+
+ public static ORB start_server(String[] args)
+ {
+ try
+ {
+ // Create and initialize the ORB.
+ final ORB orb = org.omg.CORBA.ORB.init(args, null);
+
+ // Create the servant and register it with the ORB.
+ comServant tester = new comServant();
+ orb.connect(tester);
+
+ // Storing the IOR reference.
+ String ior = orb.object_to_string(tester);
+ System.out.println("IOR: " + ior);
+
+ gnu.CORBA.IOR ii = gnu.CORBA.IOR.parse(ior);
+ System.out.println(ii);
+
+ // The file IOR.txt in the current folder will be used
+ // to find the object by clients.
+ FileOutputStream f = new FileOutputStream("IOR.txt");
+ PrintStream p = new PrintStream(f);
+ p.print(ior);
+ p.close();
+
+ System.out.println("The test server ready and waiting ...");
+
+ new Thread()
+ {
+ public void run()
+ {
+ // Start the thread, serving the invocations from clients.
+ orb.run();
+ }
+ }.start();
+
+ return orb;
+ }
+ catch (Exception e)
+ {
+ System.err.println("ERROR: " + e);
+ e.printStackTrace(System.out);
+ return null;
+ }
+ }
+}
diff --git a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/DirectTest.java b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/DirectTest.java
new file mode 100644
index 000000000..cf3c41d07
--- /dev/null
+++ b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/DirectTest.java
@@ -0,0 +1,344 @@
+/* DirectTest.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.examples.CORBA.SimpleCommunication.communication;
+
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.ByteHolder;
+import org.omg.CORBA.DoubleHolder;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.ShortHolder;
+import org.omg.CORBA.StringHolder;
+import org.omg.CORBA.UserException;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+
+/**
+ * This code uses CORBA to call various methods of the remote object,
+ * passing data structures in both directions. It finds the server by
+ * reading the IOR.txt file that must be present in the folder,
+ * where the program has been started.
+ *
+ * The IOR.txt file is written by the server
+ * {@link gnu.classpath.examples.CORBA.SimpleCommunication.comServer}.
+ * The server should be reachable over Internet, unless blocked by
+ * security tools.
+ *
+ * This code is tested for interoperability with Sun Microsystems
+ * java implementation 1.4.2 (08.b03). Server, client of both can
+ * be started either on Sun's or on Classpath CORBA implementation,
+ * in any combinations.
+ *
+ * BE SURE TO START THE SERVER BEFORE STARTING THE CLIENT.
+ *
+ * This version uses direct casting. This is the most convenient
+ * method, but it is normally used together with the IDL compiler.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class DirectTest
+{
+ /*
+ * The IOR.txt file, used to find the server and the object on the server. is written when starting the accompanying
+ */
+ public static final String IOR_FILE = "IOR.txt";
+
+ /**
+ * The invocation target.
+ */
+ comTester object;
+
+ /**
+ * Get the object reference.
+ */
+ public static void main(String[] args)
+ {
+ try
+ {
+ ORB orb = org.omg.CORBA.ORB.init(args, null);
+
+ File f = new File(IOR_FILE);
+ char[] c = new char[ (int) f.length() ];
+ FileReader fr = new FileReader(f);
+ fr.read(c);
+ fr.close();
+
+ String ior = new String(c);
+ DirectTest we = new DirectTest();
+ we.object = (comTester) orb.string_to_object(ior);
+ we.Demo();
+ orb.shutdown(false);
+ }
+ catch (IOException ex)
+ {
+ System.out.println("Cannot find or read the IOR file " +
+ "in the current folder"
+ );
+ ex.printStackTrace();
+ }
+ }
+
+ /** Run all demos. */
+ public void Demo()
+ {
+ testHello();
+ testField();
+ testParameters();
+ testStringArray();
+ testStructure();
+ testWideNarrowStrings();
+ testTree();
+ testSystemException();
+ testUserException();
+ }
+
+ /**
+ * Test the field getter/setter.
+ */
+ public void testField()
+ {
+ System.out.println("***** Test the remote field getter/setter.");
+ System.out.println("The field value is now " + object.theField());
+ System.out.println("Setting it to 555");
+ object.theField(555);
+ System.out.println("The field value is now " + object.theField());
+ }
+
+ /** The simple invocation of the parameterless remote method. */
+ public void testHello()
+ {
+ System.out.println("***** Say hello (see the server console).");
+ object.sayHello();
+ }
+
+ /**
+ * Test passing multiple parameters in both directions.
+ */
+ public void testParameters()
+ {
+ System.out.println("***** Pass multiple parameters.");
+
+ // Holder classes are required to simulate passing
+ // "by reference" (modification is returned back to the server).
+ ByteHolder a_byte = new ByteHolder((byte) 0);
+ ShortHolder a_short = new ShortHolder((short) 3);
+ StringHolder a_string = new StringHolder("[string 4]");
+
+ // This is an 'out' parameter; the value must not be passed to servant.
+ DoubleHolder a_double = new DoubleHolder(56.789);
+
+ int returned = object.passSimple(a_byte, 2, a_short, a_string, a_double);
+
+ System.out.println(" Returned value " + returned);
+ System.out.println(" Returned parameters: ");
+ System.out.println(" octet " + a_byte.value);
+ System.out.println(" short " + a_short.value);
+ System.out.println(" string '" + a_string.value+"'");
+ System.out.println(" double " + a_double.value);
+ }
+
+ /**
+ * Test passing the string array, flexible size.
+ */
+ public void testStringArray()
+ {
+ System.out.println("***** Pass string array.");
+
+ String[] x = new String[] { "one", "two" };
+
+ // The array is passed as CORBA sequence, variable size is supported.
+ String[] y = object.passStrings(x);
+
+ for (int i = 0; i < y.length; i++)
+ {
+ System.out.println(" Passed " + x [ i ] + ", returned: " + y [ i ]);
+ }
+ }
+
+ /**
+ * Test passing the structures.
+ */
+ public void testStructure()
+ {
+ System.out.println("***** Pass structure");
+
+ passThis arg = new passThis();
+ arg.a = "A";
+ arg.b = "B";
+
+ returnThis r = object.passStructure(arg);
+
+ System.out.println(" Fields of the returned structure:");
+
+ System.out.println(" c: " + r.c);
+ System.out.println(" n: " + r.n);
+
+ // The field r.arra is declared as the fixed size CORBA array.
+ System.out.println(" r[0]: " + r.arra [ 0 ]);
+ System.out.println(" r[1]: " + r.arra [ 1 ]);
+ System.out.println(" r[3]: " + r.arra [ 2 ]);
+ }
+
+ /**
+ * Test catching the system exception, thrown on the remote side.
+ */
+ public void testSystemException()
+ {
+ System.out.println("**** Test system exception:");
+ try
+ {
+ // Negative parameter = system exception.
+ object.throwException(-55);
+ }
+ catch (BAD_OPERATION ex)
+ {
+ System.out.println(" The expected BAD_OPERATION, minor code " +
+ ex.minor + ", has been thrown on remote side."
+ );
+ }
+ catch (UserException uex)
+ {
+ throw new InternalError();
+ }
+ }
+
+ /**
+ * Test passing the tree structure. Any shape of the tree is
+ * supported without rewriting the code.
+ */
+ public void testTree()
+ {
+ // Manually create the tree of nodes:
+ // Root
+ // +-- a
+ // |
+ // +-- b
+ // +-- ba
+ // | |
+ // | +-- bac
+ // |
+ // +-- bb
+ System.out.println("***** Pass and return the tree.");
+
+ node n = nod("Root");
+
+ n.children = new node[] { nod("a"), nod("b") };
+ n.children [ 1 ].children = new node[] { nod("ba"), nod("bb") };
+ n.children [ 1 ].children [ 0 ].children = new node[] { nod("bac") };
+
+ nodeHolder nh = new nodeHolder(n);
+
+ // The server should add '++' to each node name.
+ object.passTree(nh);
+
+ // Convert the returned tree to some strig representation.
+ StringBuffer img = new StringBuffer();
+ getImage(img, nh.value);
+
+ System.out.println("Returned tree: " + img.toString());
+ }
+
+ /**
+ * Test catching the user exception, thrown on the remote side.
+ */
+ public void testUserException()
+ {
+ System.out.println("**** Test user exception:");
+ try
+ {
+ // The user exception contains one user-defined field that will
+ // be initialised to the passed parameter.
+ object.throwException(123);
+ throw new InternalError();
+ }
+ catch (ourUserException uex)
+ {
+ System.out.println(" The user exception with field " + uex.ourField +
+ ", has been thrown on remote side."
+ );
+ }
+ }
+
+ /**
+ * Passes wide (UTF-16) string and narrow (ISO8859_1) string.
+ * @see gnu.CORBA.GIOP.CharSets_OSF for supported and default
+ * encodings.
+ */
+ public void testWideNarrowStrings()
+ {
+ System.out.println("**** Test 8 bit and 16 bit char strings");
+
+ String r = object.passCharacters("wide string", "narrow string");
+ System.out.println(" returned: '" + r + "'");
+ }
+
+ /**
+ * Get the string representation of the passed tree.
+ * @param b the string buffer to accumulate the representation.
+ * @param n the tree (root node).
+ */
+ private void getImage(StringBuffer b, node n)
+ {
+ b.append(n.name);
+ b.append(": (");
+
+ for (int i = 0; i < n.children.length; i++)
+ {
+ getImage(b, n.children [ i ]);
+ b.append(' ');
+ }
+ b.append(") ");
+ }
+
+ /**
+ * Create a node with the given header.
+ *
+ * @param hdr the node header.
+ * @return the created node.
+ */
+ private node nod(String hdr)
+ {
+ node n = new node();
+ n.children = new node[ 0 ];
+ n.name = hdr;
+
+ return n;
+ }
+}
diff --git a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/RequestTest.java b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/RequestTest.java
new file mode 100644
index 000000000..3c56a3876
--- /dev/null
+++ b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/RequestTest.java
@@ -0,0 +1,258 @@
+
+
+package gnu.classpath.examples.CORBA.SimpleCommunication.communication;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.ByteHolder;
+import org.omg.CORBA.DoubleHolder;
+import org.omg.CORBA.ExceptionList;
+import org.omg.CORBA.NVList;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.Request;
+import org.omg.CORBA.ShortHolder;
+import org.omg.CORBA.StringHolder;
+import org.omg.CORBA.TCKind;
+
+/**
+ * This code uses CORBA to call various methods of the remote object,
+ * passing data structures in both directions. It finds the server by
+ * reading the IOR.txt file that must be present in the folder,
+ * where the program has been started.
+ *
+ * The IOR.txt file is written by the server
+ * {@link gnu.classpath.examples.CORBA.SimpleCommunication.comServer}.
+ * The server should be reachable over Internet, unless blocked by
+ * security tools.
+ *
+ * This code is tested for interoperability with Sun Microsystems
+ * java implementation 1.4.2 (08.b03). Server, client of both can
+ * be started either on Sun's or on Classpath CORBA implementation,
+ * in any combinations.
+ *
+ * BE SURE TO START THE SERVER BEFORE STARTING THE CLIENT.
+ *
+ * Test invocations using org.omg.CORBA.Request. The methods are
+ * called by "name", like in java.lang.reflect.
+ * No need to have the local pre-compiled stub classes.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class RequestTest
+{
+ /*
+ * The IOR.txt file, used to find the server and the object on the server. is written when starting the accompanying
+ */
+ public static final String IOR_FILE = "IOR.txt";
+
+ /**
+ * The Object Request Brocker, used for various CORBA operations.
+ */
+ ORB orb;
+
+ /**
+ * Our remote object - the invocation target.
+ */
+ org.omg.CORBA.Object object;
+
+ /**
+ * Prepare for work. Read the file IOR.txt in the current folder
+ * and find the server using its information.
+ */
+ public static void main(String[] args)
+ {
+ RequestTest we = new RequestTest();
+
+ we.orb = org.omg.CORBA.ORB.init(new String[ 0 ], null);
+
+ char[] c = null;
+ try
+ {
+ File f = new File(IOR_FILE);
+ c = new char[ (int) f.length() ];
+
+ FileReader fr = new FileReader(f);
+ fr.read(c);
+ fr.close();
+ }
+ catch (IOException ex)
+ {
+ System.out.println("Unable to write the IOR.txt into the current folder");
+ ex.printStackTrace();
+ }
+
+ String ior = new String(c);
+
+ we.object = we.orb.string_to_object(ior);
+ we.Demo();
+ we.orb.shutdown(false);
+ }
+
+ /** Run all demos. */
+ public void Demo()
+ {
+ testHello();
+ try
+ {
+ testParameters();
+ }
+ catch (Exception ex)
+ {
+ // Not expected.
+ throw new InternalError();
+ }
+ testSystemException();
+ testUserException();
+ testWideNarrowStrings();
+ }
+
+ /**
+ * Send the hello message, one way.
+ */
+ public void testHello()
+ {
+ System.out.println("***** Test 'HELLO WORLD' (see the server console).");
+
+ Request hello =
+ object._create_request(null, "sayHello", orb.create_list(0), null);
+
+ // No response expected.
+ hello.send_oneway();
+ }
+
+ /**
+ * Test passing various parameters in both directions.
+ */
+ public void testParameters()
+ throws Exception
+ {
+ System.out.println("***** Test passing multiple parameters:");
+
+ Request r =
+ object._create_request(null, "passSimple", orb.create_list(0), null);
+
+ ByteHolder a_byte = new ByteHolder((byte) 0);
+ ShortHolder a_short = new ShortHolder((short) 3);
+ StringHolder a_string = new StringHolder("[string 4]");
+
+ // This is an 'out' parameter; the value must not be passed to servant.
+ DoubleHolder a_double = new DoubleHolder(56.789);
+
+ r.add_inout_arg().insert_octet((byte) 0);
+ r.add_in_arg().insert_long(2);
+ r.add_inout_arg().insert_short((short) 3);
+ r.add_inout_arg().insert_string("[string 4]");
+ r.add_out_arg().type(orb.get_primitive_tc(TCKind.tk_double));
+
+ NVList para = r.arguments();
+
+ System.out.println(" --- Parameters before invocation: ");
+
+ System.out.println(" octet " + para.item(0).value().extract_octet());
+ System.out.println(" long (in parameter) " +
+ para.item(1).value().extract_long()
+ );
+ System.out.println(" short " + para.item(2).value().extract_short());
+ System.out.println(" string " + para.item(3).value().extract_string());
+
+ // For the last parameter, the value is not set.
+ r.set_return_type(orb.get_primitive_tc(TCKind.tk_long));
+
+ r.invoke();
+
+ para = r.arguments();
+
+ System.out.println(" --- Parameters after invocation:");
+
+ System.out.println(" octet " + para.item(0).value().extract_octet());
+ System.out.println(" long (in parameter, must not be changed) " +
+ para.item(1).value().extract_long()
+ );
+ System.out.println(" short " + para.item(2).value().extract_short());
+ System.out.println(" string " + para.item(3).value().extract_string());
+ System.out.println(" double " + para.item(4).value().extract_double());
+
+ System.out.println(" Returned value " + r.result().value().extract_long());
+ }
+
+ /**
+ * Test catching the system exception, thrown on the remote side.
+ */
+ public void testSystemException()
+ {
+ System.out.println("**** Test system exception:");
+ try
+ {
+ ExceptionList exList = orb.create_exception_list();
+ exList.add(ourUserExceptionHelper.type());
+
+ Request rq =
+ object._create_request(null, "throwException", orb.create_list(1),
+ null, exList, null
+ );
+
+ rq.add_in_arg().insert_long(-55);
+
+ rq.invoke();
+
+ throw new InternalError();
+ }
+ catch (BAD_OPERATION ex)
+ {
+ System.out.println(" The expected BAD_OPERATION, minor code " +
+ ex.minor + ", has been thrown on remote side."
+ );
+ }
+ }
+
+ /**
+ * Test catching the user exception, thrown on the remote side.
+ */
+ public void testUserException()
+ {
+ System.out.println("**** Test user exception:");
+
+ ExceptionList exList = orb.create_exception_list();
+ exList.add(ourUserExceptionHelper.type());
+
+ Request rq =
+ object._create_request(null, "throwException", orb.create_list(1), null,
+ exList, null
+ );
+
+ rq.add_in_arg().insert_long(123);
+ rq.invoke();
+
+ ourUserException ou = (ourUserException) rq.env().exception();
+
+ System.out.println(" Our user exception, field " + ou.ourField +
+ ", has been thrown on remote side."
+ );
+ }
+
+ /**
+ * Passes wide (UTF-16) string and narrow (ISO8859_1) string.
+ * @see gnu.CORBA.GIOP.CharSets_OSF for supported and default
+ * encodings.
+ */
+ public void testWideNarrowStrings()
+ throws BAD_OPERATION
+ {
+ System.out.println("**** Test 8 bit and 16 bit char strings");
+
+ Request rq =
+ object._create_request(null, "passCharacters", orb.create_list(0), null);
+
+ rq.add_in_arg().insert_wstring("wide string");
+ rq.add_in_arg().insert_string("narrow string");
+
+ rq.set_return_type(orb.get_primitive_tc(TCKind.tk_wstring));
+
+ rq.invoke();
+
+ System.out.println(" Returned ' " + rq.result().value().extract_wstring());
+ }
+}
diff --git a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_comTesterImplBase.java b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_comTesterImplBase.java
new file mode 100644
index 000000000..2c5c8683c
--- /dev/null
+++ b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_comTesterImplBase.java
@@ -0,0 +1,206 @@
+/* _comTesterImplBase.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.examples.CORBA.SimpleCommunication.communication;
+
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.ByteHolder;
+import org.omg.CORBA.CompletionStatus;
+import org.omg.CORBA.DoubleHolder;
+import org.omg.CORBA.ShortHolder;
+import org.omg.CORBA.StringHolder;
+import org.omg.CORBA.StringSeqHelper;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.InvokeHandler;
+import org.omg.CORBA.portable.ObjectImpl;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.ResponseHandler;
+
+/**
+ * The base for the class that is actually implementing the functionality
+ * of the object on the server side ({@link comServant} of our case).
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class _comTesterImplBase
+ extends ObjectImpl
+ implements comTester, InvokeHandler
+{
+/**
+ * When the server receives the request message from client, it
+ * calls this method.
+ *
+ * @param a_method the method name.
+ * @param in the CDR stream, from where the implementing code must
+ * read the method parameters.
+ * @param rh the response handler, used to get the stream where
+ * the returned values must be written.
+ *
+ * @return the stream, obtained from the response handler.
+ */
+ public OutputStream _invoke(String a_method, InputStream in,
+ ResponseHandler rh
+ )
+ {
+ OutputStream out;
+
+ /* Get the field value. */
+ if (a_method.equals("_get_theField"))
+ {
+ int result = (int) 0;
+ result = theField();
+ out = rh.createReply();
+ out.write_long(result);
+ }
+ else
+ /* Set the field value. */
+ if (a_method.equals("_set_theField"))
+ {
+ int newTheField = in.read_long();
+ theField(newTheField);
+ out = rh.createReply();
+ }
+ else
+ /* Logs calls to the file. */
+ if (a_method.equals("sayHello"))
+ {
+ sayHello();
+ out = rh.createReply();
+ }
+ else
+ /* Passes various parameters in both directions. */
+ if (a_method.equals("passSimple"))
+ {
+ ByteHolder an_octet = new ByteHolder();
+ an_octet.value = in.read_octet();
+
+ int a_long = in.read_long();
+ ShortHolder a_short = new ShortHolder();
+ a_short.value = in.read_short();
+
+ StringHolder a_string = new StringHolder();
+ a_string.value = in.read_string();
+
+ DoubleHolder a_double = new DoubleHolder();
+ int result = passSimple(an_octet, a_long, a_short, a_string, a_double);
+ out = rh.createReply();
+ out.write_long(result);
+ out.write_octet(an_octet.value);
+ out.write_short(a_short.value);
+ out.write_string(a_string.value);
+ out.write_double(a_double.value);
+ }
+ else
+ /* Passes the 'wide' (usually Unicode) string and the ordinary string. */
+ if (a_method.equals("passCharacters"))
+ {
+ String wide = in.read_wstring();
+ String narrow = in.read_string();
+ String result = null;
+ result = passCharacters(wide, narrow);
+ out = rh.createReply();
+ out.write_wstring(result);
+ }
+ else
+ /*
+ Throws either 'ourUserException' with the 'ourField' field
+ initialised to the passed positive value
+ or system exception (if the parameter is zero or negative).
+ */
+ if (a_method.equals("throwException"))
+ {
+ try
+ {
+ int parameter = in.read_long();
+ throwException(parameter);
+ out = rh.createReply();
+ }
+ catch (ourUserException exception)
+ {
+ out = rh.createExceptionReply();
+ ourUserExceptionHelper.write(out, exception);
+ }
+ }
+ else
+ /* Passes and returns the structures. */
+ if (a_method.equals("passStructure"))
+ {
+ passThis in_structure = passThisHelper.read(in);
+ returnThis result = null;
+ result = passStructure(in_structure);
+ out = rh.createReply();
+ returnThisHelper.write(out, result);
+ }
+ else
+ /* Passes and returns the string sequence. */
+ if (a_method.equals("passStrings"))
+ {
+ String[] arg = StringSeqHelper.read(in);
+ String[] result = null;
+ result = passStrings(arg);
+ out = rh.createReply();
+ StringSeqHelper.write(out, result);
+ }
+ else
+ /** Pass and return the tree structure */
+ if (a_method.equals("passTree"))
+ {
+ nodeHolder tree = new nodeHolder();
+ tree.value = nodeHelper.read(in);
+ passTree(tree);
+ out = rh.createReply();
+ nodeHelper.write(out, tree.value);
+ }
+
+ else
+ throw new BAD_OPERATION("No method: " + a_method, 0,
+ CompletionStatus.COMPLETED_MAYBE
+ );
+
+ return out;
+ }
+
+ /**
+ * Return an array of this object repository ids.
+ */
+ public String[] _ids()
+ {
+ // They are the same as for the stub.
+ return _comTesterStub._ids;
+ }
+}
diff --git a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_comTesterStub.java b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_comTesterStub.java
new file mode 100644
index 000000000..437e81f08
--- /dev/null
+++ b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_comTesterStub.java
@@ -0,0 +1,426 @@
+/* _comTesterStub.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.examples.CORBA.SimpleCommunication.communication;
+
+import org.omg.CORBA.ByteHolder;
+import org.omg.CORBA.DoubleHolder;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.ShortHolder;
+import org.omg.CORBA.StringHolder;
+import org.omg.CORBA.StringSeqHelper;
+import org.omg.CORBA.portable.ApplicationException;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.ObjectImpl;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.RemarshalException;
+
+/**
+ * The stub (proxy) class, representing the remote object on the client
+ * side. It has all the same methods as the actual implementation
+ * on the server side. These methods contain the code for remote
+ * invocation.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class _comTesterStub
+ extends ObjectImpl
+ implements comTester
+{
+ /**
+ * A string array of comTester repository ids.
+ */
+ public static String[] _ids =
+ {
+ "IDL:gnu/classpath/examples/CORBA/SimpleCommunication/communication/comTester:1.0"
+ };
+
+ /**
+ * Return an array of comTester repository ids.
+ */
+ public String[] _ids()
+ {
+ return _ids;
+ }
+
+ /**
+ * Passes wide (UTF-16) string and narrow (ISO8859_1) string.
+ * @see gnu.CORBA.GIOP.CharSets_OSF for supported and default
+ * encodings.
+ */
+ public String passCharacters(String wide, String narrow)
+ {
+ InputStream in = null;
+ try
+ {
+ // Get the output stream.
+ OutputStream out = _request("passCharacters", true);
+
+ // Write the parameters.
+
+ // The first string is passed as "wide"
+ // (usually 16 bit UTF-16) string.
+ out.write_wstring(wide);
+
+ // The second string is passed as "narrow"
+ // (usually 8 bit ISO8859_1) string.
+ out.write_string(narrow);
+
+ // Do the invocation.
+ in = _invoke(out);
+
+ // Read the method return value.
+ String result = in.read_wstring();
+ return result;
+ }
+ catch (ApplicationException ex)
+ {
+ // The exception has been throws on remote side, but we
+ // do not expect any. Throw the MARSHAL exception.
+ in = ex.getInputStream();
+ throw new MARSHAL(ex.getId());
+ }
+ catch (RemarshalException _rm)
+ {
+ // This exception means that the parameters must be re-written.
+ return passCharacters(wide, narrow);
+ }
+ finally
+ {
+ // Release the resources, associated with the reply stream.
+ _releaseReply(in);
+ }
+ }
+
+ /**
+ * Passes various parameters in both directions. The parameters that
+ * shoud also return the values are wrapped into holders.
+ */
+ public int passSimple(ByteHolder an_octet, int a_long, ShortHolder a_short,
+ StringHolder a_string, DoubleHolder a_double
+ )
+ {
+ InputStream in = null;
+ try
+ {
+ // Get the stream where the parameters must be written:
+ OutputStream out = _request("passSimple", true);
+
+ // Write the parameters.
+ out.write_octet(an_octet.value);
+ out.write_long(a_long);
+ out.write_short(a_short.value);
+ out.write_string(a_string.value);
+
+ // Invoke the method.
+ in = _invoke(out);
+
+ // Read the returned values.
+ int result = in.read_long();
+
+ // Read the inout and out parameters.
+ an_octet.value = in.read_octet();
+ a_short.value = in.read_short();
+ a_string.value = in.read_string();
+ a_double.value = in.read_double();
+ return result;
+ }
+ catch (ApplicationException ex)
+ {
+ // Handle excepion on remote side.
+ in = ex.getInputStream();
+ throw new MARSHAL(ex.getId());
+ }
+ catch (RemarshalException _rm)
+ {
+ // Handle instruction to resend the parameters.
+ return passSimple(an_octet, a_long, a_short, a_string, a_double);
+ }
+ finally
+ {
+ _releaseReply(in);
+ }
+ }
+
+ /**
+ Passes and returns the string sequence.
+ */
+ public String[] passStrings(String[] arg)
+ {
+ InputStream in = null;
+ try
+ {
+ // Get the stream where the parameters must be written:
+ OutputStream out = _request("passStrings", true);
+
+ // Wrap the string array using the string sequence helper.
+ StringSeqHelper.write(out, arg);
+
+ // Invoke the method.
+ in = _invoke(out);
+
+ // Read the returned result using the string sequence helper.
+ String[] result = StringSeqHelper.read(in);
+ return result;
+ }
+ catch (ApplicationException ex)
+ {
+ // Handle the exception, thrown on remote side.
+ in = ex.getInputStream();
+ throw new MARSHAL(ex.getId());
+ }
+ catch (RemarshalException _rm)
+ {
+ return passStrings(arg);
+ }
+ finally
+ {
+ _releaseReply(in);
+ }
+ }
+
+ /**
+ Passes and returns the structures.
+ */
+ public returnThis passStructure(passThis in_structure)
+ {
+ InputStream in = null;
+ try
+ {
+ // Get the stream where the parameters must be written.
+ OutputStream out = _request("passStructure", true);
+
+ // Write the structure, using its helper.
+ passThisHelper.write(out, in_structure);
+
+ // Invoke the method.
+ in = _invoke(out);
+
+ // Read the returned structer, using another helper.
+ returnThis result = returnThisHelper.read(in);
+ return result;
+ }
+ catch (ApplicationException ex)
+ {
+ in = ex.getInputStream();
+ throw new MARSHAL(ex.getId());
+ }
+ catch (RemarshalException _rm)
+ {
+ return passStructure(in_structure);
+ }
+ finally
+ {
+ _releaseReply(in);
+ }
+ }
+
+ /**
+ * Pass and return the tree structure
+ */
+ public void passTree(nodeHolder tree)
+ {
+ InputStream in = null;
+ try
+ {
+ // Get the stream where the parameters must be written.
+ OutputStream out = _request("passTree", true);
+
+ // Write the tree (node with its chilred, grandchildren and so on),
+ // using the appropriate helper.
+ nodeHelper.write(out, tree.value);
+
+ // Call the method.
+ in = _invoke(out);
+
+ // Read the returned tree.
+ tree.value = nodeHelper.read(in);
+ }
+ catch (ApplicationException ex)
+ {
+ // Handle eception on remote side.
+ in = ex.getInputStream();
+ throw new MARSHAL(ex.getId());
+ }
+ catch (RemarshalException _rm)
+ {
+ passTree(tree);
+ }
+ finally
+ {
+ _releaseReply(in);
+ }
+ }
+
+ /**
+ * One way call of the remote method.
+ */
+ public void sayHello()
+ {
+ InputStream in = null;
+ try
+ {
+ // As we do not expect any response, the second
+ // parameter is 'false'.
+ OutputStream out = _request("sayHello", false);
+ in = _invoke(out);
+ }
+ catch (ApplicationException ex)
+ {
+ in = ex.getInputStream();
+ throw new MARSHAL(ex.getId());
+ }
+ catch (RemarshalException _rm)
+ {
+ sayHello();
+ }
+ finally
+ {
+ _releaseReply(in);
+ }
+ }
+
+ /**
+ * Get the field value.
+ */
+ public int theField()
+ {
+ InputStream in = null;
+ try
+ {
+ // The special name of operation instructs just to get
+ // the field value rather than calling the method.
+ OutputStream out = _request("_get_theField", true);
+ in = _invoke(out);
+
+ int result = in.read_long();
+ return result;
+ }
+ catch (ApplicationException ex)
+ {
+ in = ex.getInputStream();
+ throw new MARSHAL(ex.getId());
+ }
+ catch (RemarshalException _rm)
+ {
+ return theField();
+ }
+ finally
+ {
+ _releaseReply(in);
+ }
+ }
+
+ /**
+ * Set the field value.
+ */
+ public void theField(int newTheField)
+ {
+ InputStream in = null;
+ try
+ {
+ // The special name of operation instructs just to set
+ // the field value rather than calling the method.
+ OutputStream out = _request("_set_theField", true);
+ out.write_long(newTheField);
+ in = _invoke(out);
+ }
+ catch (ApplicationException ex)
+ {
+ in = ex.getInputStream();
+ throw new MARSHAL(ex.getId());
+ }
+ catch (RemarshalException _rm)
+ {
+ theField(newTheField);
+ }
+ finally
+ {
+ _releaseReply(in);
+ }
+ }
+
+ /**
+ * The server side exception tests.
+ *
+ * @param parameter the server throws the user exception in the case
+ * of the positive value of this argument, and system
+ * exception otherwise.
+ *
+ * @throws ourUserException
+ */
+ public void throwException(int parameter)
+ throws ourUserException
+ {
+ InputStream in = null;
+ try
+ {
+ // Get stream.
+ OutputStream out = _request("throwException", true);
+
+ // Write parameter.
+ out.write_long(parameter);
+
+ // Call method.
+ in = _invoke(out);
+ }
+ catch (ApplicationException ex)
+ {
+ in = ex.getInputStream();
+
+ // Get the exception id.
+ String id = ex.getId();
+
+ // If this is the user exception we expect to catch, read and throw
+ // it here. The system exception, if thrown, is handled by _invoke.
+ if (id.equals("IDL:gnu/classpath/examples/CORBA/SimpleCommunication/communication/ourUserException:1.0")
+ )
+ throw ourUserExceptionHelper.read(in);
+ else
+ throw new MARSHAL(id);
+ }
+ catch (RemarshalException _rm)
+ {
+ throwException(parameter);
+ }
+ finally
+ {
+ _releaseReply(in);
+ }
+ }
+}
diff --git a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/comServant.java b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/comServant.java
new file mode 100644
index 000000000..7f286cbbc
--- /dev/null
+++ b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/comServant.java
@@ -0,0 +1,236 @@
+/* comServant.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.examples.CORBA.SimpleCommunication.communication;
+
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.ByteHolder;
+import org.omg.CORBA.CompletionStatus;
+import org.omg.CORBA.DoubleHolder;
+import org.omg.CORBA.ShortHolder;
+import org.omg.CORBA.StringHolder;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.PrintStream;
+
+/**
+ * This class handles the actual server functionality in this test
+ * application. When the client calls the remote method, this
+ * finally results calling the method of this class.
+ *
+ * The parameters, passed to the server only, are just parameters of the
+ * java methods. The parameters that shuld be returned to client
+ * are wrapped into holder classes.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class comServant
+ extends _comTesterImplBase
+{
+ /**
+ * The field, that can be set and checked by remote client.
+ */
+ private int m_theField = 17;
+
+ /**
+ * Passes wide (UTF-16) string and narrow (ISO8859_1) string.
+ * @see gnu.CORBA.GIOP.CharSets_OSF for supported and default
+ * encodings. Returs they generalization as a wide string.
+ */
+ public String passCharacters(String wide, String narrow)
+ {
+ System.out.println("SERVER: **** Wide and narrow string test.");
+ System.out.println("SERVER: Received '" + narrow + "' and '" + wide +
+ "'"
+ );
+
+ return "return '" + narrow + "' and '" + wide + "'";
+ }
+
+ /**
+ * Accept and return parameters, having various types.
+ */
+ public int passSimple(ByteHolder an_octet, int a_long, ShortHolder a_short,
+ StringHolder a_string, DoubleHolder a_double
+ )
+ {
+ System.out.println("SERVER: ***** Test passing multiple parameters");
+ System.out.println("SERVER: Received:");
+ System.out.println("SERVER: octet " + an_octet.value);
+ System.out.println("SERVER: short " + a_short.value);
+ System.out.println("SERVER: string " + a_string.value);
+
+ // Returning incremented values.
+ an_octet.value++;
+ a_short.value++;
+
+ // OUT parameter, return only.
+ a_double.value = 1;
+ a_string.value += " [return]";
+ return 452572;
+ }
+
+ /**
+ * Accept and return the string arrays.
+ */
+ public String[] passStrings(String[] args)
+ {
+ System.out.println("SERVER: ***** Transferring string arrays");
+
+ String[] rt = new String[ args.length ];
+ for (int i = 0; i < args.length; i++)
+ {
+ System.out.println("SERVER: " + args [ i ]);
+
+ // Returning the changed content.
+ rt [ i ] = args [ i ] + ":" + args [ i ];
+ }
+ return rt;
+ }
+
+ /**
+ * Accept and return the structures.
+ */
+ public returnThis passStructure(passThis in_structure)
+ {
+ System.out.println("SERVER: ***** Transferring structures");
+ System.out.println("SERVER: Received " + in_structure.a + ":" +
+ in_structure.b
+ );
+
+ // Create and send back the returned structure.
+ returnThis r = new returnThis();
+ r.c = in_structure.a + in_structure.b;
+ r.n = 555;
+ r.arra = new int[] { 11, 22, 33 };
+ return r;
+ }
+
+ /**
+ * Pass and return the tree structure
+ */
+ public void passTree(nodeHolder tree)
+ {
+ System.out.println("SERVER: ***** Transferring tree");
+
+ StringBuffer b = new StringBuffer();
+
+ // This both creates the tree string representation
+ // and changes the node names.
+ getImage(b, tree.value);
+ System.out.println("SERVER: The tree was: " + b + ", returning changed.");
+ }
+
+ /**
+ * Just prints the hello message.
+ */
+ public void sayHello()
+ {
+ System.out.println("SERVER: ***** Hello, world!");
+ }
+
+ /**
+ * Get the value of our field.
+ */
+ public int theField()
+ {
+ System.out.println("SERVER: ***** Getting the field value, " + m_theField);
+ return m_theField;
+ }
+
+ /**
+ * Set the value of our field.
+ */
+ public void theField(int a_field)
+ {
+ System.out.println("SERVER: ***** Setting the field value to " + a_field);
+ m_theField = a_field;
+ }
+
+ /**
+ * Throw an exception.
+ *
+ * @param parameter specifies which exception will be thrown.
+ *
+ * @throws ourUserException for the non negative parameter.
+ * @throws BAD_OPERATION for the negative parameter.
+ */
+ public void throwException(int parameter)
+ throws ourUserException
+ {
+ System.out.println("SERVER: ***** Testing exceptions");
+ if (parameter > 0)
+ {
+ System.out.println("SERVER: Throwing the user exception, " +
+ "specific field = "+parameter
+ );
+ throw new ourUserException(parameter);
+ }
+ else
+ {
+ System.out.println("SERVER: Throwing " +
+ "the BAD_OPERATION, minor 456, completed"
+ );
+ throw new BAD_OPERATION(456, CompletionStatus.COMPLETED_YES);
+ }
+ }
+
+ /**
+ * Visit all tree nodes, getting the string representation
+ * and adding '++' to the node names.
+ *
+ * @param b the buffer to collect the string representation.
+ * @param n the rott tree node.
+ */
+ private void getImage(StringBuffer b, node n)
+ {
+ b.append(n.name);
+ n.name = n.name + "++";
+ b.append(": (");
+
+ for (int i = 0; i < n.children.length; i++)
+ {
+ getImage(b, n.children [ i ]);
+ b.append(' ');
+ }
+ b.append(") ");
+ }
+}
diff --git a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/comTester.java b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/comTester.java
new file mode 100644
index 000000000..49188b6e1
--- /dev/null
+++ b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/comTester.java
@@ -0,0 +1,111 @@
+/* comTester.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.examples.CORBA.SimpleCommunication.communication;
+
+import org.omg.CORBA.ByteHolder;
+import org.omg.CORBA.DoubleHolder;
+import org.omg.CORBA.ShortHolder;
+import org.omg.CORBA.StringHolder;
+
+/**
+ * The interface of our remote object. Some IDL compiles split it
+ * into "comTester" and "comTesterOperations", but we do not see
+ * much sense in doing this here.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface comTester
+{
+ /**
+ * Passes wide (UTF-16) string and narrow (ISO8859_1) string.
+ * Both types are mapped into java String.
+ *
+ * @see gnu.CORBA.GIOP.CharSets_OSF for supported and default
+ * encodings.
+ */
+ String passCharacters(String wide, String narrow);
+
+ /**
+ * Passes various parameters in both directions.
+ * The parameters that must return the value are wrapped in holders.
+ */
+ int passSimple(ByteHolder an_octet, int a_long, ShortHolder a_short,
+ StringHolder a_string, DoubleHolder a_double
+ );
+
+ /**
+ * Passes and returns the string sequence (flexible length).
+ */
+ String[] passStrings(String[] arg);
+
+ /**
+ * Passes and returns the structures.
+ */
+ returnThis passStructure(passThis in_structure);
+
+ /**
+ * Pass and return the tree structure
+ *
+ * @param tree the root node of the tree.
+ */
+ void passTree(nodeHolder tree);
+
+ /**
+ * Just prints the "Hello" message.
+ */
+ void sayHello();
+
+ /**
+ * Gets the value of the field in our object.
+ */
+ int theField();
+
+ /**
+ * Sets the value for the field in our object.
+ */
+ void theField(int newTheField);
+
+ /**
+ * Throws either 'ourUserException' with the 'ourField' field
+ * initialised to the passed positive value
+ * or system exception (if the parameter is zero or negative).
+ */
+ void throwException(int parameter)
+ throws ourUserException;
+}
diff --git a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/node.java b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/node.java
new file mode 100644
index 000000000..4040eb769
--- /dev/null
+++ b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/node.java
@@ -0,0 +1,55 @@
+/* node.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.examples.CORBA.SimpleCommunication.communication;
+
+/**
+ * The support for the tree structure, used in the test of
+ * ability to pass and return the tree structure.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class node
+ implements org.omg.CORBA.portable.IDLEntity
+{
+ /** The node name */
+ public String name = null;
+
+ /** The node children. */
+ public node[] children = null;
+}
diff --git a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/nodeHelper.java b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/nodeHelper.java
new file mode 100644
index 000000000..46fc0a791
--- /dev/null
+++ b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/nodeHelper.java
@@ -0,0 +1,160 @@
+/* nodeHelper.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.examples.CORBA.SimpleCommunication.communication;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.StructMember;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * This class is used for various helper operations around the
+ * tree {@link} structure.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class nodeHelper
+{
+ /**
+ * The node repository id, used to identify the structure.
+ */
+ private static String _id =
+ "IDL:gnu/classpath/examples/CORBA/SimpleCommunication/communication/node:1.0";
+
+ /**
+ * Caches the typecode, allowing to compute it only once.
+ */
+ private static TypeCode typeCode;
+
+ /**
+ * This is used to handle the recursive object references in
+ * CORBA - supported way. The tree node definition is recursive,
+ * as the node contains the sequence of the nodes as its field.
+ */
+ private static boolean active;
+
+ /**
+ * Extract the tree node from the unversal CORBA wrapper, Any.
+ */
+ public static node extract(Any a)
+ {
+ return read(a.create_input_stream());
+ }
+
+ /**
+ * Get the node string identifer.
+ */
+ public static String id()
+ {
+ return _id;
+ }
+
+ /**
+ * Insert the node into the universal CORBA wrapper, Any.
+ */
+ public static void insert(Any a, node that)
+ {
+ OutputStream out = a.create_output_stream();
+ a.type(type());
+ write(out, that);
+ a.read_value(out.create_input_stream(), type());
+ }
+
+ /**
+ * Read the node from the common data reprentation (CDR) stream.
+ */
+ public static node read(InputStream istream)
+ {
+ node value = new node();
+ value.name = istream.read_string();
+
+ int _len0 = istream.read_long();
+ value.children = new node[ _len0 ];
+ for (int i = 0; i < value.children.length; ++i)
+ value.children [ i ] = nodeHelper.read(istream);
+ return value;
+ }
+
+ /**
+ * Get the node type code definition.
+ */
+ public static synchronized TypeCode type()
+ {
+ // Compute the type code only once.
+ if (typeCode == null)
+ {
+ synchronized (TypeCode.class)
+ {
+ if (typeCode == null)
+ {
+ // To avoid the infinite recursion loop, the
+ // recursive reference is handled in specific way.
+ if (active)
+ return ORB.init().create_recursive_tc(_id);
+ active = true;
+
+ // List all memebers of the node structure.
+ StructMember[] members = new StructMember[ 2 ];
+ TypeCode memberType;
+ memberType = ORB.init().create_string_tc(0);
+ members [ 0 ] = new StructMember("name", memberType, null);
+ memberType = ORB.init().create_recursive_tc("");
+ members [ 1 ] = new StructMember("children", memberType, null);
+ typeCode =
+ ORB.init().create_struct_tc(nodeHelper.id(), "node", members);
+ active = false;
+ }
+ }
+ }
+ return typeCode;
+ }
+
+ /**
+ * Write the node into the common data reprentation (CDR) stream.
+ */
+ public static void write(OutputStream ostream, node value)
+ {
+ ostream.write_string(value.name);
+ ostream.write_long(value.children.length);
+ for (int i = 0; i < value.children.length; ++i)
+ nodeHelper.write(ostream, value.children [ i ]);
+ }
+}
diff --git a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/nodeHolder.java b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/nodeHolder.java
new file mode 100644
index 000000000..93d53912a
--- /dev/null
+++ b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/nodeHolder.java
@@ -0,0 +1,100 @@
+/* nodeHolder.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.examples.CORBA.SimpleCommunication.communication;
+
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
+
+/**
+ * The node holder is a wrapper about the node data structure. It
+ * can be used where the node must be passed both to and from
+ * the method being called. The same structure holds the tree,
+ * as it can be represented as a root node with children.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class nodeHolder
+ implements Streamable
+{
+ /**
+ * Stores the node value.
+ */
+ public node value;
+
+ /**
+ * Creates the node holder with the null initial value.
+ */
+ public nodeHolder()
+ {
+ }
+
+ /**
+ * Creates the node holder with the given initial value.
+ */
+ public nodeHolder(node initialValue)
+ {
+ value = initialValue;
+ }
+
+ /**
+ * Reads the node value from the common data representation (CDR)
+ * stream.
+ */
+ public void _read(InputStream in)
+ {
+ value = nodeHelper.read(in);
+ }
+
+ /**
+ * Writes the node value into common data representation (CDR)
+ * stream.
+ * @return
+ */
+ public TypeCode _type()
+ {
+ return nodeHelper.type();
+ }
+
+ public void _write(OutputStream out)
+ {
+ nodeHelper.write(out, value);
+ }
+}
diff --git a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/ourUserException.java b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/ourUserException.java
new file mode 100644
index 000000000..aea4a8bd9
--- /dev/null
+++ b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/ourUserException.java
@@ -0,0 +1,70 @@
+/* ourUserException.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.examples.CORBA.SimpleCommunication.communication;
+
+import org.omg.CORBA.UserException;
+import org.omg.CORBA.portable.IDLEntity;
+
+/**
+ * Our user exception, thrown in the tests of handling the exceptions,
+ * thrown on remote side. The exception contains the user - defined
+ * data field that is transferred from client to the server when the
+ * exception is thrown.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class ourUserException
+ extends UserException
+ implements IDLEntity
+{
+ /**
+ * Our specific field, transferred to client.
+ */
+ public int ourField;
+
+ /**
+ * Create the exception.
+ *
+ * @param _ourField the value of our specific field.
+ */
+ public ourUserException(int _ourField)
+ {
+ ourField = _ourField;
+ }
+}
diff --git a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/ourUserExceptionHelper.java b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/ourUserExceptionHelper.java
new file mode 100644
index 000000000..a5b2fa671
--- /dev/null
+++ b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/ourUserExceptionHelper.java
@@ -0,0 +1,107 @@
+/* ourUserExceptionHelper.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.examples.CORBA.SimpleCommunication.communication;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.StructMember;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCode;
+
+/**
+ * The class, providing various helper operations with our user
+ * exception.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class ourUserExceptionHelper
+{
+ /**
+ * The exception repository id. This name is also used to find the
+ * mapping local CORBA class.
+ */
+ private static String _id =
+ "IDL:gnu/classpath/examples/CORBA/SimpleCommunication/communication/ourUserException:1.0";
+
+ /**
+ * Get the exception repository id.
+ */
+ public static String id()
+ {
+ return _id;
+ }
+
+ /**
+ * Read the exception from the CDR stream.
+ */
+ public static ourUserException read(org.omg.CORBA.portable.InputStream istream)
+ {
+ ourUserException value = new ourUserException(0);
+
+ // The repository ID is not used
+ istream.read_string();
+ value.ourField = istream.read_long();
+ return value;
+ }
+
+ /**
+ * Create the type code of this exception.
+ */
+ public static synchronized TypeCode type()
+ {
+ StructMember[] members = new StructMember[ 1 ];
+ TypeCode member = null;
+ member = ORB.init().get_primitive_tc(TCKind.tk_long);
+ members [ 0 ] = new StructMember("ourField", member, null);
+ return ORB.init().create_struct_tc(ourUserExceptionHelper.id(),
+ "ourUserException", members
+ );
+ }
+
+ /**
+ * Write the exception into the CDR stream.
+ */
+ public static void write(org.omg.CORBA.portable.OutputStream ostream,
+ ourUserException value
+ )
+ {
+ ostream.write_string(id());
+ ostream.write_long(value.ourField);
+ }
+}
diff --git a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/passThis.java b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/passThis.java
new file mode 100644
index 000000000..f9ba02dc2
--- /dev/null
+++ b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/passThis.java
@@ -0,0 +1,61 @@
+/* passThis.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.examples.CORBA.SimpleCommunication.communication;
+
+
+/**
+ * The data structure, passed from to the server from client in our tests.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class passThis
+ implements org.omg.CORBA.portable.IDLEntity
+{
+ /**
+ * The first string, stored in this structure (defined as
+ * "narrow string").
+ */
+ public String a;
+
+ /**
+ * The second string, stored in this structure (define as
+ * "wide" (usually Unicode) string.
+ */
+ public String b;
+}
diff --git a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/passThisHelper.java b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/passThisHelper.java
new file mode 100644
index 000000000..13242fd63
--- /dev/null
+++ b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/passThisHelper.java
@@ -0,0 +1,102 @@
+/* passThisHelper.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.examples.CORBA.SimpleCommunication.communication;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.StructMember;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * The helper operations for the {@link passThis}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class passThisHelper
+{
+ /**
+ * The repository ID of the {@link passThis}.
+ */
+ private static String id =
+ "IDL:gnu/classpath/examples/CORBA/SimpleCommunication/communication/passThis:1.0";
+
+ /**
+ * Get the repository id.
+ */
+ public static String id()
+ {
+ return id;
+ }
+
+ /**
+ * Read the structure from the CDR stram.
+ */
+ public static passThis read(InputStream istream)
+ {
+ passThis value = new passThis();
+ value.a = istream.read_string();
+ value.b = istream.read_wstring();
+ return value;
+ }
+
+ /**
+ * Get the type code of this structure.
+ */
+ public static synchronized TypeCode type()
+ {
+ StructMember[] members = new StructMember[ 2 ];
+ TypeCode member = null;
+ member = ORB.init().create_string_tc(0);
+ members [ 0 ] = new StructMember("a", member, null);
+ member = ORB.init().create_string_tc(0);
+ members [ 1 ] = new StructMember("b", member, null);
+ return ORB.init().create_struct_tc(passThisHelper.id(), "passThis", members);
+ }
+
+ /**
+ * Write the structure into the CDR stream.
+ */
+ public static void write(OutputStream ostream, passThis value)
+ {
+ ostream.write_string(value.a);
+ ostream.write_wstring(value.b);
+ }
+}
diff --git a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/passThisHolder.java b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/passThisHolder.java
new file mode 100644
index 000000000..0d93cbaf6
--- /dev/null
+++ b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/passThisHolder.java
@@ -0,0 +1,37 @@
+
+
+package gnu.classpath.examples.CORBA.SimpleCommunication.communication;
+
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
+
+public final class passThisHolder
+ implements Streamable
+{
+ public passThis value;
+
+ public passThisHolder()
+ {
+ }
+
+ public passThisHolder(passThis initialValue)
+ {
+ value = initialValue;
+ }
+
+ public void _read(InputStream i)
+ {
+ value = passThisHelper.read(i);
+ }
+
+ public org.omg.CORBA.TypeCode _type()
+ {
+ return passThisHelper.type();
+ }
+
+ public void _write(OutputStream o)
+ {
+ passThisHelper.write(o, value);
+ }
+}
diff --git a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/returnThis.java b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/returnThis.java
new file mode 100644
index 000000000..b13b983bb
--- /dev/null
+++ b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/returnThis.java
@@ -0,0 +1,66 @@
+/* returnThis.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.examples.CORBA.SimpleCommunication.communication;
+
+import org.omg.CORBA.portable.IDLEntity;
+
+/**
+ * This data structure is returned from the server to client in our tests.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class returnThis
+ implements IDLEntity
+{
+ /**
+ * The string field.
+ */
+ public String c;
+
+ /**
+ * The CORBA array field. This field is handled as the fixed
+ * size CORBA array, but structures can also have the variable
+ * size CORBA sequences.
+ */
+ public int[] arra = new int[3];
+
+ /**
+ * The int (CORBA long) field.
+ */
+ public int n;
+}
diff --git a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/returnThisHelper.java b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/returnThisHelper.java
new file mode 100644
index 000000000..db6a11217
--- /dev/null
+++ b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/returnThisHelper.java
@@ -0,0 +1,115 @@
+/* returnThisHelper.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.examples.CORBA.SimpleCommunication.communication;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.StructMember;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * This class defines the helper operations for {@link returnThis}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class returnThisHelper
+{
+ /**
+ * The repository id.
+ */
+ private static String _id =
+ "IDL:gnu/classpath/examples/CORBA/SimpleCommunication/communication/returnThis:1.0";
+
+ /**
+ * Return the repository id.
+ */
+ public static String id()
+ {
+ return _id;
+ }
+
+ /**
+ * Read the structure from the CDR stream.
+ */
+ public static returnThis read(InputStream istream)
+ {
+ returnThis value = new returnThis();
+ value.n = istream.read_long();
+ value.c = istream.read_wstring();
+ value.arra = new int[ 3 ];
+
+ // Read the fixed size array.
+ for (int i = 0; i < 3; i++)
+ value.arra [ i ] = istream.read_long();
+ return value;
+ }
+
+ /**
+ * Create the typecode.
+ */
+ public static synchronized TypeCode type()
+ {
+ StructMember[] members = new StructMember[ 3 ];
+ TypeCode member = ORB.init().get_primitive_tc(TCKind.tk_long);
+ members [ 0 ] = new StructMember("n", member, null);
+ member = ORB.init().create_string_tc(0);
+ members [ 1 ] = new StructMember("c", member, null);
+ member = ORB.init().get_primitive_tc(TCKind.tk_long);
+ member = ORB.init().create_array_tc(3, member);
+ members [ 2 ] = new StructMember("arra", member, null);
+ return ORB.init().create_struct_tc(returnThisHelper.id(), "returnThis",
+ members
+ );
+ }
+
+ /**
+ * Write the structure to the CDR stream.
+ */
+ public static void write(OutputStream ostream, returnThis value)
+ {
+ ostream.write_long(value.n);
+ ostream.write_wstring(value.c);
+
+ // Write the fixed size array.
+ for (int i = 0; i < 3; i++)
+ ostream.write_long(value.arra [ i ]);
+ }
+}
diff --git a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/returnThisHolder.java b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/returnThisHolder.java
new file mode 100644
index 000000000..294e37ac3
--- /dev/null
+++ b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/returnThisHolder.java
@@ -0,0 +1,60 @@
+
+
+package gnu.classpath.examples.CORBA.SimpleCommunication.communication;
+
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
+
+/**
+ * The holder for the structure, returned from the server.
+ */
+public final class returnThisHolder
+ implements Streamable
+{
+ /**
+ * The enclosed structure.
+ */
+ public returnThis value = null;
+
+ /**
+ * Create the empty holder.
+ */
+ public returnThisHolder()
+ {
+ }
+
+ /**
+ * Crate the holder with the defined initial value.
+ */
+ public returnThisHolder(returnThis initialValue)
+ {
+ value = initialValue;
+ }
+
+ /**
+ * Read the value from the CDR stream.
+ */
+ public void _read(InputStream in)
+ {
+ value = returnThisHelper.read(in);
+ }
+
+ /**
+ * Get the typecode of this structure.
+ */
+ public TypeCode _type()
+ {
+ return returnThisHelper.type();
+ }
+
+ /**
+ * Write the value from the CDR stream.
+ * @param out
+ */
+ public void _write(OutputStream out)
+ {
+ returnThisHelper.write(out, value);
+ }
+}