aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/CORBA/swing/x5')
-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
17 files changed, 3628 insertions, 0 deletions
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