KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > directwebremoting > dwrp > PlainCallMarshaller


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.dwrp;
17
18 import java.io.IOException JavaDoc;
19 import java.io.PrintWriter JavaDoc;
20
21 import org.directwebremoting.extend.DwrConstants;
22 import org.directwebremoting.util.MimeConstants;
23
24 /**
25  * A Marshaller that outputs plain Javascript.
26  * @author Joe Walker [joe at getahead dot ltd dot uk]
27  */

28 public class PlainCallMarshaller extends BaseCallMarshaller
29 {
30     /* (non-Javadoc)
31      * @see org.directwebremoting.dwrp.BaseCallMarshaller#getOutboundMimeType()
32      */

33     protected String JavaDoc getOutboundMimeType()
34     {
35         return MimeConstants.MIME_JS;
36     }
37
38     /* (non-Javadoc)
39      * @see org.directwebremoting.dwrp.BaseCallMarshaller#sendOutboundScriptPrefix(java.io.PrintWriter, java.lang.String)
40      */

41     protected void sendOutboundScriptPrefix(PrintWriter JavaDoc out, String JavaDoc batchId) throws IOException JavaDoc
42     {
43         if (allowScriptTagRemoting)
44         {
45             synchronized (out)
46             {
47                 out.println(scriptTagProtection);
48             }
49         }
50     }
51
52     /* (non-Javadoc)
53      * @see org.directwebremoting.dwrp.BaseCallMarshaller#sendOutboundScriptSuffix(java.io.PrintWriter, java.lang.String)
54      */

55     protected void sendOutboundScriptSuffix(PrintWriter JavaDoc out, String JavaDoc batchId) throws IOException JavaDoc
56     {
57     }
58
59     /* (non-Javadoc)
60      * @see org.directwebremoting.dwrp.BaseCallMarshaller#sendScript(java.io.PrintWriter, java.lang.String)
61      */

62     protected void sendScript(PrintWriter JavaDoc out, String JavaDoc script) throws IOException JavaDoc
63     {
64         synchronized (out)
65         {
66             out.println(script);
67         }
68     }
69
70     /**
71      * Do we allow ScriptTag remoting?
72      * @param allowScriptTagRemoting The new value to set
73      */

74     public void setAllowScriptTagRemoting(boolean allowScriptTagRemoting)
75     {
76         this.allowScriptTagRemoting = allowScriptTagRemoting;
77     }
78
79     /**
80      * Do we allow ScriptTag remoting.
81      */

82     private boolean allowScriptTagRemoting = false;
83
84     /**
85      * What is the string we use for script tag hack protection
86      * @param scriptTagProtection the scriptTagProtection to set
87      */

88     public void setScriptTagProtection(String JavaDoc scriptTagProtection)
89     {
90         this.scriptTagProtection = scriptTagProtection;
91     }
92
93     /**
94      * What is the string we use for script tag hack protection
95      */

96     private String JavaDoc scriptTagProtection = DwrConstants.SCRIPT_TAG_PROTECTION;
97 }
98
Popular Tags