1 | package omq.common.message; |
---|
2 | |
---|
3 | import java.io.Serializable; |
---|
4 | |
---|
5 | public class Request implements Serializable { |
---|
6 | |
---|
7 | /** |
---|
8 | * |
---|
9 | */ |
---|
10 | private static final long serialVersionUID = 6366255840200365083L; |
---|
11 | |
---|
12 | private String method; |
---|
13 | private Object[] params; |
---|
14 | private String id; |
---|
15 | private boolean async = false; |
---|
16 | |
---|
17 | private transient long timeout; |
---|
18 | private transient int retries; |
---|
19 | |
---|
20 | public Request() { |
---|
21 | } |
---|
22 | |
---|
23 | public Request(String id, String method, Object[] params) { |
---|
24 | this.id = id; |
---|
25 | this.method = method; |
---|
26 | this.params = params; |
---|
27 | } |
---|
28 | |
---|
29 | private Request(String id, String method, boolean async, Object[] params) { |
---|
30 | this.id = id; |
---|
31 | this.method = method; |
---|
32 | this.async = async; |
---|
33 | this.params = params; |
---|
34 | } |
---|
35 | |
---|
36 | public static Request newSyncRequest(String id, String method, Object[] params) { |
---|
37 | return new Request(id, method, false, params); |
---|
38 | } |
---|
39 | |
---|
40 | public static Request newSyncRequest(String id, String method, Object[] params, int retries, long timeout) { |
---|
41 | Request req = new Request(id, method, false, params); |
---|
42 | req.setRetries(retries); |
---|
43 | req.setTimeout(timeout); |
---|
44 | return req; |
---|
45 | } |
---|
46 | |
---|
47 | public static Request newAsyncRequest(String id, String method, Object[] params) { |
---|
48 | return new Request(id, method, true, params); |
---|
49 | } |
---|
50 | |
---|
51 | public String getId() { |
---|
52 | return id; |
---|
53 | } |
---|
54 | |
---|
55 | public void setId(String id) { |
---|
56 | this.id = id; |
---|
57 | } |
---|
58 | |
---|
59 | public String getMethod() { |
---|
60 | return method; |
---|
61 | } |
---|
62 | |
---|
63 | public void setMethod(String method) { |
---|
64 | this.method = method; |
---|
65 | } |
---|
66 | |
---|
67 | public Object[] getParams() { |
---|
68 | return params; |
---|
69 | } |
---|
70 | |
---|
71 | public void setParams(Object[] params) { |
---|
72 | this.params = params; |
---|
73 | } |
---|
74 | |
---|
75 | public boolean isAsync() { |
---|
76 | return async; |
---|
77 | } |
---|
78 | |
---|
79 | public void setAsync(boolean async) { |
---|
80 | this.async = async; |
---|
81 | } |
---|
82 | |
---|
83 | public long getTimeout() { |
---|
84 | return timeout; |
---|
85 | } |
---|
86 | |
---|
87 | public void setTimeout(long timeout) { |
---|
88 | this.timeout = timeout; |
---|
89 | } |
---|
90 | |
---|
91 | public int getRetries() { |
---|
92 | return retries; |
---|
93 | } |
---|
94 | |
---|
95 | public void setRetries(int retries) { |
---|
96 | this.retries = retries; |
---|
97 | } |
---|
98 | |
---|
99 | } |
---|