KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > directwebremoting > servlet > HtmlCallHandler


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.servlet;
17
18 import java.io.IOException JavaDoc;
19
20 import javax.servlet.http.HttpServletRequest JavaDoc;
21 import javax.servlet.http.HttpServletResponse JavaDoc;
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 {
35     /* (non-Javadoc)
36      * @see org.directwebremoting.Handler#handle(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
37      */

38     public void handle(HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response) throws IOException JavaDoc
39     {
40         Calls calls = null;
41
42         try
43         {
44             calls = htmlCallMarshaller.marshallInbound(request, response);
45         }
46         catch (Exception JavaDoc ex)
47         {
48             htmlCallMarshaller.marshallException(request, response, ex);
49             return;
50         }
51
52         Replies replies = remoter.execute(calls);
53         htmlCallMarshaller.marshallOutbound(replies, request, response);
54     }
55
56     /**
57      * Setter for the HTML Javascript Marshaller
58      * @param marshaller The new marshaller
59      */

60     public void setHtmlCallMarshaller(HtmlCallMarshaller marshaller)
61     {
62         this.htmlCallMarshaller = marshaller;
63     }
64
65     /**
66      * Setter for the remoter
67      * @param remoter
68      */

69     public void setRemoter(Remoter remoter)
70     {
71         this.remoter = remoter;
72     }
73
74     /**
75      * The 'Plain Javascript' method by which objects are marshalled
76      */

77     protected HtmlCallMarshaller htmlCallMarshaller = null;
78
79     /**
80      * The bean to execute remote requests and generate interfaces
81      */

82     protected Remoter remoter = null;
83 }
84
Popular Tags