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