KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > directwebremoting > extend > Marshaller


1 /*
2  * Copyright 2005 Joe Walker
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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 JavaDoc;
19
20 import javax.servlet.http.HttpServletRequest JavaDoc;
21 import javax.servlet.http.HttpServletResponse JavaDoc;
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     /**
32      * Marshall an incomming HttpRequest into an abstract Calls POJO that
33      * defines the functions that we need to call.
34      * @param request The incoming Http request
35      * @param response An Ajax response, XML, JSON, Javascript, etc.
36      * @return Data specifying the methods to call
37      * @throws IOException If the connection breaks
38      * @throws ServerException If an error occurs during parsing
39      */

40     Calls marshallInbound(HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response) throws IOException JavaDoc, ServerException;
41
42     /**
43      * Marshall the return values from executing this batch of requests.
44      * @param replies The objects to convert into a reply
45      * @param request The incoming Http request
46      * @param response An Ajax response, XML, JSON, Javascript, etc.
47      * @throws IOException If the connection breaks
48      */

49     void marshallOutbound(Replies replies, HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response) throws IOException JavaDoc;
50
51     /**
52      * Try to find a batchId to send to the client so it knows what broke
53      * @param request The incoming Http request
54      * @param response An Ajax response, XML, JSON, Javascript, etc.
55      * @param ex The exception that we wish to propogate to the client
56      * @throws IOException If writing to the output stream fails
57      */

58     void marshallException(HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response, Exception JavaDoc ex) throws IOException JavaDoc;
59
60     /**
61      * Check if we can coerce the given type
62      * @param paramType The type to check
63      * @return true iff <code>paramType</code> is coercable
64      */

65     boolean isConvertable(Class JavaDoc paramType);
66 }
67
Popular Tags