Dead
[official-gcc.git] / gomp-20050608-branch / libjava / classpath / examples / gnu / classpath / examples / CORBA / swing / x5 / _GameManagerImpl_Tie.java
blob17a62600c962afa3c7607023e4f5940aad361ccf
1 /* _GameManagerImpl_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.rmi.Remote;
43 import javax.rmi.PortableRemoteObject;
44 import javax.rmi.CORBA.Tie;
46 import org.omg.CORBA.BAD_OPERATION;
47 import org.omg.CORBA.ORB;
48 import org.omg.CORBA.SystemException;
49 import org.omg.CORBA.portable.InputStream;
50 import org.omg.CORBA.portable.OutputStream;
51 import org.omg.CORBA.portable.ResponseHandler;
52 import org.omg.CORBA.portable.UnknownException;
53 import org.omg.PortableServer.Servant;
55 /**
56 * Normally generated with rmic compiler, this class represents the GameManager
57 * Tie on the client side. The Game Manager methods contain the code for remote
58 * invocation.
60 * This class is normally generated with rmic from the {@link GameManagerImpl}:
62 * <pre>
63 * rmic -iiop -poa -keep gnu.classpath.examples.CORBA.swing.x5.GameManagerImpl
64 * </pre>
66 * (the compiled package must be present in the current folder).
68 * In this example the class was manually edited and commented for better
69 * understanding of functionality.
71 * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
73 public class _GameManagerImpl_Tie
74 extends Servant
75 implements Tie
77 /**
78 * The target, where remote invocations are forwarded.
80 private GameManagerImpl target = null;
82 /**
83 * The GameManager repository Id.
85 private static final String[] _type_ids =
86 { "RMI:gnu.classpath.examples.CORBA.swing.x5.GameManager:0000000000000000" };
88 /**
89 * Set the target where the remote invocations are forwarded.
91 public void setTarget(Remote a_target)
93 this.target = (GameManagerImpl) a_target;
96 /**
97 * Get the target where the remote invocations are forwarded.
99 public Remote getTarget()
101 return target;
105 * Get the CORBA object for that this Tie is currently serving the request.
106 * The same tie may serve multiple requests for the different objects in
107 * parallel threads.
109 public org.omg.CORBA.Object thisObject()
111 return _this_object();
115 * Deactivate this object.
117 public void deactivate()
121 _poa().deactivate_object(_poa().servant_to_id(this));
123 catch (org.omg.PortableServer.POAPackage.WrongPolicy exception)
126 catch (org.omg.PortableServer.POAPackage.ObjectNotActive exception)
129 catch (org.omg.PortableServer.POAPackage.ServantNotActive exception)
135 * Get the ORB for this tie.
137 public ORB orb()
139 return _orb();
143 * Set the ORB for this tie.
145 public void orb(ORB orb)
149 ((org.omg.CORBA_2_3.ORB) orb).set_delegate(this);
151 catch (ClassCastException e)
153 throw new org.omg.CORBA.BAD_PARAM(
154 "POA Servant requires an instance of org.omg.CORBA_2_3.ORB");
159 * Return all interfaces, supported by this method.
161 public String[] _all_interfaces(org.omg.PortableServer.POA poa,
162 byte[] objectId)
164 return _type_ids;
168 * This method is invoked by CORBA system to handle the remote invocation.
170 * @param method the name of the method being invoked.
171 * @param _in the stream to read the method parameters.
172 * @param reply the responsed handler that can create the output stream to
173 * write the parameters being returned.
175 public OutputStream _invoke(String method, InputStream _in,
176 ResponseHandler reply)
177 throws SystemException
181 org.omg.CORBA_2_3.portable.InputStream in =
182 (org.omg.CORBA_2_3.portable.InputStream) _in;
183 if (method.equals("requestTheGame"))
185 Player p = (Player) PortableRemoteObject.narrow(
186 in.read_Object(), Player.class);
187 target.requestTheGame(p);
189 OutputStream out = reply.createReply();
190 return out;
192 else if (method.equals("unregister"))
194 Player p = (Player) PortableRemoteObject.narrow(
195 in.read_Object(), Player.class);
196 target.unregister(p);
198 OutputStream out = reply.createReply();
199 return out;
201 else
202 throw new BAD_OPERATION();
204 catch (SystemException ex)
206 throw ex;
208 catch (Throwable ex)
210 ex.printStackTrace();
211 throw new UnknownException(ex);