KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.sapia.ubik.rmi.server.command;
2
3
4 /**
5  * Models a "response": i.e.: the return value of an asynchronous call-back.
6  * An instance of this class in fact encapsulate the return value itself,
7  * plus the command identifier of the response at the originating host.
8  *
9  * @author Yanick Duchesne
10  * <dl>
11  * <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>
12  * <dt><b>License:</b><dd>Read the license.txt file of the jar or visit the
13  * <a HREF="http://www.sapia-oss.org/license.html">license page</a> at the Sapia OSS web site</dd></dt>
14  * </dl>
15  */

16 public class Response implements Executable, java.io.Serializable JavaDoc {
17   private String JavaDoc _id;
18   private Object JavaDoc _obj;
19
20   /**
21    * Constructor for Response.
22    */

23   public Response(String JavaDoc cmdId, Object JavaDoc response) {
24     _id = cmdId;
25     _obj = response;
26   }
27
28   /**
29    * Returns the command identifier that this response corresponds to.
30    *
31    * @return a command identifier.
32    */

33   public String JavaDoc getId() {
34     return _id;
35   }
36
37   /**
38    * This response's return value.
39    *
40    * @return an <code>Object</code> or <code>null</code> if the
41    * return value of the original asynchronous call-back is null.
42    */

43   public Object JavaDoc get() {
44     return _obj;
45   }
46
47   /**
48    * @see org.sapia.ubik.rmi.server.command.Executable#execute()
49    */

50   public Object JavaDoc execute() throws Throwable JavaDoc {
51     return _obj;
52   }
53
54   public String JavaDoc toString() {
55     return "[ id=" + _id + " ]";
56   }
57 }
58
Popular Tags