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.servlet;
17:
18: import java.io.IOException;
19:
20: import javax.servlet.http.HttpServletRequest;
21: import javax.servlet.http.HttpServletResponse;
22:
23: import org.directwebremoting.dwrp.HtmlCallMarshaller;
24: import org.directwebremoting.extend.Calls;
25: import org.directwebremoting.extend.Handler;
26: import org.directwebremoting.extend.Remoter;
27: import org.directwebremoting.extend.Replies;
28:
29: /**
30: * A Handler standard DWR calls whose replies are HTML wrapped.
31: * @author Joe Walker [joe at getahead dot ltd dot uk]
32: */
33: public class HtmlCallHandler implements Handler {
34: /* (non-Javadoc)
35: * @see org.directwebremoting.Handler#handle(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
36: */
37: public void handle(HttpServletRequest request,
38: HttpServletResponse response) throws IOException {
39: Calls calls;
40:
41: try {
42: calls = htmlCallMarshaller.marshallInbound(request,
43: response);
44: } catch (Exception ex) {
45: htmlCallMarshaller.marshallException(request, response, ex);
46: return;
47: }
48:
49: Replies replies = remoter.execute(calls);
50: htmlCallMarshaller.marshallOutbound(replies, request, response);
51: }
52:
53: /**
54: * Setter for the HTML Javascript Marshaller
55: * @param htmlCallMarshaller The new marshaller
56: */
57: public void setHtmlCallMarshaller(
58: HtmlCallMarshaller htmlCallMarshaller) {
59: this .htmlCallMarshaller = htmlCallMarshaller;
60: }
61:
62: /**
63: * Setter for the remoter
64: * @param remoter The new remoter
65: */
66: public void setRemoter(Remoter remoter) {
67: this .remoter = remoter;
68: }
69:
70: /**
71: * The 'Plain Javascript' method by which objects are marshalled
72: */
73: protected HtmlCallMarshaller htmlCallMarshaller = null;
74:
75: /**
76: * The bean to execute remote requests and generate interfaces
77: */
78: protected Remoter remoter = null;
79: }
|