1 package org.lsst.ccs.bus;
2
3 import org.lsst.ccs.utilities.logging.Logger;
4
5 import java.io.Serializable;
6 import java.util.Arrays;
7
8
9
10
11
12
13
14
15 public abstract class Command extends BusMessage implements CommandBusMessage {
16
17
18
19
20 public static final Serializable[] NO_ARGS = new Serializable[0];
21 private static final long serialVersionUID = 1488098756706412158L;
22 protected static final Logger log = Logger.getLogger("org.lsst.ccs.bus.Command");
23
24 @Override
25 public String getMessageType() {
26 return "lsst.command";
27 }
28
29
30
31 protected String destination = "*";
32
33 protected String key;
34
35 protected int level;
36
37
38
39
40 String correlId;
41
42 protected String command;
43 protected Object[] parameters = NO_ARGS;
44
45
46
47
48 protected boolean unParsed = false;
49
50
51
52 protected Command(String key, int level, String destination, String command, Object... parameterz) {
53 this.level = level;
54 this.destination = destination;
55 this.command = command;
56 this.parameters = parameterz;
57 }
58
59
60
61
62
63
64 public String getDestination() {
65 return destination;
66 }
67
68
69
70
71
72
73 public void setDestination(String destination) {
74 this.destination = destination;
75 }
76
77
78
79
80
81
82
83
84 public String getKey() {
85 return key;
86 }
87
88
89
90
91
92
93
94 public void setKey(String key) {
95 this.key = key;
96 }
97
98
99
100
101
102
103 @Deprecated
104 public boolean isWrite() {
105 return true;
106 }
107
108
109
110
111
112 @Deprecated
113 protected boolean canWaitForReady = true;
114
115
116
117
118
119
120 @Deprecated
121 public boolean canWaitForReady() {
122 return canWaitForReady;
123 }
124
125
126
127
128
129
130 @Deprecated
131 public void setCanWaitForReady(boolean canWaitForReady) {
132 this.canWaitForReady = canWaitForReady;
133 }
134
135
136
137
138 @Deprecated
139 protected boolean canRunInActiveMode = true;
140
141
142
143
144
145
146 @Deprecated
147 public boolean canRunInActiveMode() {
148 return canRunInActiveMode;
149 }
150
151 @Deprecated
152 public void setCanRunInActiveMode(boolean canRunInActiveMode) {
153 this.canRunInActiveMode = canRunInActiveMode;
154 }
155
156 @Override
157 public String toString() {
158 return getClass().getName() + " from " + origin + " to " + destination + "["
159 + this.getCommand() + "(" + Arrays.toString(parameters) + ")";
160 }
161
162 public String getCorrelId() {
163 return correlId;
164 }
165
166
167
168
169
170
171 public void setCorrelId(String correlId) {
172 this.correlId = correlId;
173 }
174
175
176 public boolean isUnParsed() {
177 return unParsed;
178 }
179
180 public void setUnParsed(boolean unParsed) {
181 this.unParsed = unParsed;
182 }
183
184 public String getCommand() {
185 return command;
186 }
187
188 public Object[] getParameters() {
189 return parameters;
190 }
191
192 public int getLevel() {
193 return level;
194 }
195
196 @Deprecated
197 public void setLevel(int level) {
198 this.level = level;
199 }
200 }