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 id; |
---|
13 | private String method; |
---|
14 | private boolean async = false; |
---|
15 | private Object[] arguments; |
---|
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[] arguments) { |
---|
24 | this.id = id; |
---|
25 | this.method = method; |
---|
26 | this.arguments = arguments; |
---|
27 | } |
---|
28 | |
---|
29 | private Request(String id, String method, boolean async, Object[] arguments) { |
---|
30 | this.id = id; |
---|
31 | this.method = method; |
---|
32 | this.async = async; |
---|
33 | this.arguments = arguments; |
---|
34 | } |
---|
35 | |
---|
36 | public static Request newSyncRequest(String id, String method, Object[] arguments) { |
---|
37 | return new Request(id, method, false, arguments); |
---|
38 | } |
---|
39 | |
---|
40 | public static Request newSyncRequest(String id, String method, Object[] arguments, int retries, long timeout) { |
---|
41 | Request req = new Request(id, method, false, arguments); |
---|
42 | req.setRetries(retries); |
---|
43 | req.setTimeout(timeout); |
---|
44 | return req; |
---|
45 | } |
---|
46 | |
---|
47 | public static Request newAsyncRequest(String id, String method, Object[] arguments) { |
---|
48 | return new Request(id, method, true, arguments); |
---|
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[] getArguments() { |
---|
68 | return arguments; |
---|
69 | } |
---|
70 | |
---|
71 | public void setArguments(Object[] arguments) { |
---|
72 | this.arguments = arguments; |
---|
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 | } |
---|