Reset branch to trunk.
[official-gcc.git] / trunk / libjava / classpath / examples / gnu / classpath / examples / CORBA / swing / x5 / _PlayerImpl_Tie.java
blobf6c5f476521818e76a165e5b3acbcb6582ff31bc
1 /* _PlayerImpl_Tie.java --
2 Copyright (C) 2005 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 02110-1301 USA.
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 package gnu.classpath.examples.CORBA.swing.x5;
41 import java.awt.Point;
42 import java.rmi.Remote;
44 import javax.rmi.PortableRemoteObject;
45 import javax.rmi.CORBA.Tie;
47 import org.omg.CORBA.BAD_OPERATION;
48 import org.omg.CORBA.ORB;
49 import org.omg.CORBA.SystemException;
50 import org.omg.CORBA.portable.InputStream;
51 import org.omg.CORBA.portable.OutputStream;
52 import org.omg.CORBA.portable.ResponseHandler;
53 import org.omg.CORBA.portable.UnknownException;
54 import org.omg.PortableServer.Servant;
56 /**
57 * Generate with rmic, command line
58 * rmic -iiop -poa -keep gnu.classpath.examples.CORBA.swing.x5.PlayerImpl
59 * (the compiled package must be present in the current folder).
61 * This class is normally generated with rmic or grmic from the
62 * {@link PlayerImpl}. See tools/gnu/classpath/tools/giop/README.
64 * In this example the class was manually edited and commented for better
65 * understanding of functionality.
67 * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
69 public class _PlayerImpl_Tie extends Servant implements Tie
71 private PlayerImpl target = null;
72 private static final String[] _type_ids =
73 { "RMI:gnu.classpath.examples.CORBA.swing.x5.Player:0000000000000000" };
75 public void setTarget(Remote a_target)
77 this.target = (PlayerImpl) a_target;
80 public Remote getTarget()
82 return target;
85 public org.omg.CORBA.Object thisObject()
87 return _this_object();
90 public void deactivate()
92 try
94 _poa().deactivate_object(_poa().servant_to_id(this));
96 catch (org.omg.PortableServer.POAPackage.WrongPolicy exception)
99 catch (org.omg.PortableServer.POAPackage.ObjectNotActive exception)
102 catch (org.omg.PortableServer.POAPackage.ServantNotActive exception)
107 public ORB orb()
109 return _orb();
112 public void orb(ORB orb)
116 ((org.omg.CORBA_2_3.ORB) orb).set_delegate(this);
118 catch (ClassCastException e)
120 throw new org.omg.CORBA.BAD_PARAM(
121 "POA Servant requires an instance of org.omg.CORBA_2_3.ORB"
126 public String[] _all_interfaces(org.omg.PortableServer.POA poa,
127 byte[] objectId
130 return _type_ids;
133 public OutputStream _invoke(String method, InputStream _in,
134 ResponseHandler reply
135 ) throws SystemException
139 org.omg.CORBA_2_3.portable.InputStream in =
140 (org.omg.CORBA_2_3.portable.InputStream) _in;
141 switch (method.charAt(9))
143 case 101 :
144 if (method.equals("start_game"))
146 Player arg0 =
147 (Player) PortableRemoteObject.narrow(in.read_Object(),
148 Player.class
150 boolean arg1 = in.read_boolean();
151 boolean result = target.start_game(arg0, arg1);
152 OutputStream out = reply.createReply();
153 out.write_boolean(result);
154 return out;
157 case 104 :
158 if (method.equals("receive_chat"))
160 byte arg0 = in.read_octet();
161 String arg1 = (String) in.read_value(String.class);
162 target.receive_chat(arg0, arg1);
164 OutputStream out = reply.createReply();
165 return out;
168 case 111 :
169 if (method.equals("receive_move"))
171 int arg0 = in.read_long();
172 int arg1 = in.read_long();
173 Point[] arg2 = (Point[]) in.read_value(Point[].class);
174 target.receive_move(arg0, arg1, arg2);
176 OutputStream out = reply.createReply();
177 return out;
180 case 114 :
181 if (method.equals("_get_J_current_state"))
183 int result = target.get_current_state();
184 OutputStream out = reply.createReply();
185 out.write_long(result);
186 return out;
189 case 116 :
190 if (method.equals("disconnect"))
192 target.disconnect();
194 OutputStream out = reply.createReply();
195 return out;
198 throw new BAD_OPERATION("No such method: '"+method+"'");
200 catch (SystemException ex)
202 throw ex;
204 catch (Throwable ex)
206 throw new UnknownException(ex);