KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > ubik > rmi > server > command > AsyncCommand


1 package org.sapia.ubik.rmi.server.command;
2
3 import org.sapia.ubik.net.ServerAddress;
4 import org.sapia.ubik.rmi.server.VmId;
5
6
7 /**
8  * Models a command that is executed asynchronously.
9  *
10  * @author Yanick Duchesne
11  * <dl>
12  * <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>
13  * <dt><b>License:</b><dd>Read the license.txt file of the jar or visit the
14  * <a HREF="http://www.sapia-oss.org/license.html">license page</a> at the Sapia OSS web site</dd></dt>
15  * </dl>
16  */

17 public class AsyncCommand implements Executable {
18   private String JavaDoc _cmdId;
19   private VmId _caller;
20   private ServerAddress _from;
21   private Command _cmd;
22   private Object JavaDoc _response;
23
24   /**
25    * Constructor for AsyncCommandWrapper.
26    *
27    * @param the unique identifier of this command.
28    * @param from the <code>ServerAddress</code> corresponding to
29    * the server to call back, and from which this command originates.
30    * @param cmd the <code>Command</code> instance to wrap.
31    */

32   public AsyncCommand(String JavaDoc cmdId, VmId caller, ServerAddress from, Command cmd) {
33     _cmdId = cmdId;
34     _from = from;
35     _cmd = cmd;
36     _caller = caller;
37   }
38
39   /**
40    * Returns the identifier of this command.
41    *
42    * @return the identifier of this command.
43    */

44   public String JavaDoc getCmdId() {
45     return _cmdId;
46   }
47
48   /**
49    * Returns the address of the server to call back, and from which
50    * this command originates.
51    *
52    * @return a <code>ServerAddress<code>.
53    */

54   public ServerAddress getFrom() {
55     return _from;
56   }
57
58   /**
59    * Returns the caller's VM identifier.
60    *
61    * @return a <code>VmId</code>
62    */

63   public VmId getCallerVmId() {
64     return _caller;
65   }
66
67   /**
68    * Returns this instance's wrapped command.
69    *
70    * @return a <code>Command</code>.
71    */

72   public Command getCommand() {
73     return _cmd;
74   }
75
76   /**
77    * @see org.sapia.ubik.rmi.server.command.Executable#execute()
78    */

79   public Object JavaDoc execute() throws Throwable JavaDoc {
80     return _cmd.execute();
81   }
82 }
83
Popular Tags