View Javadoc

1   package org.lsst.ccs.bus;
2   
3   /**
4    * Reply to command.
5    *
6    * 
7    */
8   public class CommandReply extends CommandAckOrReply  {
9   
10      private static final long serialVersionUID = -8056794161035014352L;
11  
12      @Override
13      public String getMessageType() {
14          return "lsst.reply";
15      }
16  
17      /**
18       * @ImplSpec
19       * this has been changed: previous status are transfered to Positive or Negative Ack.
20       */
21      public enum CommandStatus {
22  		OK,  OK_VOID, ERROR;
23  	};
24  
25  	CommandStatus status;
26  	Object reply;
27  
28      // nolonger valid : serach information in Thread context or change class
29      @Deprecated
30  	public CommandReply(Object reply, CommandStatus status) {
31  		super();
32  		this.reply = reply;
33  		this.status = status;
34  	}
35  
36      // added by bamade
37      public CommandReply(Command command, Object reply, CommandStatus status, String origin) {
38          super(command,origin);
39          this.status = status;
40          this.reply = reply;
41      }
42      public CommandReply(Command command,   String origin) {
43          super(command,origin);
44          this.status= CommandStatus.OK_VOID ;
45      }
46  
47      public CommandReply(Command command,   Throwable th , String origin) {
48          super(command,origin);
49          this.status= CommandStatus.ERROR ;
50          this.reply = th ;
51      }
52  
53      /**
54  	 * @return the status
55  	 */
56  	public CommandStatus getStatus() {
57  		return status;
58  	}
59  
60  	/**
61  	 * @return the reply
62  	 */
63  	public Object getReply() {
64  		return reply;
65  	}
66  
67  	@Override
68  	public String toString() {
69  		return getClass().getName() + "(" + status + "/" + reply + " from "
70  				+ origin + ")";
71  	}
72  }