01: /*
02: * Copyright 2005 Joe Walker
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.directwebremoting.extend;
17:
18: /**
19: * Reply is a read-only POJO to encapsulate the information required to make a
20: * single java call, including the result of the call (either returned data or
21: * exception).
22: * @author Joe Walker [joe at getahead dot ltd dot uk]
23: */
24: public class Reply {
25: /**
26: * Constructor for the success case.
27: * @param callId The call callId, copied from the Call object
28: * @param reply The successful reply data
29: */
30: public Reply(String callId, Object reply) {
31: this .callId = callId;
32: this .reply = reply;
33: }
34:
35: /**
36: * Constructor for the error case.
37: * Reply <b>must</b> be set to null for this constructor to work. This
38: * parameter exists to avoid overloading issues. See Java Puzzlers #46 for
39: * an example.
40: * @param callId The call callId, copied from the Call object
41: * @param reply Must be set to null
42: * @param th The exception to record against this call.
43: */
44: public Reply(String callId, Object reply, Throwable th) {
45: if (reply != null) {
46: throw new NullPointerException(
47: "'reply' must be null when setting an Exception.");
48: }
49:
50: this .callId = callId;
51: this .th = th;
52: }
53:
54: /**
55: * @return Returns the call callId.
56: */
57: public String getCallId() {
58: return callId;
59: }
60:
61: /**
62: * @return Returns the call return value.
63: */
64: public Object getReply() {
65: return reply;
66: }
67:
68: /**
69: * @return Returns the Exception
70: */
71: public Throwable getThrowable() {
72: return th;
73: }
74:
75: private String callId = null;
76:
77: private Object reply = null;
78:
79: private Throwable th = null;
80: }
|