aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA')
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/NamingService/Demo.java200
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/Demo.java102
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/DemoServer.java118
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/DemoServant.java230
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/DemoTester.java111
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/DirectTest.java344
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/RequestTest.java284
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToPass.java66
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToPassHelper.java103
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToPassHolder.java37
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToReturn.java71
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToReturnHelper.java116
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToReturnHolder.java60
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/TreeNode.java60
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/TreeNodeHelper.java162
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/TreeNodeHolder.java100
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/WeThrowThisException.java75
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/WeThrowThisExceptionHelper.java117
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_DemoTesterImplBase.java209
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_DemoTesterStub.java429
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/README.html493
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/CanvasWorld.java307
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/ChatConstants.java80
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/ClientFrame.java417
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/Demo.java99
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/GameManager.java68
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/GameManagerImpl.java135
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/IorReader.java124
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/OrbStarter.java236
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/Player.java96
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/PlayerImpl.java275
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/PlayingDesk.java512
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/State.java82
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/X5Server.java175
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/_GameManagerImpl_Tie.java209
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/_GameManager_Stub.java207
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/_PlayerImpl_Tie.java209
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/_Player_Stub.java397
38 files changed, 7115 insertions, 0 deletions
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/NamingService/Demo.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/NamingService/Demo.java
new file mode 100644
index 000000000..38c4ecb98
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/NamingService/Demo.java
@@ -0,0 +1,200 @@
+/* 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 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(String[] an_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"
+ );
+
+ final String[] args = an_args;
+
+ new Thread()
+ {
+ public void run()
+ {
+ gnu.classpath.tools.tnameserv.Main.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/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/Demo.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/Demo.java
new file mode 100644
index 000000000..f53609cf7
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/Demo.java
@@ -0,0 +1,102 @@
+/* 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 java.io.File;
+
+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)
+ {
+ File ior = new File("IOR.txt");
+ if (ior.exists())
+ ior.delete();
+
+ // Start the server.
+ new Thread()
+ {
+ public void run()
+ {
+ DemoServer.start_server(args);
+ }
+ }.start();
+
+ System.out.print("Waiting for the server to start ");
+ while (!ior.exists())
+ {
+ // Pause some time for the server to start.
+ try
+ {
+ Thread.sleep(200);
+ }
+ catch (InterruptedException ex)
+ {
+ }
+ System.out.print(".");
+ }
+ System.out.println("ok.");
+ System.out.println();
+
+ // Test the stream oriented communication.
+ DirectTest.main(args);
+ // Test the request oriented communication.
+ RequestTest.main(args);
+
+ System.exit(0);
+ }
+}
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/DemoServer.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/DemoServer.java
new file mode 100644
index 000000000..d7b1a7771
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/DemoServer.java
@@ -0,0 +1,118 @@
+/* DemoServer.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DemoServant;
+
+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 DemoServant}.
+ *
+ * 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 DemoServer
+{
+
+ 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.
+ DemoServant tester = new DemoServant();
+ 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/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/DemoServant.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/DemoServant.java
new file mode 100644
index 000000000..9af20d227
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/DemoServant.java
@@ -0,0 +1,230 @@
+/* DemoServant.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+/**
+ * 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 DemoServant
+ extends _DemoTesterImplBase
+{
+ /**
+ * 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 StructureToReturn passStructure(StructureToPass 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.
+ StructureToReturn r = new StructureToReturn();
+ 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(TreeNodeHolder tree)
+ {
+ System.out.println("SERVER: ***** Transferring tree");
+
+ StringBuilder b = new StringBuilder();
+
+ // This both creates the tree string representation
+ // and changes the TreeNode 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 WeThrowThisException for the non negative parameter.
+ * @throws BAD_OPERATION for the negative parameter.
+ */
+ public void throwException(int parameter)
+ throws WeThrowThisException
+ {
+ System.out.println("SERVER: ***** Testing exceptions");
+ if (parameter > 0)
+ {
+ System.out.println("SERVER: Throwing the user exception, " +
+ "specific field = "+parameter
+ );
+ throw new WeThrowThisException(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 TreeNode names.
+ *
+ * @param b the buffer to collect the string representation.
+ * @param n the rott tree TreeNode.
+ */
+ private void getImage(StringBuilder b, TreeNode 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/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/DemoTester.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/DemoTester.java
new file mode 100644
index 000000000..f3766f325
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/DemoTester.java
@@ -0,0 +1,111 @@
+/* DemoTester.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 "DemoTester" and "comTesterOperations", but we do not see
+ * much sense in doing this here.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface DemoTester
+{
+ /**
+ * 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.
+ */
+ StructureToReturn passStructure(StructureToPass in_structure);
+
+ /**
+ * Pass and return the tree structure
+ *
+ * @param tree the root TreeNode of the tree.
+ */
+ void passTree(TreeNodeHolder 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 'WeThrowThisException' 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 WeThrowThisException;
+}
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/DirectTest.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/DirectTest.java
new file mode 100644
index 000000000..843530de5
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.DemoServer}.
+ * 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.
+ */
+ DemoTester 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 = (DemoTester) 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");
+
+ StructureToPass arg = new StructureToPass();
+ arg.a = "A";
+ arg.b = "B";
+
+ StructureToReturn 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.");
+
+ TreeNode n = nod("Root");
+
+ n.children = new TreeNode[] { nod("a"), nod("b") };
+ n.children [ 1 ].children = new TreeNode[] { nod("ba"), nod("bb") };
+ n.children [ 1 ].children [ 0 ].children = new TreeNode[] { nod("bac") };
+
+ TreeNodeHolder nh = new TreeNodeHolder(n);
+
+ // The server should add '++' to each TreeNode name.
+ object.passTree(nh);
+
+ // Convert the returned tree to some strig representation.
+ StringBuilder img = new StringBuilder();
+ 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 (WeThrowThisException 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 TreeNode).
+ */
+ private void getImage(StringBuilder b, TreeNode 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 TreeNode with the given header.
+ *
+ * @param hdr the TreeNode header.
+ * @return the created TreeNode.
+ */
+ private TreeNode nod(String hdr)
+ {
+ TreeNode n = new TreeNode();
+ n.children = new TreeNode[ 0 ];
+ n.name = hdr;
+
+ return n;
+ }
+}
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/RequestTest.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/RequestTest.java
new file mode 100644
index 000000000..9c908e520
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/RequestTest.java
@@ -0,0 +1,284 @@
+/* RequestTest.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., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 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 java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.ExceptionList;
+import org.omg.CORBA.NVList;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.Request;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.UnknownUserException;
+
+/**
+ * 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.DemoServer}.
+ * 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();
+ 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);
+
+ 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(WeThrowThisExceptionHelper.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(WeThrowThisExceptionHelper.type());
+
+ Request rq =
+ object._create_request(null, "throwException", orb.create_list(1), null,
+ exList, null
+ );
+
+ rq.add_in_arg().insert_long(123);
+ rq.invoke();
+
+ UnknownUserException uku = (UnknownUserException) rq.env().exception();
+ WeThrowThisException our_exception = WeThrowThisExceptionHelper.extract(uku.except);
+
+ System.out.println(" Our user exception, field " + our_exception.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/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToPass.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToPass.java
new file mode 100644
index 000000000..d17e91fba
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToPass.java
@@ -0,0 +1,66 @@
+/* StructureToPass.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 StructureToPass
+ implements org.omg.CORBA.portable.IDLEntity
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
+ * 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/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToPassHelper.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToPassHelper.java
new file mode 100644
index 000000000..155ad170b
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToPassHelper.java
@@ -0,0 +1,103 @@
+/* StructureToPassHelper.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 gnu.CORBA.OrbRestricted;
+
+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 StructureToPass}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class StructureToPassHelper
+{
+ /**
+ * The repository ID of the {@link StructureToPass}.
+ */
+ private static String id =
+ "IDL:gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToPass:1.0";
+
+ /**
+ * Get the repository id.
+ */
+ public static String id()
+ {
+ return id;
+ }
+
+ /**
+ * Read the structure from the CDR stram.
+ */
+ public static StructureToPass read(InputStream istream)
+ {
+ StructureToPass value = new StructureToPass();
+ 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 = OrbRestricted.Singleton.create_string_tc(0);
+ members[0] = new StructMember("a", member, null);
+ member = OrbRestricted.Singleton.create_string_tc(0);
+ members[1] = new StructMember("b", member, null);
+ return OrbRestricted.Singleton.create_struct_tc(StructureToPassHelper.id(),
+ "StructureToPass", members);
+ }
+
+ /**
+ * Write the structure into the CDR stream.
+ */
+ public static void write(OutputStream ostream, StructureToPass value)
+ {
+ ostream.write_string(value.a);
+ ostream.write_wstring(value.b);
+ }
+}
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToPassHolder.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToPassHolder.java
new file mode 100644
index 000000000..5bbe6908e
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToPassHolder.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 StructureToPassHolder
+ implements Streamable
+{
+ public StructureToPass value;
+
+ public StructureToPassHolder()
+ {
+ }
+
+ public StructureToPassHolder(StructureToPass initialValue)
+ {
+ value = initialValue;
+ }
+
+ public void _read(InputStream i)
+ {
+ value = StructureToPassHelper.read(i);
+ }
+
+ public org.omg.CORBA.TypeCode _type()
+ {
+ return StructureToPassHelper.type();
+ }
+
+ public void _write(OutputStream o)
+ {
+ StructureToPassHelper.write(o, value);
+ }
+}
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToReturn.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToReturn.java
new file mode 100644
index 000000000..5dc843ae8
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToReturn.java
@@ -0,0 +1,71 @@
+/* StructureToReturn.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 StructureToReturn
+ implements IDLEntity
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
+ * 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/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToReturnHelper.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToReturnHelper.java
new file mode 100644
index 000000000..83f422c52
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToReturnHelper.java
@@ -0,0 +1,116 @@
+/* StructureToReturnHelper.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 gnu.CORBA.OrbRestricted;
+
+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 StructureToReturn}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class StructureToReturnHelper
+{
+ /**
+ * The repository id.
+ */
+ private static String _id =
+ "IDL:gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToReturn:1.0";
+
+ /**
+ * Return the repository id.
+ */
+ public static String id()
+ {
+ return _id;
+ }
+
+ /**
+ * Read the structure from the CDR stream.
+ */
+ public static StructureToReturn read(InputStream istream)
+ {
+ StructureToReturn value = new StructureToReturn();
+ 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 = OrbRestricted.Singleton.get_primitive_tc(TCKind.tk_long);
+ members[0] = new StructMember("n", member, null);
+ member = OrbRestricted.Singleton.create_string_tc(0);
+ members[1] = new StructMember("c", member, null);
+ member = OrbRestricted.Singleton.get_primitive_tc(TCKind.tk_long);
+ member = OrbRestricted.Singleton.create_array_tc(3, member);
+ members[2] = new StructMember("arra", member, null);
+ return OrbRestricted.Singleton.create_struct_tc(
+ StructureToReturnHelper.id(),
+ "StructureToReturn",
+ members);
+ }
+
+ /**
+ * Write the structure to the CDR stream.
+ */
+ public static void write(OutputStream ostream, StructureToReturn 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/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToReturnHolder.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToReturnHolder.java
new file mode 100644
index 000000000..c70f9cfcc
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToReturnHolder.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 StructureToReturnHolder
+ implements Streamable
+{
+ /**
+ * The enclosed structure.
+ */
+ public StructureToReturn value = null;
+
+ /**
+ * Create the empty holder.
+ */
+ public StructureToReturnHolder()
+ {
+ }
+
+ /**
+ * Crate the holder with the defined initial value.
+ */
+ public StructureToReturnHolder(StructureToReturn initialValue)
+ {
+ value = initialValue;
+ }
+
+ /**
+ * Read the value from the CDR stream.
+ */
+ public void _read(InputStream in)
+ {
+ value = StructureToReturnHelper.read(in);
+ }
+
+ /**
+ * Get the typecode of this structure.
+ */
+ public TypeCode _type()
+ {
+ return StructureToReturnHelper.type();
+ }
+
+ /**
+ * Write the value from the CDR stream.
+ * @param out
+ */
+ public void _write(OutputStream out)
+ {
+ StructureToReturnHelper.write(out, value);
+ }
+}
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/TreeNode.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/TreeNode.java
new file mode 100644
index 000000000..b267f39ea
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/TreeNode.java
@@ -0,0 +1,60 @@
+/* TreeNode.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 TreeNode
+ implements org.omg.CORBA.portable.IDLEntity
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /** The TreeNode name */
+ public String name = null;
+
+ /** The TreeNode children. */
+ public TreeNode[] children = null;
+}
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/TreeNodeHelper.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/TreeNodeHelper.java
new file mode 100644
index 000000000..eac1c9a24
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/TreeNodeHelper.java
@@ -0,0 +1,162 @@
+/* TreeNodeHelper.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 gnu.CORBA.OrbRestricted;
+
+import org.omg.CORBA.Any;
+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 TreeNodeHelper
+{
+ /**
+ * The TreeNode repository id, used to identify the structure.
+ */
+ private static String _id =
+ "IDL:gnu/classpath/examples/CORBA/SimpleCommunication/communication/TreeNode: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 TreeNode definition is recursive,
+ * as the TreeNode contains the sequence of the nodes as its field.
+ */
+ private static boolean active;
+
+ /**
+ * Extract the tree TreeNode from the unversal CORBA wrapper, Any.
+ */
+ public static TreeNode extract(Any a)
+ {
+ return read(a.create_input_stream());
+ }
+
+ /**
+ * Get the TreeNode string identifer.
+ */
+ public static String id()
+ {
+ return _id;
+ }
+
+ /**
+ * Insert the TreeNode into the universal CORBA wrapper, Any.
+ */
+ public static void insert(Any a, TreeNode that)
+ {
+ OutputStream out = a.create_output_stream();
+ a.type(type());
+ write(out, that);
+ a.read_value(out.create_input_stream(), type());
+ }
+
+ /**
+ * Read the TreeNode from the common data reprentation (CDR) stream.
+ */
+ public static TreeNode read(InputStream istream)
+ {
+ TreeNode value = new TreeNode();
+ value.name = istream.read_string();
+
+ int _len0 = istream.read_long();
+ value.children = new TreeNode[ _len0 ];
+ for (int i = 0; i < value.children.length; ++i)
+ value.children [ i ] = TreeNodeHelper.read(istream);
+ return value;
+ }
+
+ /**
+ * Get the TreeNode 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 OrbRestricted.Singleton.create_recursive_tc(_id);
+ active = true;
+
+ // List all memebers of the TreeNode structure.
+ StructMember[] members = new StructMember[ 2 ];
+ TypeCode memberType;
+ memberType = OrbRestricted.Singleton.create_string_tc(0);
+ members [ 0 ] = new StructMember("name", memberType, null);
+ memberType = OrbRestricted.Singleton.create_recursive_tc("");
+ members [ 1 ] = new StructMember("children", memberType, null);
+ typeCode =
+ OrbRestricted.Singleton.create_struct_tc(TreeNodeHelper.id(), "TreeNode", members);
+ active = false;
+ }
+ }
+ }
+ return typeCode;
+ }
+
+ /**
+ * Write the TreeNode into the common data reprentation (CDR) stream.
+ */
+ public static void write(OutputStream ostream, TreeNode value)
+ {
+ ostream.write_string(value.name);
+ ostream.write_long(value.children.length);
+ for (int i = 0; i < value.children.length; ++i)
+ TreeNodeHelper.write(ostream, value.children [ i ]);
+ }
+}
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/TreeNodeHolder.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/TreeNodeHolder.java
new file mode 100644
index 000000000..ec180ce57
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/TreeNodeHolder.java
@@ -0,0 +1,100 @@
+/* TreeNodeHolder.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 TreeNode holder is a wrapper about the TreeNode data structure. It
+ * can be used where the TreeNode 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 TreeNode with children.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class TreeNodeHolder
+ implements Streamable
+{
+ /**
+ * Stores the TreeNode value.
+ */
+ public TreeNode value;
+
+ /**
+ * Creates the TreeNode holder with the null initial value.
+ */
+ public TreeNodeHolder()
+ {
+ }
+
+ /**
+ * Creates the TreeNode holder with the given initial value.
+ */
+ public TreeNodeHolder(TreeNode initialValue)
+ {
+ value = initialValue;
+ }
+
+ /**
+ * Reads the TreeNode value from the common data representation (CDR)
+ * stream.
+ */
+ public void _read(InputStream in)
+ {
+ value = TreeNodeHelper.read(in);
+ }
+
+ /**
+ * Writes the TreeNode value into common data representation (CDR)
+ * stream.
+ * @return
+ */
+ public TypeCode _type()
+ {
+ return TreeNodeHelper.type();
+ }
+
+ public void _write(OutputStream out)
+ {
+ TreeNodeHelper.write(out, value);
+ }
+}
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/WeThrowThisException.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/WeThrowThisException.java
new file mode 100644
index 000000000..cf20d61ec
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/WeThrowThisException.java
@@ -0,0 +1,75 @@
+/* WeThrowThisException.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 WeThrowThisException
+ extends UserException
+ implements IDLEntity
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
+ * Our specific field, transferred to client.
+ */
+ public int ourField;
+
+ /**
+ * Create the exception.
+ *
+ * @param _ourField the value of our specific field.
+ */
+ public WeThrowThisException(int _ourField)
+ {
+ ourField = _ourField;
+ }
+}
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/WeThrowThisExceptionHelper.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/WeThrowThisExceptionHelper.java
new file mode 100644
index 000000000..adf4d25d5
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/WeThrowThisExceptionHelper.java
@@ -0,0 +1,117 @@
+/* WeThrowThisExceptionHelper.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 gnu.CORBA.OrbRestricted;
+
+import org.omg.CORBA.Any;
+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 WeThrowThisExceptionHelper
+{
+ /**
+ * 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/WeThrowThisException:1.0";
+
+ /**
+ * Get the exception repository id.
+ */
+ public static String id()
+ {
+ return _id;
+ }
+
+ /**
+ * Extract the exception from the given Any where it might be
+ * wrapped.
+ */
+ public static WeThrowThisException extract(Any a)
+ {
+ return read(a.create_input_stream());
+ }
+
+ /**
+ * Read the exception from the CDR stream.
+ */
+ public static WeThrowThisException read(org.omg.CORBA.portable.InputStream istream)
+ {
+ WeThrowThisException value = new WeThrowThisException(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 = OrbRestricted.Singleton.get_primitive_tc(TCKind.tk_long);
+ members [ 0 ] = new StructMember("ourField", member, null);
+ return OrbRestricted.Singleton.create_struct_tc(WeThrowThisExceptionHelper.id(),
+ "WeThrowThisException", members
+ );
+ }
+
+ /**
+ * Write the exception into the CDR stream.
+ */
+ public static void write(org.omg.CORBA.portable.OutputStream ostream,
+ WeThrowThisException value
+ )
+ {
+ ostream.write_string(id());
+ ostream.write_long(value.ourField);
+ }
+} \ No newline at end of file
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_DemoTesterImplBase.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_DemoTesterImplBase.java
new file mode 100644
index 000000000..237c23086
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_DemoTesterImplBase.java
@@ -0,0 +1,209 @@
+/* _DemoTesterImplBase.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 DemoServant} of our case).
+ *
+ * Following CORBA standards, the name of this class must start from
+ * underscore and end by the "ImplBase".
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class _DemoTesterImplBase
+ extends ObjectImpl
+ implements DemoTester, 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 'WeThrowThisException' 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 (WeThrowThisException exception)
+ {
+ out = rh.createExceptionReply();
+ WeThrowThisExceptionHelper.write(out, exception);
+ }
+ }
+ else
+ /* Passes and returns the structures. */
+ if (a_method.equals("passStructure"))
+ {
+ StructureToPass in_structure = StructureToPassHelper.read(in);
+ StructureToReturn result = null;
+ result = passStructure(in_structure);
+ out = rh.createReply();
+ StructureToReturnHelper.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"))
+ {
+ TreeNodeHolder tree = new TreeNodeHolder();
+ tree.value = TreeNodeHelper.read(in);
+ passTree(tree);
+ out = rh.createReply();
+ TreeNodeHelper.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 _DemoTesterStub._ids;
+ }
+}
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_DemoTesterStub.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_DemoTesterStub.java
new file mode 100644
index 000000000..c8e0ccd6d
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_DemoTesterStub.java
@@ -0,0 +1,429 @@
+/* _DemoTesterStub.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.
+ *
+ * Following CORBA standards, the name of this class must start from
+ * underscore and end by the "Stub".
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class _DemoTesterStub
+ extends ObjectImpl
+ implements DemoTester
+{
+ /**
+ * A string array of DemoTester repository ids.
+ */
+ public static String[] _ids =
+ {
+ "IDL:gnu/classpath/examples/CORBA/SimpleCommunication/communication/DemoTester:1.0"
+ };
+
+ /**
+ * Return an array of DemoTester 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 StructureToReturn passStructure(StructureToPass 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.
+ StructureToPassHelper.write(out, in_structure);
+
+ // Invoke the method.
+ in = _invoke(out);
+
+ // Read the returned structer, using another helper.
+ StructureToReturn result = StructureToReturnHelper.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(TreeNodeHolder tree)
+ {
+ InputStream in = null;
+ try
+ {
+ // Get the stream where the parameters must be written.
+ OutputStream out = _request("passTree", true);
+
+ // Write the tree (TreeNode with its chilred, grandchildren and so on),
+ // using the appropriate helper.
+ TreeNodeHelper.write(out, tree.value);
+
+ // Call the method.
+ in = _invoke(out);
+
+ // Read the returned tree.
+ tree.value = TreeNodeHelper.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 WeThrowThisException
+ */
+ public void throwException(int parameter)
+ throws WeThrowThisException
+ {
+ 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/WeThrowThisException:1.0")
+ )
+ throw WeThrowThisExceptionHelper.read(in);
+ else
+ throw new MARSHAL(id);
+ }
+ catch (RemarshalException _rm)
+ {
+ throwException(parameter);
+ }
+ finally
+ {
+ _releaseReply(in);
+ }
+ }
+}
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/README.html b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/README.html
new file mode 100644
index 000000000..a3a9e6282
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/README.html
@@ -0,0 +1,493 @@
+<html>
+ <head>
+ <title>Five-in-a-row v 0.0</title>
+ </head>
+ <body LANG="en-US">
+ <h1>
+ <i>Five-in-a-row
+ </i> 0.0 supplementary documentation
+ </h1>
+ <h3>Introduction and rules
+ </h3>
+ <p>
+ <i>Five-in-a-row
+ </i> is a two player strategy game. The players
+ are connected via network using CORBA-based RMI/IIOP protocol and
+ make they moves with the help of the Swing-based
+ interface. While playing, the users can also chat.
+ </p>
+ <p>The system consists of the single server and any number of
+ interconnected players. The person, willing to play, starts the
+ client and connects the server. The server redirects call to the
+ partner that has previously connected the same server, also willing
+ to play.
+ </p>
+ <p>The game desk is a field where it is possible to set O's
+ and X'es, one per move. The goal is to get five O's in a row while
+ preventing your partner from getting five X's in a row. Vertical,
+ horizontal and diagonal rows are allowed. The system detects the
+ loss-victory situation on the desk, but currently does not serve as a
+ playing partner, requiring at least two human players for this game.
+ </p>
+ <p>Both players can at any time reset the game (restarting it with
+ the same player) or leave the game (disconnecting). The disconnected
+ player can contact the game manager again, requesting to find another
+ partner.
+ </p>
+ <p>Simple as it is, the application has some features of the typical
+ role playing game that frequently just has more states, actions,
+ possible moves and also provides far richer graphics environment. The
+ game manger serves as a World-Wide-Pub where you can always find a
+ partner to play.
+
+ The players can made both unsynchronized (chatting, game reset and
+ leaving) and synchronized (moves) actions. The game state changes
+ while playing, and the set of the available actions depends on the
+ current state. Finally, the mouse and canvas are involved. However
+ using RMI/IIOP machinery allowed to implement all this functionality
+ with just 13 classes (plus 4 generated), all of them being rather
+ simple.
+
+ This example refers to the standard classes only and must be buildable
+ from your IDE as long as it has any java 1.4 compiler.
+ </p>
+ <p>
+ The used IIOP protocol must ensure interoperability, allowing players
+ to use different java virtual machines and operating systems.
+ The processors may have the opposite byte order.
+ </p>
+ <h3>Configuration and run
+ </h3>
+ <p>The game manager server executable class is
+ <i>gnu.classpath.examples.CORBA.swing.x5.X5Server
+ </i>. After start,
+ it will print to console the Internet address that must be entered to
+ the client to reach the manager.
+ </p>
+ <p>The client executable class it
+ <i>gnu.classpath.examples.CORBA.swing.x5.Demo
+ </i>.
+ </p>
+ <p>The game should run with GNU Classpath
+ 0.19 and Sun Microsystems java 1.5.0_04. Due later fixed bugs it will
+ not run with the older versions of these two implementations.
+ </p>
+ <p>The game manager HTTP server uses port
+ 1500. Hence all firewalls between the server and the player must be
+ configured to allow HTTP on 1500. The ports, used by the RMI/IIOP are
+ not persistent. GNU Classpath is configured to take ports 1501, 1502
+ and 1503 (the firewalls must allow to use them for RMI/IIOP). The
+ CORBA implementation other than Classpath may use different port
+ values. Unfortunately, there is no standard method to configure the
+ used port range in a vendor-independent way.
+ </p>
+ <h3>The game server
+ </h3>
+ <p>The game manager is first reachable via http:// protocol (for
+ instance http://123.456.7.89:1500). The simple server at this port
+ always serves much longer string, representing the CORBA stringified
+ object reference (IOR). The
+ <i>Five-in-a-row&nbsp;
+ </i>client uses
+ this reference to find and access the remote game server object.
+ </p>
+ <p>If the server player queue is empty, it simply queues this player.
+ If the queue is not empty, the server introduces the arrived player
+ and queued player to each other as leaves the them alone. When
+ playing, the two clients communicate with each other directly, so the
+ server is just a &ldquo;meeting point&rdquo; where the players can
+ find each other. The game server is a console-only application.
+ </p>
+ <p>The initial server http:// address must be transferred to players
+ by some other means of communication (web chat, E-mail, link in a web
+ site and so on). The server writes this address to the specified
+ file, and the client can also take the default value from the same
+ file. This is convenient when all applications run on a single
+ machine, but also may be used to transfer the address via shared
+ filesystem.
+ </p>
+ <h3>The game client
+ </h3>
+ <p>The clients are Swing-based GUI applications, capable for remote
+ communication with each other and with the game manager. They have a
+ set of predefined states and switch between these states in
+ accordance to the preprogrammed logic. The client states are defined
+ in the
+ <i>State
+ </i> interface. They are displayed in the bottom left
+ corner of the window and are summarized in the following table:
+ </p>
+ <table BORDER=1 CELLPADDING=4 CELLSPACING=0 WIDTH="100%">
+ <thead>
+ <tr BGCOLOR="#ccccff">
+ <th BGCOLOR="#e6e6ff">
+ Our state
+ </th>
+ <th BGCOLOR="#e6e6ff">
+ Partner state
+ </th>
+ <th BGCOLOR="#e6e6ff">
+ Possible actions
+ </th>
+ <th BGCOLOR="#e6e6ff">
+ Comment
+ </th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>
+ Disconnected
+ </td>
+ <td>
+ Partner not accessible
+ </td>
+ <td>
+ Connect
+ </td>
+ <td>
+ Initial state.
+ </td>
+ </tr>
+ <tr>
+ <td>
+ Queued
+ </td>
+ <td>
+ Partner not accessible
+ </td>
+ <td>
+ Leave
+ </td>
+ <td>
+ Queued by the game manager.
+ </td>
+ </tr>
+ <tr>
+ <td>
+ I think.
+ </td>
+ <td>
+ I wait for your move
+ </td>
+ <td>
+ Make move, reset game, leave, chat.
+ </td>
+ <td>
+ The person who waited for another player to come starts
+ the game first.
+ </td>
+ </tr>
+ <tr>
+ <td>
+ I wait for your move
+ </td>
+ <td>
+ I think
+ </td>
+ <td>
+ Chat, reset game, leave.
+ </td>
+ <td>
+ After the partner makes the move, the state changes to
+ <i>I think
+ </i>, unless the end of game situation is detected by
+ the desk analyzer.
+ </td>
+ </tr>
+ <tr>
+ <td>
+ I have lost
+ </td>
+ <td>
+ I have won
+ </td>
+ <td>
+ Chat, reset game, leave.
+ </td>
+ <td>
+ Can be entered with the help of the desk analyzer only.
+ </td>
+ </tr>
+ <tr>
+ <td>
+ I have won
+ </td>
+ <td>
+ I have lost
+ </td>
+ <td>
+ Chat, reset game, leave
+ </td>
+ <td>
+ Can be entered with the help of the desk analyzer only.
+ </td>
+ </tr>
+ <tr>
+ <td>
+ Error
+ </td>
+ <td>
+ Any
+ </td>
+ <td>
+ Chat, leave
+ </td>
+ <td>
+ This should never happen under normal work, but the demo
+ program may be modified by the user.
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ <br>
+ <br>
+ As it is seen, being in one of the states, the client expects to
+ be the partner client in a certain defined state, and both clients
+ change they states in a synchronized manner. Each state has its own
+ set of the available actions and each action either preserves the
+ current state (chat, reset) or changes it following the rules. For
+ this simple example, the state change rules are obvious.
+ <h3>The used RMI-IIOP architecture
+ </h3>
+ Both player and game manager servants are derived from the
+ <i>org.omg.PortableServer.Servant
+ </i> and, being servants, are simply
+ connected to the
+ <i>POA
+ </i>with
+ <i>POA.servant_to_reference
+ </i>. The
+ first remote object (game manager) is found using the stringified
+ object reference. No naming service is involved.
+</p>
+Where required, the CORBA objects are narrowed into required
+player and game manager interfaces using method
+<i>PortableRemoteObject.narrow(org.omg.CORBA.Object object, Class
+ interface_class)
+</i>, passing the actual interface of the object as
+the second parameter. After narrowing, the remote side obtains
+possibility to invoke remote methods, defined in the interface of
+this object. After the first remote object is found, other objects
+can be simply passed as the method parameters. For instance, the game
+manager introduces another player by passing its reference as a
+parameter to the method
+<i>Player.start_game.
+</i>
+<h3>Class and interface summary
+</h3>
+<table BORDER=1 CELLPADDING=3 CELLSPACING=0 WIDTH="100%">
+ <col>
+ <col>
+ <tr>
+ <th COLSPAN=2 BGCOLOR="#e6e6ff">
+ Executables classes
+ </th>
+ </tr>
+ <tr>
+ <td>
+ Demo
+ </td>
+ <td>
+ The main executable class of the game client.
+ </td>
+ </tr>
+ <tr>
+ <td>
+ X5Server
+ </td>
+ <td>
+ The main executable class of the game manager server.
+ </td>
+ </tr>
+</table>
+<p></p>
+<table BORDER=1 CELLPADDING=3 CELLSPACING=0 WIDTH="100%">
+ <tr BGCOLOR="#ccccff">
+ <th COLSPAN=2 BGCOLOR="#e6e6ff">
+ Interface Summary
+ </th>
+ </tr>
+ <tr>
+ <td>
+ GameManager
+ </td>
+ <td>
+ The game manager interface.
+ </td>
+ </tr>
+ <tr>
+ <td>
+ Player
+ </td>
+ <td>
+ Defines remote methods that are invoked by another player or by
+ the challenge server.
+ </td>
+ </tr>
+ <tr>
+ <td>
+ State
+ </td>
+ <td>
+ Defines the states in that the player can be.
+ </td>
+ </tr>
+</table>
+&nbsp;
+<table BORDER=1 CELLPADDING=3 CELLSPACING=0 WIDTH="100%">
+ <col>
+ <col>
+ <tr BGCOLOR="#ccccff">
+ <th COLSPAN=2 BGCOLOR="#e6e6ff">
+ Class Summary
+ </th>
+ </tr>
+ <tr>
+ <td>
+ _GameManager_Stub
+ </td>
+ <td>
+ Normally generated with rmic compiler, this class represents
+ the GameManager Stub on the client side.
+ </td>
+ </tr>
+ <tr>
+ <td>
+ _GameManagerImpl_Tie
+ </td>
+ <td>
+ Normally generated with rmic compiler, this class represents
+ the GameManager Tie on the client side.
+ </td>
+ </tr>
+ <tr>
+ <td>
+ _Player_Stub
+ </td>
+ <td>
+ Generate with rmic, command line rmic -iiop -poa -keep
+ gnu.classpath.examples.CORBA.swing.x5.PlayerImpl (the compiled
+ package must be present in the current folder).
+ </td>
+ </tr>
+ <tr>
+ <td>
+ _PlayerImpl_Tie
+ </td>
+ <td>
+ Generate with rmic, command line rmic -iiop -poa -keep
+ gnu.classpath.examples.CORBA.swing.x5.PlayerImpl (the compiled
+ package must be present in the current folder).
+ </td>
+ </tr>
+ <tr>
+ <td>
+ ChatConstants
+ </td>
+ <td>
+ The chat color code constants, used to indicate who is talking.
+ </td>
+ </tr>
+ <tr>
+ <td>
+ ClientFrame
+ </td>
+ <td>
+ The JFrame of the GUI client.
+ </td>
+ </tr>
+ <tr>
+ <td>
+ GameManagerImpl
+ </td>
+ <td>
+ The manager connects two players into the game.
+ </td>
+ </tr>
+ <tr>
+ <td>
+ IorReader
+ </td>
+ <td>
+ Reads the remote URL.
+ </td>
+ </tr>
+ <tr>
+ <td>
+ OrbStarter
+ </td>
+ <td>
+ Starts the ORBs, involved into this application.
+ </td>
+ </tr>
+ <tr>
+ <td>
+ PlayerImpl
+ </td>
+ <td>
+ The implementation of the PlayerCommunicator, providing the
+ local functionality.
+ </td>
+ </tr>
+ <tr>
+ <td>
+ PlayingDesk
+ </td>
+ <td>
+ Manages actions, related to the game rules and also does all
+ painting.
+ </td>
+ </tr>
+</table>
+<h3>See also
+</h3>
+<p>
+ <a HREF="http://www.javascripter.net/games/xo/xo.htm">http://www.javascripter.net/games/xo/xo.htm
+ </a>
+</p>
+<p>
+ <a HREF="http://www.leepoint.net/notes-java/45examples/55games/five/five.html">http://www.leepoint.net/notes-java/45examples/55games/five/five.html
+ </a>
+</p>
+<p>Copyright
+</p>
+<p>
+ <font COLOR="#b3b3b3">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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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.
+ </font>
+</p>
+<p>
+ <br>
+ <br>
+</p>
+<p>
+First version written by <a href="http://savannah.gnu.org/users/audriusa">
+Audrius Me&scaron;kauskas</a>
+</p>
+</body>
+</html>
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/CanvasWorld.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/CanvasWorld.java
new file mode 100644
index 000000000..9e1a70fcc
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/CanvasWorld.java
@@ -0,0 +1,307 @@
+/* CanvasWorld.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., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 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.swing.x5;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Point;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+import javax.swing.JComponent;
+import javax.swing.JFrame;
+import javax.swing.JScrollPane;
+
+/**
+ * The purpose of this simple example is to check if the mouse events are
+ * correctly received in a scrollable canvas and also if the canvas are
+ * correctly repainted. The similar canvas are used in various games and
+ * interactive demonstrations.
+ *
+ * The user can set one of the three possible figures with the different
+ * mouse buttons. The figure must be set where the user have clicked the
+ * mouse.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class CanvasWorld
+ extends JComponent
+ implements MouseListener, State
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
+ * Red oval, set by the left mouse button.
+ */
+ public static final int RED = 0;
+
+ /**
+ * Black cross, set by the right mouse button.
+ */
+ public static final int BLACK = 1;
+
+ /**
+ * Blue and smaller oval, set by the middle mouse button.
+ */
+ public static final int HINT = 2;
+
+ /**
+ * The message string is displayed at the top of the window.
+ */
+ String message = "Click left, right or middle button in to set the figure";
+
+ /**
+ * The additinal message, related to the mouse events.
+ */
+ String mouse = "No mouse event so far";
+
+ /**
+ * The grid spacing.
+ */
+ static int W = 16;
+
+ /**
+ * The radius of the dots being painted.
+ */
+ static int R = W / 3;
+
+ /**
+ * The collection of the red dots.
+ */
+ ArrayList reds = new ArrayList();
+
+ /**
+ * The collection of the black crosses.
+ */
+ ArrayList blacks = new ArrayList();
+
+ /**
+ * The collection of the smaller blue crosses.
+ */
+ ArrayList hints = new ArrayList();
+
+ public CanvasWorld()
+ {
+ try
+ {
+ addMouseListener(this);
+ }
+ catch (Exception e)
+ {
+ throw new AssertionError(e);
+ }
+ }
+
+ /**
+ * Paint this component.
+ */
+ public void paintComponent(Graphics g)
+ {
+ int w = getWidth();
+ int h = getHeight();
+
+ g.setColor(Color.white);
+ g.fillRect(0, 0, w, h);
+
+ drawGrid(w, h, g);
+
+ g.setColor(Color.black);
+
+ g.drawString(message, W, W);
+ g.drawString(mouse, W, 2*W);
+
+ drawFigures(g);
+ }
+
+ /**
+ * Check for the presence of the given point in the collection.
+ */
+ public final boolean pointPresent(int x, int y, Collection in)
+ {
+ Iterator iter = in.iterator();
+ Point p;
+ while (iter.hasNext())
+ {
+ p = (Point) iter.next();
+ if (p.x == x && p.y == y)
+ return true;
+ }
+ return false;
+ }
+
+ public void drawGrid(int w, int h, Graphics g)
+ {
+ g.setColor(Color.lightGray);
+
+ int xs = 2*W+W/2;
+
+ // Draw vertical lines:
+ for (int x = 0; x < w; x += W)
+ {
+ g.drawLine(x, xs, x, h);
+ }
+
+ // Draw horizontal lines:
+ for (int y = 3*W; y < h; y += W)
+ {
+ g.drawLine(0, y, w, y);
+ }
+
+ g.setColor(Color.gray);
+ }
+
+ public void drawFigures(Graphics g)
+ {
+ g.setColor(Color.red);
+ drawDots(reds, g, RED);
+
+ g.setColor(Color.black);
+ drawDots(blacks, g, BLACK);
+
+ g.setColor(Color.blue);
+ drawDots(hints, g, HINT);
+ }
+
+ public Point makePoint(int x, int y)
+ {
+ return new Point(x / W, y / W);
+ }
+
+ /**
+ * Draw a collection of dots (the collor must be set before calling the
+ * method).
+ */
+ public void drawDots(Collection dots, Graphics g, int mode)
+ {
+ Iterator iter = dots.iterator();
+ int x;
+ int y;
+
+ int hW = W / 2;
+ int RR = R * 2;
+ int hR = R / 2;
+ Point p;
+ while (iter.hasNext())
+ {
+ p = (Point) iter.next();
+ x = p.x * W + hW;
+ y = p.y * W + hW;
+
+ if (mode == RED)
+ g.drawOval(x - R, y - R, RR, RR);
+ else if (mode == BLACK)
+ {
+ g.drawLine(x - R, y - R, x + R, y + R);
+ g.drawLine(x - R, y + R, x + R, y - R);
+ }
+ else
+ {
+ // Hint.
+ g.drawOval(x - hR, y - hR, R, R);
+ }
+ }
+ }
+
+ public void mouseClicked(MouseEvent e)
+ {
+ int x = e.getX();
+ int y = e.getY();
+
+ Point p = makePoint(x, y);
+
+ // Ignore clicks on the occupied cells.
+ if (pointPresent(p.x, p.y, reds) || (pointPresent(p.x, p.y, blacks)))
+ {
+ message = "Clicked on the occupied cell.";
+ return;
+ }
+ else
+ message = "Figure set at ["+p.x+","+p.y+"]";
+
+ if (e.getButton() == MouseEvent.BUTTON1)
+ reds.add(p);
+ else if (e.getButton() == MouseEvent.BUTTON3)
+ blacks.add(p);
+ else if (e.getButton() == MouseEvent.BUTTON2)
+ hints.add(p);
+ repaint();
+ }
+
+ public void mouseEntered(MouseEvent m)
+ {
+ mouse = "Mouse entered.";
+ repaint();
+ }
+
+ public void mousePressed(MouseEvent m)
+ {
+ mouse = "Mouse pressed at "+m.getX()+","+m.getY();
+ repaint();
+ }
+
+ public void mouseReleased(MouseEvent m)
+ {
+ mouse = "Mouse released at "+m.getX()+","+m.getY();
+ repaint();
+ }
+
+ public void mouseExited(MouseEvent m)
+ {
+ mouse = "Mouse exited";
+ repaint();
+ }
+
+ public static void main(String[] args)
+ {
+ JFrame frame = new JFrame();
+ CanvasWorld world = new CanvasWorld();
+ world.setPreferredSize(new Dimension(1000,1000));
+ frame.add(new JScrollPane(world));
+ frame.setSize(400, 200);
+ frame.setVisible(true);
+ }
+
+} \ No newline at end of file
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/ChatConstants.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/ChatConstants.java
new file mode 100644
index 000000000..b0552b439
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/ChatConstants.java
@@ -0,0 +1,80 @@
+/* ChatConstants.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., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 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.swing.x5;
+
+import java.awt.Color;
+
+/**
+ * The chat color code constants, used to indicate who is talking.
+ * Additionally, the red color is reseved for the most important messages,
+ * related to the start and end of the game.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class ChatConstants
+{
+ /**
+ * Messages from the local system.
+ */
+ public static byte SYSTEM = 0;
+
+ /**
+ * Mirrored messsages from the local player.
+ */
+ public static byte SELF = 1;
+
+ /**
+ * Messages from the remote player.
+ */
+ public static byte REMOTE_PLAYER = 2;
+
+ /**
+ * Messages from the game server/
+ */
+ public static byte GAME_SERVER = 3;
+
+ /**
+ * The array of the used colors.
+ */
+ public static Color[] colors =
+ new Color[]
+ {
+ Color.black, new Color(0, 80, 0), new Color(0, 0, 128), Color.blue
+ };
+} \ No newline at end of file
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/ClientFrame.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/ClientFrame.java
new file mode 100644
index 000000000..c3d8300b7
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/ClientFrame.java
@@ -0,0 +1,417 @@
+/* ClientFrame.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., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 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.swing.x5;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.GridLayout;
+import java.awt.event.*;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+
+import java.rmi.RemoteException;
+
+import javax.rmi.PortableRemoteObject;
+
+import javax.swing.*;
+import java.awt.Dimension;
+
+/**
+ * The JFrame of the GUI client.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class ClientFrame
+ extends JFrame
+{
+ /**
+ * The size of the playing field.
+ */
+ public final Dimension DESK_SIZE =
+ new Dimension(624, 352-PlayingDesk.W);
+
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ // Define the application components:
+
+ /**
+ * Central panel where the main action takes place.
+ */
+ PlayingDesk desk = new PlayingDesk();
+
+ /**
+ * The scroll pane for canvas.
+ */
+ JScrollPane scroll = new JScrollPane();
+
+ /**
+ * Will remember the manager IOR.
+ */
+ String mior = "";
+
+ // The bottom panel contains the area that is used both to enter URL and
+ // for chatting.
+ JPanel pnBottom = new JPanel();
+
+ BorderLayout layBottom = new BorderLayout();
+
+ JTextField taUrl = new JTextField();
+
+ // The top primitive chatting panel, composed from labels.
+ JPanel pnChat = new JPanel();
+
+ GridLayout layChat = new GridLayout();
+
+ JLabel lbC3 = new JLabel();
+
+ JLabel lbC2 = new JLabel();
+
+ JLabel lbC1 = new JLabel();
+
+ // The button panel.
+ JPanel pnButtons = new JPanel();
+
+ GridLayout layButtons = new GridLayout();
+
+ JButton bLeave = new JButton();
+
+ JButton bConnect = new JButton();
+
+ JButton bExit = new JButton();
+
+ JButton bReset = new JButton();
+
+ JLabel lbState = new JLabel();
+
+ JButton bChat = new JButton();
+
+ JButton bPaste = new JButton();
+
+ public ClientFrame()
+ {
+ try
+ {
+ jbInit();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ private void jbInit()
+ throws Exception
+ {
+ desk.frame = this;
+
+ pnBottom.setLayout(layBottom);
+
+ pnChat.setLayout(layChat);
+ layChat.setColumns(1);
+ layChat.setRows(3);
+
+ lbC1.setText("This program needs the game server (see README on how to start it).");
+ lbC2.setText("Enter the game server address (host:port)");
+ lbC3.setText("Pressing \'Connect\' with the empty address will start the server on "
+ + "the local machine.");
+ bLeave.setEnabled(true);
+ bLeave.setToolTipText("Leave if either you have lost or do not want longer to play with "
+ + "this partner.");
+ bLeave.setText("Leave game");
+ bLeave.addActionListener(new java.awt.event.ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ bLeave_actionPerformed(e);
+ }
+ });
+ bConnect.setToolTipText("Connect your playing partner");
+ bConnect.setText("Connect");
+ bConnect.addActionListener(new java.awt.event.ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ bConnect_actionPerformed(e);
+ }
+ });
+ pnButtons.setLayout(layButtons);
+ bExit.setToolTipText("Exit this program");
+ bExit.setText("Exit");
+ bExit.addActionListener(new java.awt.event.ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ bExit_actionPerformed(e);
+ }
+ });
+ layButtons.setHgap(2);
+ bReset.setToolTipText("Restart the game. The partner may choose to exit!");
+ bReset.setText("Reset game");
+ bReset.addActionListener(new java.awt.event.ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ bReset_actionPerformed(e);
+ }
+ });
+ lbState.setText("Disconnected");
+ bChat.setToolTipText("Send message to player. Reuse the address "+
+ "field to enter the message.");
+ bChat.setText("Chat");
+ bChat.addActionListener(new java.awt.event.ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ bChat_actionPerformed(e);
+ }
+ });
+
+ bPaste.setText("Paste");
+ bPaste.setToolTipText("Paste, same as Ctrl-V");
+ bPaste.addActionListener(new java.awt.event.ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ bPaste_actionPerformed(e);
+ }
+ });
+
+ desk.setMaximumSize(DESK_SIZE);
+ desk.setPreferredSize(DESK_SIZE);
+
+ scroll.getViewport().add(desk, null);
+ getContentPane().add(scroll, BorderLayout.CENTER);
+ getContentPane().add(pnBottom, BorderLayout.SOUTH);
+
+ pnBottom.add(taUrl, BorderLayout.CENTER);
+ pnBottom.add(pnChat, BorderLayout.NORTH);
+
+ pnChat.add(lbC1, null);
+ pnChat.add(lbC2, null);
+ pnChat.add(lbC3, null);
+ pnBottom.add(pnButtons, BorderLayout.SOUTH);
+ pnButtons.add(lbState, null);
+ pnButtons.add(bConnect, null);
+ pnButtons.add(bChat, null);
+ pnButtons.add(bLeave, null);
+ pnButtons.add(bReset, null);
+ pnButtons.add(bExit, null);
+ pnButtons.add(bPaste, null);
+
+ desk.player.set_current_state(State.DISCONNECTED);
+ }
+
+ /**
+ * Handles exit procedure.
+ */
+ protected void processWindowEvent(WindowEvent e)
+ {
+ super.processWindowEvent(e);
+ if (e.getID() == WindowEvent.WINDOW_CLOSING)
+ {
+ bExit_actionPerformed(null);
+ }
+ }
+
+ /**
+ * Handles the connection procedure.
+ */
+ void bConnect_actionPerformed(ActionEvent e)
+ {
+ try
+ {
+ int state = desk.player.get_current_state();
+
+ if (state == State.DISCONNECTED || state == State.ERROR)
+ {
+ talk(ChatConstants.colors[0], "Connecting...");
+
+ if (desk.manager == null)
+ {
+ mior = taUrl.getText().trim();
+
+ // Obtain the manager object:
+ org.omg.CORBA.Object object = null;
+
+ try
+ {
+ object = desk.orb.string_to_object(mior);
+ }
+ catch (Exception exc)
+ {
+ // Maybe CORBA 3.0.3 is not completely implemented?
+ if (mior.startsWith("http://") || mior.startsWith("ftp://")
+ || mior.startsWith("file://"))
+ object = desk.orb.string_to_object(IorReader.readUrl(mior));
+ else
+ throw exc;
+ }
+
+ desk.manager = (GameManager) PortableRemoteObject.narrow(
+ object, GameManager.class);
+
+ // Export the desk.player as a remote object.
+ PortableRemoteObject.exportObject(desk.player);
+ }
+
+ desk.player.set_current_state(State.QUEUED);
+ desk.manager.requestTheGame(desk.player);
+ }
+
+ // Save the specified IOR for the future use:
+ File gmf = new File(OrbStarter.WRITE_URL_TO_FILE);
+ FileWriter f = new FileWriter(gmf);
+ BufferedWriter b = new BufferedWriter(f);
+
+ b.write(mior);
+ b.close();
+ }
+ catch (Exception ex)
+ {
+ talk(Color.red, "The manager is not reachable by this address.");
+ talk(Color.red, ex.getMessage());
+ desk.player.set_current_state(State.DISCONNECTED);
+ }
+ }
+
+ /**
+ * Display the new message with the given color. Shift the other messages over
+ * the labels.
+ */
+ public void talk(Color color, String text)
+ {
+ lbC1.setText(lbC2.getText());
+ lbC1.setForeground(lbC2.getForeground());
+
+ lbC2.setText(lbC3.getText());
+ lbC2.setForeground(lbC3.getForeground());
+
+ lbC3.setText(text);
+ lbC3.setForeground(color);
+ }
+
+ /**
+ * Exit this program.
+ */
+ void bExit_actionPerformed(ActionEvent e)
+ {
+ try
+ {
+ if (desk.player.get_current_state() != State.DISCONNECTED
+ && desk.player.partner != null)
+ {
+ desk.player.partner.receive_chat(ChatConstants.REMOTE_PLAYER,
+ "I close the program!");
+ desk.player.partner.disconnect();
+ }
+ }
+ catch (RemoteException ex)
+ {
+ // We will print the exception because this is a demo application that
+ // may be modified for learning purposes.
+ ex.printStackTrace();
+ }
+ System.exit(0);
+ }
+
+ void bReset_actionPerformed(ActionEvent e)
+ {
+ if (desk.player.partner != null)
+ {
+ try
+ {
+ desk.player.partner.receive_chat(ChatConstants.REMOTE_PLAYER,
+ "Your partner restarted the game.");
+
+ desk.player.start_game(desk.player.partner, false);
+ desk.player.partner.start_game(desk.player, true);
+ }
+ catch (RemoteException ex)
+ {
+ // We will print the exception because this is a demo application
+ // that
+ // may be modified for learning purposes.
+ ex.printStackTrace();
+ }
+ }
+ else
+ talk(Color.black, "You have not started the game yet.");
+ }
+
+ void bLeave_actionPerformed(ActionEvent e)
+ {
+ desk.player.leave();
+ }
+
+ void bChat_actionPerformed(ActionEvent e)
+ {
+ try
+ {
+ if (desk.player.partner != null)
+ {
+ String message = taUrl.getText();
+ desk.player.partner.receive_chat(ChatConstants.REMOTE_PLAYER, message);
+ talk(ChatConstants.colors[ChatConstants.SELF], message);
+ taUrl.setText("");
+ }
+ else
+ {
+ talk(Color.black, "Sorry, not connected to anybody");
+ }
+ }
+ catch (RemoteException ex)
+ {
+ // We will print the exception because this is a demo application that
+ // may be modified for learning purposes.
+ ex.printStackTrace();
+ }
+ }
+
+ /**
+ * Work around our keyboard shortcut handling that is still not working
+ * properly.
+ */
+ void bPaste_actionPerformed(ActionEvent e)
+ {
+ taUrl.paste();
+ }
+} \ No newline at end of file
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/Demo.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/Demo.java
new file mode 100644
index 000000000..b83217896
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/Demo.java
@@ -0,0 +1,99 @@
+/* Demo.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., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 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.swing.x5;
+
+import java.awt.Dimension;
+import java.awt.Toolkit;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+
+/**
+ * The main executable class of the game client.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class Demo
+{
+
+ public static void main(String[] args)
+ {
+ ClientFrame frame = new ClientFrame();
+ frame.setSize(new Dimension(640, 480));
+ frame.setTitle("Make vertical, horizontal or diagonal line of 5 dots. "
+ + "Click mouse to set the dot.");
+ frame.validate();
+
+ // Center the window
+ Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
+ Dimension frameSize = frame.getSize();
+ if (frameSize.height > screenSize.height)
+ {
+ frameSize.height = screenSize.height;
+ }
+ if (frameSize.width > screenSize.width)
+ {
+ frameSize.width = screenSize.width;
+ }
+ frame.setLocation((screenSize.width - frameSize.width) / 2,
+ (screenSize.height - frameSize.height) / 2);
+ frame.setVisible(true);
+
+ // Set the ior.
+ try
+ {
+ if (OrbStarter.WRITE_URL_TO_FILE != null)
+ {
+ File saved_ior = new File(OrbStarter.WRITE_URL_TO_FILE);
+ if (saved_ior.exists())
+ {
+ FileReader f = new FileReader(saved_ior);
+ String s = new BufferedReader(f).readLine();
+ frame.taUrl.setText(s);
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ // We will print the exception, because this is a demo program -
+ // expected to be modified by user.
+ e.printStackTrace();
+ }
+ }
+} \ No newline at end of file
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/GameManager.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/GameManager.java
new file mode 100644
index 000000000..4d632e8bf
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/GameManager.java
@@ -0,0 +1,68 @@
+/* GameManager.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., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 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.swing.x5;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+/**
+ * The game manager interface.
+ *
+ * Defines the operations of the game server that connects two players into
+ * the game. The game server does not participate in the game itself.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public interface GameManager extends Remote
+{
+ /**
+ * Register the newPlayer as the person who is willing to play. When another
+ * player calls this method, the Manager connects them by calling
+ * {@link PlayerCommunicator#start_game}. The manager provides the partner
+ * and sets (randomly) the starting side.
+ */
+ void requestTheGame(Player newPlayer) throws RemoteException;
+
+ /**
+ * Unregister the player that left and is no longer waiting for a playing
+ * partner to come.
+ * @throws RemoteException
+ */
+ void unregister(Player player) throws RemoteException;
+} \ No newline at end of file
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/GameManagerImpl.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/GameManagerImpl.java
new file mode 100644
index 000000000..fc449bc50
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/GameManagerImpl.java
@@ -0,0 +1,135 @@
+/* GameManagerImpl.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., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 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.swing.x5;
+
+import java.rmi.RemoteException;
+
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.Object;
+
+/**
+ * The manager connects two players into the game.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class GameManagerImpl
+ implements GameManager
+{
+ /**
+ * The game manager IOR.
+ */
+ static String ior;
+
+ /**
+ * The game manager ORB.
+ */
+ static ORB orb;
+
+ /**
+ * True if the manager started ok.
+ */
+ static boolean ok;
+
+ /**
+ * Another player that is already waiting for the game.
+ */
+ Player queuedPlayer = null;
+
+ public synchronized void requestTheGame(Player newPlayer)
+ throws RemoteException
+ {
+ System.out.println("Game requested");
+
+ if (queuedPlayer == null)
+ {
+ // No other player so far.
+ newPlayer.receive_chat(ChatConstants.GAME_SERVER,
+ "Request registered, waiting for the other player to come...");
+ System.out.println("Player queued.");
+ queuedPlayer = newPlayer;
+ }
+ else if (queuedPlayer.equals(newPlayer))
+ {
+ // The same player applies again.
+ newPlayer.receive_chat(ChatConstants.GAME_SERVER,
+ "No other player so far... Please wait.");
+ }
+ else
+ {
+ // As the queued player waited for the game, we allow him/her
+ // to start the game. This is a reward for waiting.
+ newPlayer.receive_chat(ChatConstants.GAME_SERVER,
+ "The other player is waiting. The game started, your "
+ + "partner begins...");
+ queuedPlayer.receive_chat(ChatConstants.GAME_SERVER,
+ "The other player arrived. Lets play, you begin the game now...");
+
+ newPlayer.start_game(queuedPlayer, false);
+ queuedPlayer.start_game(newPlayer, true);
+
+ queuedPlayer = null;
+ System.out.println("Players connected.");
+ }
+ }
+
+ /**
+ * Unregister the player who left and is no longer waiting for another side.
+ */
+ public void unregister(Player player)
+ throws RemoteException
+ {
+ if (queuedPlayer != null)
+ {
+ // We need to verify the identity of the player being unregistered.
+ // The stubs, being derived from the org.omg.CORBA.Object, have the
+ // method for this. This method compares the player host address,
+ // used port and the object key.
+ if (player instanceof Object && queuedPlayer instanceof Object)
+ {
+ Object a = (Object) player;
+ Object b = (Object) queuedPlayer;
+
+ if (a._is_equivalent(b))
+ queuedPlayer = null;
+ }
+ else
+ queuedPlayer = null;
+ }
+ System.out.println("Unregistering player");
+ }
+} \ No newline at end of file
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/IorReader.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/IorReader.java
new file mode 100644
index 000000000..73a8eecab
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/IorReader.java
@@ -0,0 +1,124 @@
+/* IorReader.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., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 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.swing.x5;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.DATA_CONVERSION;
+
+/**
+ * Reads the remote URL. Following formal/04-03-12, CORBA should be able to do
+ * this without the help of this class. However some popular class libraries
+ * are written using the older CORBA specifications and may not handle
+ * functionality, require by this game. This class substitutes the functionality,
+ * ensuring that these implementations will also start and we will be able
+ * to test the interoperability.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class IorReader
+{
+ /**
+ * Read IOR from the remote URL.
+ */
+ public static String readUrl(String url)
+ {
+ URL u;
+ try
+ {
+ u = new URL(url);
+ }
+ catch (MalformedURLException mex)
+ {
+ throw new BAD_PARAM("Malformed URL: '" + url + "'");
+ }
+
+ try
+ {
+ InputStreamReader r = new InputStreamReader(u.openStream());
+
+ StringBuilder b = new StringBuilder();
+ int c;
+
+ while ((c = r.read()) > 0)
+ b.append((char) c);
+
+ return b.toString().trim();
+ }
+ catch (Exception exc)
+ {
+ DATA_CONVERSION d = new DATA_CONVERSION("Reading " + url + " failed.");
+ throw d;
+ }
+ }
+
+ /**
+ * Read IOR from the file in the local file system.
+ */
+ public static String readFile(String file)
+ {
+ File f = new File(file);
+ if (!f.exists())
+ {
+ DATA_CONVERSION err = new DATA_CONVERSION(f.getAbsolutePath()
+ + " does not exist.");
+ throw err;
+ }
+ try
+ {
+ char[] c = new char[(int) f.length()];
+ FileReader fr = new FileReader(f);
+ fr.read(c);
+ fr.close();
+ return new String(c).trim();
+ }
+ catch (IOException ex)
+ {
+ DATA_CONVERSION d = new DATA_CONVERSION();
+ d.initCause(ex);
+ throw (d);
+ }
+ }
+}
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/OrbStarter.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/OrbStarter.java
new file mode 100644
index 000000000..3852945c6
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/OrbStarter.java
@@ -0,0 +1,236 @@
+/* OrbStarter.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., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 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.swing.x5;
+
+import java.rmi.RemoteException;
+import java.util.Properties;
+
+import javax.rmi.PortableRemoteObject;
+import javax.rmi.CORBA.Tie;
+
+import org.omg.CORBA.ORB;
+import org.omg.PortableServer.POA;
+import org.omg.PortableServer.POAHelper;
+import org.omg.PortableServer.Servant;
+
+/**
+ * Starts the ORBs, involved into this application.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class OrbStarter
+{
+ /**
+ * The game manager name server port. This server allows to access the game
+ * manager by host (IP) and port rather than by the rather long IOR string.
+ */
+ static int MANAGER_NAMER_PORT = 1500;
+
+ /**
+ * The used port range (understood and used by GNU Classpath only).
+ */
+ static String USED_PORT_RANGE = "1501-1503";
+
+ /**
+ * Specify the file where under start the game manager writes its IOR.
+ * You may specify the path if the game manager and player clients have
+ * access to some share file system or if you prefer to write IOR to
+ * floppy and then read from the floppy on the client side. Both clients
+ * and server will use this constant. Set to null not to write the IOR.
+ */
+ static String WRITE_URL_TO_FILE = "game_manager_ior.txt";
+
+ /**
+ * Start the manager ORB.
+ * @return the manager URL if it starts.
+ */
+ public static String startManager(final String[] args)
+ {
+ GameManagerImpl.ior = null;
+ GameManagerImpl.ok = false;
+
+ final Properties p = new Properties();
+ p.put("gnu.CORBA.ListenerPort", USED_PORT_RANGE);
+
+ try
+ {
+ new Thread()
+ {
+ public void run()
+ {
+ try
+ {
+ GameManagerImpl.orb = ORB.init(args, p);
+
+ // Obtain the root poa:
+ POA rootPOA = POAHelper.narrow(GameManagerImpl.orb.resolve_initial_references("RootPOA"));
+
+ GameManagerImpl impl = new GameManagerImpl();
+
+ PortableRemoteObject.exportObject(impl);
+
+ // Construct the tie that is also the servant.
+ Tie tie = new _GameManagerImpl_Tie();
+
+ // Set the invocation target for this tie.
+ tie.setTarget(impl);
+
+ // Obtain the reference to the corresponding CORBA object:
+ org.omg.CORBA.Object object = rootPOA.servant_to_reference((Servant) tie);
+
+ GameManagerImpl.ok = true;
+
+ // Activate the root POA.
+ rootPOA.the_POAManager().activate();
+
+ // Get the IOR URL that must be passed to clients.
+ GameManagerImpl.ior = GameManagerImpl.orb.object_to_string(object);
+
+ GameManagerImpl.orb.run();
+ }
+ catch (Exception exc)
+ {
+ exc.printStackTrace();
+ GameManagerImpl.ior = "Unable to start the ORB: " + exc;
+ }
+ }
+ }.start();
+
+ // Wait the thread to enter orb.run.
+ long t = System.currentTimeMillis();
+ while (GameManagerImpl.ior == null
+ && System.currentTimeMillis() - t < 20000)
+ {
+ Thread.sleep(100);
+ }
+
+ return GameManagerImpl.ior;
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ return "Exception: " + e;
+ }
+ }
+
+ /**
+ * Start the client ORB.
+ */
+ public static String startPlayer(final Player player, final PlayingDesk desk)
+ {
+ desk.ior = null;
+ desk.ok = false;
+
+ final Properties p = new Properties();
+ p.put("gnu.CORBA.ListenerPort", USED_PORT_RANGE);
+
+ try
+ {
+ new Thread()
+ {
+ public void run()
+ {
+ try
+ {
+ desk.orb = ORB.init(new String[0], p);
+
+ POA rootPOA = POAHelper.narrow(desk.orb.resolve_initial_references("RootPOA"));
+ rootPOA.the_POAManager().activate();
+
+ // Construct the tie.
+ Tie tie = new _PlayerImpl_Tie();
+
+ // Set the implementing class (invocation target).
+ tie.setTarget(new PlayerImpl());
+
+ // Connect the tie as POA servant.
+ org.omg.CORBA.Object object = rootPOA.servant_to_reference((Servant) tie);
+
+ // Get the stringified reference.
+ desk.ior = desk.orb.object_to_string(object);
+
+ // Mark that the object was created OK.
+ desk.ok = true;
+ desk.orb.run();
+ }
+ catch (Exception exc)
+ {
+ exc.printStackTrace();
+ desk.ior = "Unable to start the ORB: " + exc;
+ }
+ }
+ }.start();
+
+ long t = System.currentTimeMillis();
+ while (desk.ior == null && System.currentTimeMillis() - t < 20000)
+ {
+ Thread.sleep(100);
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ return "Exception: " + e;
+ }
+
+ // Add shutdown hook to unregister from the manager.
+ Runtime.getRuntime().addShutdownHook(new Thread()
+ {
+ public void run()
+ {
+ if (desk.manager != null && player != null)
+ {
+ try
+ {
+ desk.manager.unregister(player);
+ }
+ catch (RemoteException ex)
+ {
+ // We will print the exception because this is a demo
+ // application that
+ // may be modified for learning purposes.
+ ex.printStackTrace();
+ }
+ desk.manager = null;
+ }
+ }
+ });
+ return desk.ior;
+ }
+}
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/Player.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/Player.java
new file mode 100644
index 000000000..ff5624b79
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/Player.java
@@ -0,0 +1,96 @@
+/* Player.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., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 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.swing.x5;
+
+import java.awt.Point;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+/**
+ * Defines remote methods that are invoked by another player or by the
+ * challenge server.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public interface Player extends Remote
+{
+ /**
+ * Receive the invitation to play from the patner or the game manager.
+ *
+ * @param address the address (host and port) of the remote partner.
+ * @param youStart if true, the game manager instructs to start
+ * the game first (another side is instructed to start the game second).
+ *
+ * @return true on success.
+ */
+ boolean start_game(Player otherPlayer, boolean youStart)
+ throws RemoteException;
+
+ /**
+ * Get the state of the local player (one of the constants, defined
+ * in this interface).
+ */
+ int get_current_state() throws RemoteException;
+
+ /**
+ * Receive the chat message from the friend or challenge server (remote).
+ * Possible at any state, always remote.
+ *
+ * @param color the color code, used to highlight the message.
+ * @param text the message text.
+ */
+ void receive_chat(byte color, String test) throws RemoteException;
+
+ /**
+ * Indicated that the remote side leaves the game (capitulating).
+ */
+ void disconnect() throws RemoteException;
+
+ /**
+ * Receive friends move (possible at I_WAIT_FOR_YOUR_MOVE).
+ *
+ * @param x grid position.
+ * @param y grid position.
+ *
+ * @param sessionId the session id, must match (otherwise the call is ignored).
+ * @param victory if not a null, the friend thinks that it has won, the parameter
+ * containing the ends of the builded line.
+ */
+ void receive_move(int x, int y, Point[] victory) throws RemoteException;
+} \ No newline at end of file
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/PlayerImpl.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/PlayerImpl.java
new file mode 100644
index 000000000..c30f7d51a
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/PlayerImpl.java
@@ -0,0 +1,275 @@
+/* PlayerImpl.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., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 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.swing.x5;
+
+import java.awt.Color;
+import java.awt.Point;
+
+import java.rmi.RemoteException;
+
+/**
+ * The implementation of the PlayerCommunicator, providing the local
+ * functionality. Apart remote methods, the class also defines some local
+ * methods, needed for the co-ordinated work with the game user interface.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class PlayerImpl
+ implements Player, State
+{
+ /**
+ * The playing table.
+ */
+ PlayingDesk desk;
+
+ /**
+ * The state of this player (one of the constants, defined in the player
+ * interface.
+ */
+ private int state = DISCONNECTED;
+
+ /**
+ * The other player.
+ */
+ Player partner;
+
+ /**
+ * Called when the local player refuses to continue the game.
+ */
+ public void leave()
+ {
+ try
+ {
+ if (state == I_THINK || state == I_WAIT_FOR_YOUR_MOVE)
+ {
+ partner.receive_chat(ChatConstants.REMOTE_PLAYER,
+ "Your partner has left the game.");
+ partner.disconnect();
+ }
+ else if (state == State.QUEUED)
+ {
+ if (desk.manager != null)
+ desk.manager.unregister(desk.player);
+ receive_chat(ChatConstants.SYSTEM,
+ "Do not be so pessimistic, try to play first!");
+ }
+ set_current_state(State.DISCONNECTED);
+
+ desk.frame.bChat.setEnabled(false);
+ desk.frame.bLeave.setEnabled(false);
+ desk.frame.bConnect.setEnabled(true);
+ desk.frame.taUrl.setText(desk.frame.mior);
+ }
+ catch (RemoteException ex)
+ {
+ // We will print the exception because this is a demo application that
+ // may be modified for learning purposes.
+ ex.printStackTrace();
+ }
+ }
+
+ /**
+ * Called when we make the move. The PlayingTable is responsible for checking
+ * the correctness of the move and detecting the victory.
+ *
+ * @param x x position of the new dot.
+ * @param y y position of the new dot.
+ *
+ * @param victory array of two memebers, representing the endpoints of the
+ * drawn line (victory detected) or null if no such yet exists.
+ */
+ public void we_move(int x, int y, Point[] victory)
+ {
+ try
+ {
+ set_current_state(I_WAIT_FOR_YOUR_MOVE);
+ partner.receive_move(x, y, victory);
+ }
+ catch (RemoteException ex)
+ {
+ // We will print the exception because this is a demo application that
+ // may be modified for learning purposes.
+ ex.printStackTrace();
+
+ state = ERROR;
+ }
+ }
+
+ /**
+ * Set the current state.
+ */
+ public void set_current_state(int new_state)
+ {
+ state = new_state;
+
+ if (state == DISCONNECTED)
+ {
+ setStatus("Disconnected");
+ }
+ else if (state == I_THINK)
+ {
+ setStatus("Our move");
+ }
+ else if (state == I_WAIT_FOR_YOUR_MOVE)
+ {
+ setStatus("Partner's move");
+ }
+ else if (state == ERROR)
+ {
+ setStatus("Error.");
+ }
+ else if (state == I_HAVE_LOST)
+ {
+ setStatus("We lost");
+ }
+ else if (state == I_HAVE_WON)
+ {
+ setStatus("Victory");
+ }
+ else if (state == QUEUED)
+ {
+ setStatus("Queued");
+ }
+ else
+ {
+ setStatus("State " + state);
+ }
+
+ boolean connected = state != State.DISCONNECTED;
+
+ desk.frame.bConnect.setEnabled(!connected && state != State.QUEUED);
+ desk.frame.bReset.setEnabled(connected);
+ desk.frame.bLeave.setEnabled(connected);
+ desk.frame.bChat.setEnabled(connected);
+ }
+
+ /**
+ * Show the state in the status line.
+ */
+ public void setStatus(String status)
+ {
+ desk.frame.lbState.setText(status);
+ }
+
+ /**
+ * Receive the invitation to play from the patner or the game manager.
+ *
+ * @param address the address (host and port) of the remote partner.
+ * @param youStart if true, the game manager instructs to start the game first
+ * (another side is instructed to start the game second).
+ *
+ * Game server may also chat a little bit with both players, saying that the
+ * game has started.
+ *
+ * @return true on success.
+ */
+ public boolean start_game(Player otherPlayer, boolean youStart)
+ throws RemoteException
+ {
+ partner = otherPlayer;
+ desk.reset();
+
+ if (youStart)
+ {
+ set_current_state(I_THINK);
+ }
+ else
+ {
+ set_current_state(I_WAIT_FOR_YOUR_MOVE);
+ }
+
+ desk.frame.taUrl.setText("");
+
+ return true;
+ }
+
+ /**
+ * Get the state of the local player (one of the constants, defined in this
+ * interface).
+ */
+ public int get_current_state()
+ throws RemoteException
+ {
+ return state;
+ }
+
+ /**
+ * Receive the chat message from the friend or challenge server (remote).
+ * Possible at any state, always remote.
+ *
+ * @param color the color code, used to highlight the message.
+ * @param text the message text.
+ */
+ public void receive_chat(byte color, String text)
+ throws RemoteException
+ {
+ if (color >= ChatConstants.colors.length)
+ color = ChatConstants.REMOTE_PLAYER;
+
+ desk.frame.talk(ChatConstants.colors[color], text);
+ }
+
+ /**
+ * Indicated that the remote side leaves the game (capitulating).
+ */
+ public void disconnect()
+ throws RemoteException
+ {
+ desk.frame.talk(Color.red, "The partner leaves the game.");
+ partner = null;
+ set_current_state(DISCONNECTED);
+
+ desk.frame.taUrl.setText(desk.frame.mior);
+ }
+
+ /**
+ * Receive friends move (possible at I_WAIT_FOR_YOUR_MOVE).
+ *
+ * @param x grid position.
+ * @param y grid position.
+ * @param victory if not a null, the friend thinks that it has won, the
+ * parameter containing the ends of the builded line.
+ */
+ public void receive_move(int x, int y, Point[] victory)
+ throws RemoteException
+ {
+ // The state changes are handled by the PlayingTable
+ desk.friendsMove(x, y, victory);
+ }
+} \ No newline at end of file
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/PlayingDesk.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/PlayingDesk.java
new file mode 100644
index 000000000..fa8966f26
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/PlayingDesk.java
@@ -0,0 +1,512 @@
+/* PlayingDesk.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., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 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.swing.x5;
+
+import java.awt.Color;
+import java.awt.Graphics;
+import java.awt.Point;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.rmi.RemoteException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+import javax.swing.JComponent;
+
+import org.omg.CORBA.ORB;
+
+/**
+ * Manages actions, related to the game rules and also does all painting.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class PlayingDesk
+ extends JComponent
+ implements MouseListener, State
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
+ * Indicates that the field point state is the red oval.
+ */
+ public static final int RED = 0;
+
+ /**
+ * Indicates that the field point state is the black cross.
+ */
+ public static final int BLACK = 1;
+
+ /**
+ * Indicates that the field point state is the hint, suggested by the fan.
+ */
+ public static final int HINT = 2;
+
+ /**
+ * The access to the main frame methods.
+ */
+ ClientFrame frame;
+
+ /**
+ * The access to the player communicator.
+ */
+ PlayerImpl player;
+
+ /**
+ * The game manager.
+ */
+ GameManager manager;
+
+ /**
+ * The player ORB.
+ */
+ ORB orb;
+
+ /**
+ * The player IOR.
+ */
+ String ior;
+
+ /**
+ * True if the player ORB started ok.
+ */
+ boolean ok;
+
+ /**
+ * The grid spacing.
+ */
+ static int W = 16;
+
+ /**
+ * The radius of the dots being painted.
+ */
+ static int R = W / 3;
+
+ /**
+ * The collection of the red dots.
+ */
+ ArrayList reds = new ArrayList();
+
+ /**
+ * The collection of the black dots.
+ */
+ ArrayList blacks = new ArrayList();
+
+ /**
+ * The array of hints.
+ */
+ ArrayList hints = new ArrayList();
+
+ /**
+ * When the game is completed, obtains the value of the two end points of the
+ * created line.
+ */
+ Point[] endOfGame;
+
+ public PlayingDesk()
+ {
+ try
+ {
+ player = new PlayerImpl();
+ player.desk = this;
+
+ OrbStarter.startPlayer(player, this);
+
+ jbInit();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Paint this component.
+ */
+ public void paintComponent(Graphics g)
+ {
+ int w = getWidth();
+ int h = getHeight();
+
+ g.setColor(Color.white);
+ g.fillRect(0, 0, w, h);
+
+ drawGrid(w, h, g);
+ drawFigures(g);
+ }
+
+ /**
+ * Check maybe a game is finished after setting the point N
+ */
+ public Point[] checkFinished(Collection x, Point N)
+ {
+ Iterator iter = x.iterator();
+ Point p;
+
+ // The victory, if happens, must occur inside these boundaries:
+ int ax = N.x - 5;
+ int bx = N.x + 5;
+
+ int ay = N.y - 5;
+ int by = N.y + 5;
+
+ while (iter.hasNext())
+ {
+ p = (Point) iter.next();
+
+ if (p.x > ax && p.x < bx && p.y > ay && p.y < by)
+ {
+ // Check the vertical line down
+ if (pointPresent(p.x, p.y + 1, x))
+ if (pointPresent(p.x, p.y + 2, x))
+ if (pointPresent(p.x, p.y + 3, x))
+ if (pointPresent(p.x, p.y + 4, x))
+ return new Point[] { p, new Point(p.x, p.y + 4) };
+
+ // Check the horizontal line left
+ if (pointPresent(p.x + 1, p.y, x))
+ if (pointPresent(p.x + 2, p.y, x))
+ if (pointPresent(p.x + 3, p.y, x))
+ if (pointPresent(p.x + 4, p.y, x))
+ return new Point[] { p, new Point(p.x + 4, p.y) };
+
+ // Check the diagonal line right down.
+ if (pointPresent(p.x + 1, p.y + 1, x))
+ if (pointPresent(p.x + 2, p.y + 2, x))
+ if (pointPresent(p.x + 3, p.y + 3, x))
+ if (pointPresent(p.x + 4, p.y + 4, x))
+ return new Point[] { p, new Point(p.x + 4, p.y + 4) };
+
+ // Check the diagonal line left down.
+ if (pointPresent(p.x - 1, p.y + 1, x))
+ if (pointPresent(p.x - 2, p.y + 2, x))
+ if (pointPresent(p.x - 3, p.y + 3, x))
+ if (pointPresent(p.x - 4, p.y + 4, x))
+ return new Point[] { p, new Point(p.x - 4, p.y + 4) };
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Called when the "end of the game" situation is detected.
+ */
+ public void drawFinishLine(int xa, int ya, int xb, int yb, Graphics g)
+ {
+ g.setColor(Color.blue);
+
+ int hW = W / 2;
+ g.drawLine(xa * W + hW, ya * W + hW, xb * W + hW, yb * W + hW);
+ }
+
+ /**
+ * Check for the presence of the given point in the collection.
+ */
+ public final boolean pointPresent(int x, int y, Collection in)
+ {
+ Iterator iter = in.iterator();
+ Point p;
+ while (iter.hasNext())
+ {
+ p = (Point) iter.next();
+ if (p.x == x && p.y == y)
+ return true;
+ }
+ return false;
+ }
+
+ public void drawGrid(int w, int h, Graphics g)
+ {
+ g.setColor(Color.lightGray);
+
+ // Draw vertical lines:
+ for (int x = 0; x < w; x += W)
+ {
+ g.drawLine(x, 0, x, h);
+ }
+
+ // Draw horizontal lines:
+ for (int y = 0; y < h; y += W)
+ {
+ g.drawLine(0, y, w, y);
+ }
+
+ g.setColor(Color.gray);
+ g.drawRect(0,0, frame.DESK_SIZE.width, frame.DESK_SIZE.height);
+ g.drawRect(0,0, frame.DESK_SIZE.width+3, frame.DESK_SIZE.height+3);
+ }
+
+ public void drawFigures(Graphics g)
+ {
+ g.setColor(Color.red);
+ drawDots(reds, g, RED);
+
+ g.setColor(Color.black);
+ drawDots(blacks, g, BLACK);
+
+ g.setColor(Color.lightGray);
+ drawDots(hints, g, HINT);
+
+ if (endOfGame != null)
+ drawFinishLine(endOfGame[0].x, endOfGame[0].y, endOfGame[1].x,
+ endOfGame[1].y, g);
+ }
+
+ public Point makePoint(int x, int y)
+ {
+ return new Point(x / W, y / W);
+ }
+
+ /**
+ * Draw a collection of dots (the collor must be set before calling the
+ * method).
+ */
+ public void drawDots(Collection dots, Graphics g, int mode)
+ {
+ Iterator iter = dots.iterator();
+ int x;
+ int y;
+
+ int hW = W / 2;
+ int RR = R * 2;
+ int hR = R / 2;
+ Point p;
+ while (iter.hasNext())
+ {
+ p = (Point) iter.next();
+ x = p.x * W + hW;
+ y = p.y * W + hW;
+
+ if (mode == RED)
+ g.drawOval(x - R, y - R, RR, RR);
+ else if (mode == BLACK)
+ {
+ g.drawLine(x - R, y - R, x + R, y + R);
+ g.drawLine(x - R, y + R, x + R, y - R);
+ }
+ else
+ {
+ // Hint.
+ g.drawOval(x - hR, y - hR, R, R);
+ }
+ }
+ }
+
+ private void jbInit()
+ throws Exception
+ {
+ addMouseListener(this);
+ }
+
+ public void mouseClicked(MouseEvent e)
+ {
+ try
+ {
+ int state = player.get_current_state();
+
+ // Check if the state is correct.
+ if (state == I_WAIT_FOR_YOUR_MOVE)
+ {
+ frame.talk(Color.black,
+ "It is now time for our partner's move, not ours. Please wait.");
+ }
+ else if (state == DISCONNECTED)
+ {
+ frame.talk(Color.black,
+ "We are not connected to the playing partner yet.");
+ }
+ else if (state == I_HAVE_LOST)
+ {
+ frame.talk(Color.black,
+ "We have already lost this battle, but why not to try again?");
+ }
+ else if (state == I_HAVE_WON)
+ {
+ frame.talk(Color.black,
+ "The victory is ours, nothing more to do here.");
+ }
+ else if (player.partner == null)
+ frame.talk(Color.black, "No other player so far.");
+ else
+ {
+ int x = e.getX();
+ int y = e.getY();
+
+ if (x>frame.DESK_SIZE.width ||
+ y>frame.DESK_SIZE.height)
+ {
+ frame.talk(Color.black,"Outside the game area.");
+ return;
+ }
+
+ Point p = makePoint(x, y);
+
+ // Ignore clicks on the occupied cells.
+ if (pointPresent(p.x, p.y, reds)
+ || (pointPresent(p.x, p.y, blacks)))
+ {
+ frame.talk(Color.black,
+ "This is against the rules, select the unoccupied cell.");
+ return;
+ }
+
+ reds.add(p);
+
+ endOfGame = checkFinished(reds, p);
+ repaint();
+
+ if (endOfGame != null)
+ {
+ frame.talk(Color.red, "Our move " + p.x + "-" + p.y
+ + " and we win!");
+ player.set_current_state(I_HAVE_WON);
+ }
+ else
+ {
+ frame.talk(Color.black, "Our move " + p.x + "-" + p.y
+ + ". Waiting for the other side move...");
+ player.set_current_state(I_WAIT_FOR_YOUR_MOVE);
+ }
+
+ player.partner.receive_move(p.x, p.y, endOfGame);
+ }
+ }
+ catch (RemoteException ex)
+ {
+ // We will print the exception because this is a demo application
+ // that may be modified for learning purposes.
+ ex.printStackTrace();
+ }
+ }
+
+ /**
+ * Handle the move of the other playing side.
+ */
+ public void friendsMove(int x, int y, Point[] victory)
+ {
+ try
+ {
+ int state = player.get_current_state();
+ if (state != I_WAIT_FOR_YOUR_MOVE || pointPresent(x, y, blacks))
+ {
+ stateFailed("Move " + x + "-" + y);
+ }
+ else
+ {
+ blacks.add(new Point(x, y));
+
+ if (victory != null)
+ {
+ frame.talk(Color.red,
+ " We have lost this time, unfortunately..");
+ player.set_current_state(I_HAVE_LOST);
+ endOfGame = victory;
+ }
+ else
+ {
+ frame.talk(Color.black, "Partner goes " + x + "-" + y
+ + ". Your move?");
+ player.set_current_state(I_THINK);
+ }
+ repaint();
+ }
+ }
+ catch (RemoteException rex)
+ {
+ rex.printStackTrace();
+ }
+ }
+
+ /**
+ * Prepare for the new game.
+ */
+ public void reset()
+ {
+ blacks.clear();
+ reds.clear();
+ hints.clear();
+ endOfGame = null;
+ repaint();
+ }
+
+ public void mouseEntered(MouseEvent m)
+ {
+ // Nothing to do.
+ }
+
+ public void mousePressed(MouseEvent m)
+ {
+ // Nothing to do.
+ }
+
+ public void mouseReleased(MouseEvent m)
+ {
+ // Nothing to do.
+ }
+
+ public void mouseExited(MouseEvent m)
+ {
+ // Nothing to do.
+ }
+
+ /**
+ * The systems detected the error conditions. The game cannot continue (the
+ * chat is still possible).
+ */
+ public void stateFailed(String reason)
+ {
+ try
+ {
+ player.receive_chat(ChatConstants.REMOTE_PLAYER,
+ "Wrong move, game cannot continue (our state was "
+ + player.get_current_state() + ")");
+ frame.talk(Color.red, "The remote side violates communicating rules.");
+ player.set_current_state(State.ERROR);
+ }
+ catch (RemoteException ex)
+ {
+ // We will print the exception because this is a demo application
+ // that may be modified for learning purposes.
+ ex.printStackTrace();
+ }
+ }
+} \ No newline at end of file
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/State.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/State.java
new file mode 100644
index 000000000..7285396cd
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/State.java
@@ -0,0 +1,82 @@
+/* State.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., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 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.swing.x5;
+
+/**
+ * Defines the states in that the player can be.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public interface State {
+ /**
+ * The initial ("disconnected") state.
+ */
+ int DISCONNECTED = 0;
+
+ /**
+ * The state, indicating that the player has been queued for the game and
+ * waiting for the partner to come.
+ */
+ int QUEUED = 1;
+
+ /**
+ * The "my move" state.
+ */
+ int I_THINK = 2;
+
+ /**
+ * The "friend's move" state.
+ */
+ int I_WAIT_FOR_YOUR_MOVE = 3;
+
+ /**
+ * States that we have won.
+ */
+ int I_HAVE_WON = 4;
+
+ /**
+ * States that we have lost.
+ */
+ int I_HAVE_LOST = 5;
+
+ /**
+ * The "inconsistent" state when it is not possible to continue the game.
+ */
+ int ERROR = -1;
+} \ No newline at end of file
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/X5Server.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/X5Server.java
new file mode 100644
index 000000000..771783460
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/X5Server.java
@@ -0,0 +1,175 @@
+/* GameManagerAddressServer.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., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 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.swing.x5;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.InetAddress;
+import java.net.ServerSocket;
+import java.net.Socket;
+
+/**
+ * The main executable class of the game manager server.
+ *
+ * The manager address server returns the IOR address string of the game
+ * manager. Hence the user does not need to enter the rather long IOR address
+ * string and only needs to specify the host and port of the machine where the
+ * game manager is running.
+ *
+ * The manager address server starts the main game manager as well.
+ *
+ * This server acts as a HTTP server that always returns the same response. This
+ * primitive functionality is sufficient for its task.
+ *
+ * The more complex CORBA applications should use the name service instead. We
+ * do not use the name service as this would require to start additional
+ * external application, specific for the different java platforms.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class X5Server
+{
+ /**
+ * Start the game manager.
+ */
+ public static void main(String[] args)
+ {
+ // Start the game manager, write the IOR to the agreed location.
+ OrbStarter.startManager(args);
+
+ if (!GameManagerImpl.ok)
+ {
+ System.out.println("Unable to start the game manager:");
+ System.exit(1);
+ }
+
+ // Print the IOR.
+ System.out.println(GameManagerImpl.ior);
+
+ String manager_address = null;
+
+ // Start the game manager server.
+ ServerSocket nameServer = null;
+ try
+ {
+ nameServer = new ServerSocket(OrbStarter.MANAGER_NAMER_PORT);
+
+ System.out.println("The game manager is listening at:");
+ manager_address = "http://"
+ + InetAddress.getLocalHost().getHostAddress() + ":"
+ + nameServer.getLocalPort();
+
+ System.out.println(manager_address);
+
+ System.out.println("Enter this address to the "
+ + "input field of the game client.");
+
+ System.out.println("Use ^C to stop the manager.");
+ }
+ catch (Exception ex)
+ {
+ System.out.println("The port " + OrbStarter.MANAGER_NAMER_PORT
+ + " is not available. The game manager namer will not start.");
+ System.exit(1);
+ }
+
+ // Write the IOR to the local file system.
+ if (OrbStarter.WRITE_URL_TO_FILE != null)
+ {
+ try
+ {
+ File gmf = new File(OrbStarter.WRITE_URL_TO_FILE);
+ FileWriter f = new FileWriter(gmf);
+ BufferedWriter b = new BufferedWriter(f);
+
+ b.write(manager_address);
+ b.close();
+ }
+ catch (IOException e)
+ {
+ System.out.println("Local filesystem not accessible."
+ + "Read IOR from console.");
+ }
+ }
+
+ // Do forever.
+ while (true)
+ {
+ try
+ {
+ Socket socket = nameServer.accept();
+
+ System.out.println("Connected.");
+
+ // Set the two minutes timeout.
+ socket.setSoTimeout(1000 * 120);
+
+ OutputStream out = socket.getOutputStream();
+
+ int length = GameManagerImpl.ior.length();
+
+ StringBuilder b = new StringBuilder();
+ b.append("HTTP/1.0 200 OK\r\n");
+ b.append("Content-Length: " + length + "\r\n");
+ b.append("Connection: close\r\n");
+ b.append("Content-Type: text/plain; charset=UTF-8\r\n");
+ b.append("\r\n");
+
+ b.append(GameManagerImpl.ior);
+
+ out.write(b.toString().getBytes("UTF-8"));
+
+ socket.shutdownOutput();
+
+ if (!socket.isClosed())
+ socket.close();
+
+ System.out.println("Completed.");
+ }
+ catch (Exception exc)
+ {
+ exc.printStackTrace();
+ System.out.println("Network problem.");
+ }
+ }
+ }
+}
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/_GameManagerImpl_Tie.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/_GameManagerImpl_Tie.java
new file mode 100644
index 000000000..a0c33df34
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/_GameManagerImpl_Tie.java
@@ -0,0 +1,209 @@
+/* _GameManagerImpl_Tie.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., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 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.swing.x5;
+
+import java.rmi.Remote;
+
+import javax.rmi.PortableRemoteObject;
+import javax.rmi.CORBA.Tie;
+
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.SystemException;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.ResponseHandler;
+import org.omg.CORBA.portable.UnknownException;
+import org.omg.PortableServer.Servant;
+
+/**
+ * Normally generated with rmic compiler, this class represents the GameManager
+ * Tie on the client side. The Game Manager methods contain the code for remote
+ * invocation.
+ *
+ * This class is normally generated with rmic or grmic from the
+ * {@link GameManagerImpl}. See tools/gnu/classpath/tools/giop/README.
+ *
+ * In this example the class was manually edited and commented for better
+ * understanding of functionality.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class _GameManagerImpl_Tie
+ extends Servant
+ implements Tie
+{
+ /**
+ * The target, where remote invocations are forwarded.
+ */
+ private GameManagerImpl target = null;
+
+ /**
+ * The GameManager repository Id.
+ */
+ private static final String[] _type_ids =
+ { "RMI:gnu.classpath.examples.CORBA.swing.x5.GameManager:0000000000000000" };
+
+ /**
+ * Set the target where the remote invocations are forwarded.
+ */
+ public void setTarget(Remote a_target)
+ {
+ this.target = (GameManagerImpl) a_target;
+ }
+
+ /**
+ * Get the target where the remote invocations are forwarded.
+ */
+ public Remote getTarget()
+ {
+ return target;
+ }
+
+ /**
+ * Get the CORBA object for that this Tie is currently serving the request.
+ * The same tie may serve multiple requests for the different objects in
+ * parallel threads.
+ */
+ public org.omg.CORBA.Object thisObject()
+ {
+ return _this_object();
+ }
+
+ /**
+ * Deactivate this object.
+ */
+ public void deactivate()
+ {
+ try
+ {
+ _poa().deactivate_object(_poa().servant_to_id(this));
+ }
+ catch (org.omg.PortableServer.POAPackage.WrongPolicy exception)
+ {
+ }
+ catch (org.omg.PortableServer.POAPackage.ObjectNotActive exception)
+ {
+ }
+ catch (org.omg.PortableServer.POAPackage.ServantNotActive exception)
+ {
+ }
+ }
+
+ /**
+ * Get the ORB for this tie.
+ */
+ public ORB orb()
+ {
+ return _orb();
+ }
+
+ /**
+ * Set the ORB for this tie.
+ */
+ public void orb(ORB orb)
+ {
+ try
+ {
+ ((org.omg.CORBA_2_3.ORB) orb).set_delegate(this);
+ }
+ catch (ClassCastException e)
+ {
+ throw new org.omg.CORBA.BAD_PARAM(
+ "POA Servant requires an instance of org.omg.CORBA_2_3.ORB");
+ }
+ }
+
+ /**
+ * Return all interfaces, supported by this method.
+ */
+ public String[] _all_interfaces(org.omg.PortableServer.POA poa,
+ byte[] objectId)
+ {
+ return _type_ids;
+ }
+
+ /**
+ * This method is invoked by CORBA system to handle the remote invocation.
+ *
+ * @param method the name of the method being invoked.
+ * @param _in the stream to read the method parameters.
+ * @param reply the responsed handler that can create the output stream to
+ * write the parameters being returned.
+ */
+ public OutputStream _invoke(String method, InputStream _in,
+ ResponseHandler reply)
+ throws SystemException
+ {
+ try
+ {
+ org.omg.CORBA_2_3.portable.InputStream in =
+ (org.omg.CORBA_2_3.portable.InputStream) _in;
+ if (method.equals("requestTheGame"))
+ {
+ Player p = (Player) PortableRemoteObject.narrow(
+ in.read_Object(), Player.class);
+ target.requestTheGame(p);
+
+ OutputStream out = reply.createReply();
+ return out;
+ }
+ else if (method.equals("unregister"))
+ {
+ Player p = (Player) PortableRemoteObject.narrow(
+ in.read_Object(), Player.class);
+ target.unregister(p);
+
+ OutputStream out = reply.createReply();
+ return out;
+ }
+ else
+ throw new BAD_OPERATION();
+ }
+ catch (SystemException ex)
+ {
+ throw ex;
+ }
+ catch (Throwable ex)
+ {
+ ex.printStackTrace();
+ throw new UnknownException(ex);
+ }
+ }
+} \ No newline at end of file
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/_GameManager_Stub.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/_GameManager_Stub.java
new file mode 100644
index 000000000..e9279963a
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/_GameManager_Stub.java
@@ -0,0 +1,207 @@
+/* _GameManager_Stub.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., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 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.swing.x5;
+
+import java.rmi.RemoteException;
+import java.rmi.UnexpectedException;
+
+import javax.rmi.CORBA.Stub;
+import javax.rmi.CORBA.Util;
+
+import org.omg.CORBA.SystemException;
+import org.omg.CORBA.portable.ApplicationException;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.RemarshalException;
+import org.omg.CORBA.portable.ServantObject;
+
+/**
+ * Normally generated with rmic compiler, this class represents the GameManager
+ * Stub on the client side. The Game Manager methods contain the code for
+ * remote invocation.
+ *
+ * This class is normally generated with rmic from the {@link GameManagerImpl}:
+ * <pre>
+ * rmic -iiop -poa -keep gnu.classpath.examples.CORBA.swing.x5.GameManagerImpl
+ * </pre>
+ * (the compiled package must be present in the current folder).
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class _GameManager_Stub extends Stub implements GameManager
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ private static final String[] _type_ids =
+ { "RMI:gnu.classpath.examples.CORBA.swing.x5.GameManager:0000000000000000" };
+
+ public String[] _ids()
+ {
+ return _type_ids;
+ }
+
+ /**
+ * Notify the manager that the player is no longer willing to play and
+ * should be removed from the queue.
+ */
+ public void unregister(Player p)
+ throws RemoteException
+ {
+ if (!Util.isLocal(this))
+ {
+ try
+ {
+ org.omg.CORBA.portable.InputStream in = null;
+ try
+ {
+ OutputStream out = _request("unregister", true);
+ Util.writeRemoteObject(out, p);
+ _invoke(out);
+ }
+ catch (ApplicationException ex)
+ {
+ in = ex.getInputStream();
+
+ String id = in.read_string();
+ throw new UnexpectedException(id);
+ }
+ catch (RemarshalException ex)
+ {
+ unregister(p);
+ }
+ finally
+ {
+ _releaseReply(in);
+ }
+ }
+ catch (SystemException ex)
+ {
+ throw Util.mapSystemException(ex);
+ }
+ }
+ else
+ {
+ ServantObject so =
+ _servant_preinvoke("requestTheGame", GameManager.class);
+ if (so == null)
+ {
+ unregister(p);
+ return;
+ }
+ try
+ {
+ ((GameManager) so.servant).unregister(p);
+ }
+ catch (Throwable ex)
+ {
+ Throwable exCopy = (Throwable) Util.copyObject(ex, _orb());
+ throw Util.wrapException(exCopy);
+ }
+ finally
+ {
+ _servant_postinvoke(so);
+ }
+ }
+ }
+
+ /**
+ * The method that the user should invoke.
+ */
+ public void requestTheGame(Player arg0) throws RemoteException
+ {
+ if (!Util.isLocal(this))
+ {
+ try
+ {
+ org.omg.CORBA.portable.InputStream in = null;
+ try
+ {
+ OutputStream out = _request("requestTheGame", true);
+ Util.writeRemoteObject(out, arg0);
+ _invoke(out);
+ }
+ catch (ApplicationException ex)
+ {
+ in = ex.getInputStream();
+
+ String id = in.read_string();
+ throw new UnexpectedException(id);
+ }
+ catch (RemarshalException ex)
+ {
+ requestTheGame(arg0);
+ }
+ finally
+ {
+ _releaseReply(in);
+ }
+ }
+ catch (SystemException ex)
+ {
+ throw Util.mapSystemException(ex);
+ }
+ }
+ else
+ {
+ ServantObject so =
+ _servant_preinvoke("requestTheGame", GameManager.class);
+ if (so == null)
+ {
+ requestTheGame(arg0);
+ return;
+ }
+ try
+ {
+ Player arg0Copy = (Player) Util.copyObject(arg0, _orb());
+ ((GameManager) so.servant).requestTheGame(arg0Copy);
+ }
+ catch (Throwable ex)
+ {
+ Throwable exCopy = (Throwable) Util.copyObject(ex, _orb());
+ throw Util.wrapException(exCopy);
+ }
+ finally
+ {
+ _servant_postinvoke(so);
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/_PlayerImpl_Tie.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/_PlayerImpl_Tie.java
new file mode 100644
index 000000000..f6c5f4765
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/_PlayerImpl_Tie.java
@@ -0,0 +1,209 @@
+/* _PlayerImpl_Tie.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., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 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.swing.x5;
+
+import java.awt.Point;
+import java.rmi.Remote;
+
+import javax.rmi.PortableRemoteObject;
+import javax.rmi.CORBA.Tie;
+
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.SystemException;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.ResponseHandler;
+import org.omg.CORBA.portable.UnknownException;
+import org.omg.PortableServer.Servant;
+
+/**
+ * Generate with rmic, command line
+ * rmic -iiop -poa -keep gnu.classpath.examples.CORBA.swing.x5.PlayerImpl
+ * (the compiled package must be present in the current folder).
+ *
+ * This class is normally generated with rmic or grmic from the
+ * {@link PlayerImpl}. See tools/gnu/classpath/tools/giop/README.
+ *
+ * In this example the class was manually edited and commented for better
+ * understanding of functionality.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class _PlayerImpl_Tie extends Servant implements Tie
+{
+ private PlayerImpl target = null;
+ private static final String[] _type_ids =
+ { "RMI:gnu.classpath.examples.CORBA.swing.x5.Player:0000000000000000" };
+
+ public void setTarget(Remote a_target)
+ {
+ this.target = (PlayerImpl) a_target;
+ }
+
+ public Remote getTarget()
+ {
+ return target;
+ }
+
+ public org.omg.CORBA.Object thisObject()
+ {
+ return _this_object();
+ }
+
+ public void deactivate()
+ {
+ try
+ {
+ _poa().deactivate_object(_poa().servant_to_id(this));
+ }
+ catch (org.omg.PortableServer.POAPackage.WrongPolicy exception)
+ {
+ }
+ catch (org.omg.PortableServer.POAPackage.ObjectNotActive exception)
+ {
+ }
+ catch (org.omg.PortableServer.POAPackage.ServantNotActive exception)
+ {
+ }
+ }
+
+ public ORB orb()
+ {
+ return _orb();
+ }
+
+ public void orb(ORB orb)
+ {
+ try
+ {
+ ((org.omg.CORBA_2_3.ORB) orb).set_delegate(this);
+ }
+ catch (ClassCastException e)
+ {
+ throw new org.omg.CORBA.BAD_PARAM(
+ "POA Servant requires an instance of org.omg.CORBA_2_3.ORB"
+ );
+ }
+ }
+
+ public String[] _all_interfaces(org.omg.PortableServer.POA poa,
+ byte[] objectId
+ )
+ {
+ return _type_ids;
+ }
+
+ public OutputStream _invoke(String method, InputStream _in,
+ ResponseHandler reply
+ ) throws SystemException
+ {
+ try
+ {
+ org.omg.CORBA_2_3.portable.InputStream in =
+ (org.omg.CORBA_2_3.portable.InputStream) _in;
+ switch (method.charAt(9))
+ {
+ case 101 :
+ if (method.equals("start_game"))
+ {
+ Player arg0 =
+ (Player) PortableRemoteObject.narrow(in.read_Object(),
+ Player.class
+ );
+ boolean arg1 = in.read_boolean();
+ boolean result = target.start_game(arg0, arg1);
+ OutputStream out = reply.createReply();
+ out.write_boolean(result);
+ return out;
+ }
+
+ case 104 :
+ if (method.equals("receive_chat"))
+ {
+ byte arg0 = in.read_octet();
+ String arg1 = (String) in.read_value(String.class);
+ target.receive_chat(arg0, arg1);
+
+ OutputStream out = reply.createReply();
+ return out;
+ }
+
+ case 111 :
+ if (method.equals("receive_move"))
+ {
+ int arg0 = in.read_long();
+ int arg1 = in.read_long();
+ Point[] arg2 = (Point[]) in.read_value(Point[].class);
+ target.receive_move(arg0, arg1, arg2);
+
+ OutputStream out = reply.createReply();
+ return out;
+ }
+
+ case 114 :
+ if (method.equals("_get_J_current_state"))
+ {
+ int result = target.get_current_state();
+ OutputStream out = reply.createReply();
+ out.write_long(result);
+ return out;
+ }
+
+ case 116 :
+ if (method.equals("disconnect"))
+ {
+ target.disconnect();
+
+ OutputStream out = reply.createReply();
+ return out;
+ }
+ }
+ throw new BAD_OPERATION("No such method: '"+method+"'");
+ }
+ catch (SystemException ex)
+ {
+ throw ex;
+ }
+ catch (Throwable ex)
+ {
+ throw new UnknownException(ex);
+ }
+ }
+} \ No newline at end of file
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/_Player_Stub.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/_Player_Stub.java
new file mode 100644
index 000000000..eeb5cf0da
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5/_Player_Stub.java
@@ -0,0 +1,397 @@
+/* _Player_Stub.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., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 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.swing.x5;
+
+import java.awt.Point;
+import java.io.Serializable;
+import java.rmi.RemoteException;
+import java.rmi.UnexpectedException;
+
+import javax.rmi.CORBA.Stub;
+import javax.rmi.CORBA.Util;
+
+import org.omg.CORBA.SystemException;
+import org.omg.CORBA.portable.ApplicationException;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.RemarshalException;
+import org.omg.CORBA.portable.ServantObject;
+
+/**
+ * Generate with rmic, command line
+ * rmic -iiop -poa -keep gnu.classpath.examples.CORBA.swing.x5.PlayerImpl
+ * (the compiled package must be present in the current folder).
+ *
+ * This class is normally generated with rmic from the {@link GameManagerImpl}:
+ * <pre>
+ * rmic -iiop -poa -keep gnu.classpath.examples.CORBA.swing.x5.GameManagerImpl
+ * </pre>
+ * (the compiled package must be present in the current folder).
+ *
+ * In this example the class was manually edited and commented for better
+ * understanding of functionality.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class _Player_Stub extends Stub implements Player
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ private static final String[] _type_ids =
+ { "RMI:gnu.classpath.examples.CORBA.swing.x5.Player:0000000000000000" };
+
+ public String[] _ids()
+ {
+ return _type_ids;
+ }
+
+ public boolean start_game(Player arg0, boolean arg1)
+ throws RemoteException
+ {
+ if (!Util.isLocal(this))
+ {
+ try
+ {
+ org.omg.CORBA.portable.InputStream in = null;
+ try
+ {
+ OutputStream out = _request("start_game", true);
+ Util.writeRemoteObject(out, arg0);
+ out.write_boolean(arg1);
+ in = _invoke(out);
+ return in.read_boolean();
+ }
+ catch (ApplicationException ex)
+ {
+ in = ex.getInputStream();
+
+ String id = in.read_string();
+ throw new UnexpectedException(id);
+ }
+ catch (RemarshalException ex)
+ {
+ return start_game(arg0, arg1);
+ }
+ finally
+ {
+ _releaseReply(in);
+ }
+ }
+ catch (SystemException ex)
+ {
+ throw Util.mapSystemException(ex);
+ }
+ }
+ else
+ {
+ ServantObject so = _servant_preinvoke("start_game", Player.class);
+ if (so == null)
+ {
+ return start_game(arg0, arg1);
+ }
+ try
+ {
+ Player arg0Copy = (Player) Util.copyObject(arg0, _orb());
+ return ((Player) so.servant).start_game(arg0Copy, arg1);
+ }
+ catch (Throwable ex)
+ {
+ Throwable exCopy = (Throwable) Util.copyObject(ex, _orb());
+ throw Util.wrapException(exCopy);
+ }
+ finally
+ {
+ _servant_postinvoke(so);
+ }
+ }
+ }
+
+ public int get_current_state() throws RemoteException
+ {
+ if (!Util.isLocal(this))
+ {
+ try
+ {
+ org.omg.CORBA.portable.InputStream in = null;
+ try
+ {
+ OutputStream out = _request("_get_J_current_state", true);
+ in = _invoke(out);
+ return in.read_long();
+ }
+ catch (ApplicationException ex)
+ {
+ in = ex.getInputStream();
+
+ String id = in.read_string();
+ throw new UnexpectedException(id);
+ }
+ catch (RemarshalException ex)
+ {
+ return get_current_state();
+ }
+ finally
+ {
+ _releaseReply(in);
+ }
+ }
+ catch (SystemException ex)
+ {
+ throw Util.mapSystemException(ex);
+ }
+ }
+ else
+ {
+ ServantObject so =
+ _servant_preinvoke("_get_J_current_state", Player.class);
+ if (so == null)
+ {
+ return get_current_state();
+ }
+ try
+ {
+ return ((Player) so.servant).get_current_state();
+ }
+ catch (Throwable ex)
+ {
+ Throwable exCopy = (Throwable) Util.copyObject(ex, _orb());
+ throw Util.wrapException(exCopy);
+ }
+ finally
+ {
+ _servant_postinvoke(so);
+ }
+ }
+ }
+
+ public void receive_chat(byte arg0, String arg1) throws RemoteException
+ {
+ if (!Util.isLocal(this))
+ {
+ try
+ {
+ org.omg.CORBA_2_3.portable.InputStream in = null;
+ try
+ {
+ org.omg.CORBA_2_3.portable.OutputStream out =
+ (org.omg.CORBA_2_3.portable.OutputStream) _request("receive_chat",
+ true
+ );
+ out.write_octet(arg0);
+ out.write_value(arg1, String.class);
+ _invoke(out);
+ }
+ catch (ApplicationException ex)
+ {
+ in =
+ (org.omg.CORBA_2_3.portable.InputStream) ex.getInputStream();
+
+ String id = in.read_string();
+ throw new UnexpectedException(id);
+ }
+ catch (RemarshalException ex)
+ {
+ receive_chat(arg0, arg1);
+ }
+ finally
+ {
+ _releaseReply(in);
+ }
+ }
+ catch (SystemException ex)
+ {
+ throw Util.mapSystemException(ex);
+ }
+ }
+ else
+ {
+ ServantObject so = _servant_preinvoke("receive_chat", Player.class);
+ if (so == null)
+ {
+ receive_chat(arg0, arg1);
+ return;
+ }
+ try
+ {
+ ((Player) so.servant).receive_chat(arg0, arg1);
+ }
+ catch (Throwable ex)
+ {
+ Throwable exCopy = (Throwable) Util.copyObject(ex, _orb());
+ throw Util.wrapException(exCopy);
+ }
+ finally
+ {
+ _servant_postinvoke(so);
+ }
+ }
+ }
+
+ public void disconnect() throws RemoteException
+ {
+ if (!Util.isLocal(this))
+ {
+ try
+ {
+ org.omg.CORBA.portable.InputStream in = null;
+ try
+ {
+ OutputStream out = _request("disconnect", true);
+ _invoke(out);
+ }
+ catch (ApplicationException ex)
+ {
+ in = ex.getInputStream();
+
+ String id = in.read_string();
+ throw new UnexpectedException(id);
+ }
+ catch (RemarshalException ex)
+ {
+ disconnect();
+ }
+ finally
+ {
+ _releaseReply(in);
+ }
+ }
+ catch (SystemException ex)
+ {
+ throw Util.mapSystemException(ex);
+ }
+ }
+ else
+ {
+ ServantObject so = _servant_preinvoke("disconnect", Player.class);
+ if (so == null)
+ {
+ disconnect();
+ return;
+ }
+ try
+ {
+ ((Player) so.servant).disconnect();
+ }
+ catch (Throwable ex)
+ {
+ Throwable exCopy = (Throwable) Util.copyObject(ex, _orb());
+ throw Util.wrapException(exCopy);
+ }
+ finally
+ {
+ _servant_postinvoke(so);
+ }
+ }
+ }
+
+ public void receive_move(int arg0, int arg1, Point[] arg2)
+ throws RemoteException
+ {
+ if (!Util.isLocal(this))
+ {
+ try
+ {
+ org.omg.CORBA_2_3.portable.InputStream in = null;
+ try
+ {
+ org.omg.CORBA_2_3.portable.OutputStream out =
+ (org.omg.CORBA_2_3.portable.OutputStream) _request("receive_move",
+ true
+ );
+ out.write_long(arg0);
+ out.write_long(arg1);
+ out.write_value(cast_array(arg2), Point[].class);
+ _invoke(out);
+ }
+ catch (ApplicationException ex)
+ {
+ in =
+ (org.omg.CORBA_2_3.portable.InputStream) ex.getInputStream();
+
+ String id = in.read_string();
+ throw new UnexpectedException(id);
+ }
+ catch (RemarshalException ex)
+ {
+ receive_move(arg0, arg1, arg2);
+ }
+ finally
+ {
+ _releaseReply(in);
+ }
+ }
+ catch (SystemException ex)
+ {
+ throw Util.mapSystemException(ex);
+ }
+ }
+ else
+ {
+ ServantObject so = _servant_preinvoke("receive_move", Player.class);
+ if (so == null)
+ {
+ receive_move(arg0, arg1, arg2);
+ return;
+ }
+ try
+ {
+ Point[] arg2Copy = (Point[]) Util.copyObject(arg2, _orb());
+ ((Player) so.servant).receive_move(arg0, arg1, arg2Copy);
+ }
+ catch (Throwable ex)
+ {
+ Throwable exCopy = (Throwable) Util.copyObject(ex, _orb());
+ throw Util.wrapException(exCopy);
+ }
+ finally
+ {
+ _servant_postinvoke(so);
+ }
+ }
+ }
+
+ // This method is required as a work-around for
+ // a bug in the JDK 1.1.6 verifier.
+ private Serializable cast_array(Object obj)
+ {
+ return (Serializable) obj;
+ }
+} \ No newline at end of file