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 boolean multi; |
---|
18 | private transient int wait; |
---|
19 | private transient long timeout; |
---|
20 | private transient int retries; |
---|
21 | |
---|
22 | public Request() { |
---|
23 | } |
---|
24 | |
---|
25 | public Request(String id, String method, Object[] params) { |
---|
26 | this.id = id; |
---|
27 | this.method = method; |
---|
28 | this.params = params; |
---|
29 | } |
---|
30 | |
---|
31 | private Request(String id, String method, boolean async, Object[] params) { |
---|
32 | this.id = id; |
---|
33 | this.method = method; |
---|
34 | this.async = async; |
---|
35 | this.params = params; |
---|
36 | } |
---|
37 | |
---|
38 | private Request(String id, String method, boolean async, Object[] params, boolean multi) { |
---|
39 | this.id = id; |
---|
40 | this.method = method; |
---|
41 | this.async = async; |
---|
42 | this.params = params; |
---|
43 | this.multi = multi; |
---|
44 | } |
---|
45 | |
---|
46 | public static Request newSyncRequest(String id, String method, Object[] params) { |
---|
47 | return new Request(id, method, false, params); |
---|
48 | } |
---|
49 | |
---|
50 | public static Request newSyncRequest(String id, String method, Object[] params, int retries, long timeout, boolean multi, int wait) { |
---|
51 | Request req = new Request(id, method, false, params, multi); |
---|
52 | req.setRetries(retries); |
---|
53 | req.setTimeout(timeout); |
---|
54 | req.setWait(wait); |
---|
55 | return req; |
---|
56 | } |
---|
57 | |
---|
58 | public static Request newAsyncRequest(String id, String method, Object[] params, boolean multi) { |
---|
59 | return new Request(id, method, true, params, multi); |
---|
60 | } |
---|
61 | |
---|
62 | public String getId() { |
---|
63 | return id; |
---|
64 | } |
---|
65 | |
---|
66 | public void setId(String id) { |
---|
67 | this.id = id; |
---|
68 | } |
---|
69 | |
---|
70 | public String getMethod() { |
---|
71 | return method; |
---|
72 | } |
---|
73 | |
---|
74 | public void setMethod(String method) { |
---|
75 | this.method = method; |
---|
76 | } |
---|
77 | |
---|
78 | public Object[] getParams() { |
---|
79 | return params; |
---|
80 | } |
---|
81 | |
---|
82 | public void setParams(Object[] params) { |
---|
83 | this.params = params; |
---|
84 | } |
---|
85 | |
---|
86 | public boolean isAsync() { |
---|
87 | return async; |
---|
88 | } |
---|
89 | |
---|
90 | public void setAsync(boolean async) { |
---|
91 | this.async = async; |
---|
92 | } |
---|
93 | |
---|
94 | public long getTimeout() { |
---|
95 | return timeout; |
---|
96 | } |
---|
97 | |
---|
98 | public void setTimeout(long timeout) { |
---|
99 | this.timeout = timeout; |
---|
100 | } |
---|
101 | |
---|
102 | public int getRetries() { |
---|
103 | return retries; |
---|
104 | } |
---|
105 | |
---|
106 | public void setRetries(int retries) { |
---|
107 | this.retries = retries; |
---|
108 | } |
---|
109 | |
---|
110 | public boolean isMulti() { |
---|
111 | return multi; |
---|
112 | } |
---|
113 | |
---|
114 | public void setMulti(boolean multi) { |
---|
115 | this.multi = multi; |
---|
116 | } |
---|
117 | |
---|
118 | public int getWait() { |
---|
119 | return wait; |
---|
120 | } |
---|
121 | |
---|
122 | public void setWait(int wait) { |
---|
123 | this.wait = wait; |
---|
124 | } |
---|
125 | } |
---|