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: import java.io.IOException;
19:
20: import javax.servlet.http.HttpServletRequest;
21: import javax.servlet.http.HttpServletResponse;
22:
23: /**
24: * A Marshaller is responsible for all the on-the-wire communication between
25: * DWR on the server and the HTTP channel. engine.js does the corresponding
26: * work on the Javascript side.
27: * @author Joe Walker [joe at getahead dot ltd dot uk]
28: */
29: public interface Marshaller {
30: /**
31: * Marshall an incomming HttpRequest into an abstract Calls POJO that
32: * defines the functions that we need to call.
33: * @param request The incoming Http request
34: * @param response An Ajax response, XML, JSON, Javascript, etc.
35: * @return Data specifying the methods to call
36: * @throws IOException If the connection breaks
37: * @throws ServerException If an error occurs during parsing
38: */
39: Calls marshallInbound(HttpServletRequest request,
40: HttpServletResponse response) throws IOException,
41: ServerException;
42:
43: /**
44: * Marshall the return values from executing this batch of requests.
45: * @param replies The objects to convert into a reply
46: * @param request The incoming Http request
47: * @param response An Ajax response, XML, JSON, Javascript, etc.
48: * @throws IOException If the connection breaks
49: */
50: void marshallOutbound(Replies replies, HttpServletRequest request,
51: HttpServletResponse response) throws IOException;
52:
53: /**
54: * Try to find a batchId to send to the client so it knows what broke
55: * @param request The incoming Http request
56: * @param response An Ajax response, XML, JSON, Javascript, etc.
57: * @param ex The exception that we wish to propogate to the client
58: * @throws IOException If writing to the output stream fails
59: */
60: void marshallException(HttpServletRequest request,
61: HttpServletResponse response, Exception ex)
62: throws IOException;
63:
64: /**
65: * Check if we can coerce the given type
66: * @param paramType The type to check
67: * @return true iff <code>paramType</code> is coercable
68: */
69: boolean isConvertable(Class<?> paramType);
70: }
|