KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > ubik > rmi > server > CommandConnect


1 package org.sapia.ubik.rmi.server;
2
3 import java.io.IOException JavaDoc;
4 import java.io.ObjectInput JavaDoc;
5 import java.io.ObjectOutput JavaDoc;
6
7
8 /**
9  * This command sends back a remote reference to the caller, for the server
10  * listening at the port specified in the constructor.
11  * @author Yanick Duchesne
12  * <dl>
13  * <dt><b>Copyright:</b><dd>Copyright &#169; 2002-2003 <a HREF="http://www.sapia-oss.org">Sapia Open Source Software</a>. All Rights Reserved.</dd></dt>
14  * <dt><b>License:</b><dd>Read the license.txt file of the jar or visit the
15  * <a HREF="http://www.sapia-oss.org/license.html">license page</a> at the Sapia OSS web site</dd></dt>
16  * </dl>
17  */

18 public class CommandConnect extends RMICommand {
19   private String JavaDoc _transportType;
20
21   /** Do not call; used for externalization only */
22   public CommandConnect() {
23   }
24
25   public CommandConnect(String JavaDoc transportType) {
26     _transportType = transportType;
27   }
28
29   /**
30    * @see org.sapia.ubik.rmi.server.RMICommand#execute()
31    */

32   public Object JavaDoc execute() throws Throwable JavaDoc {
33     ServerRef ref = Hub.serverRuntime.server.getServerRef(_transportType);
34     Hub.serverRuntime.gc.registerRef(_vmId, ref.oid, ref.server);
35
36     return ref.stub;
37   }
38
39   /**
40    * @see org.sapia.ubik.rmi.server.RMICommand#readExternal(java.io.ObjectInput)
41    */

42   public void readExternal(ObjectInput JavaDoc in)
43     throws IOException JavaDoc, ClassNotFoundException JavaDoc {
44     super.readExternal(in);
45     _transportType = in.readUTF();
46   }
47
48   /**
49    * @see org.sapia.ubik.rmi.server.RMICommand#writeExternal(java.io.ObjectOutput)
50    */

51   public void writeExternal(ObjectOutput JavaDoc out) throws IOException JavaDoc {
52     super.writeExternal(out);
53     out.writeUTF(_transportType);
54   }
55 }
56
Popular Tags