KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > portal > generic > context > TopLevelResponseHandler


1 /*
2  * The Apache Software License, Version 1.1
3  *
4  * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in
15  * the documentation and/or other materials provided with the
16  * distribution.
17  *
18  * 3. The end-user documentation included with the redistribution, if
19  * any, must include the following acknowlegement:
20  * "This product includes software developed by the
21  * Caucho Technology (http://www.caucho.com/)."
22  * Alternately, this acknowlegement may appear in the software itself,
23  * if and wherever such third-party acknowlegements normally appear.
24  *
25  * 4. The names "Hessian", "Resin", and "Caucho" must not be used to
26  * endorse or promote products derived from this software without prior
27  * written permission. For written permission, please contact
28  * info@caucho.com.
29  *
30  * 5. Products derived from this software may not be called "Resin"
31  * nor may "Resin" appear in their names without prior written
32  * permission of Caucho Technology.
33  *
34  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
35  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
36  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
37  * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS
38  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
39  * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
40  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
41  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
42  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
43  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
44  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
45  *
46  * @author Sam
47  */

48
49
50 package com.caucho.portal.generic.context;
51
52 import com.caucho.portal.generic.PortletConnection;
53
54 import java.io.IOException JavaDoc;
55 import java.io.OutputStream JavaDoc;
56 import java.io.PrintWriter JavaDoc;
57 import java.io.UnsupportedEncodingException JavaDoc;
58 import java.util.Locale JavaDoc;
59
60 /**
61  * A ResponseHandler that writes out to the connection.
62  */

63 class TopLevelResponseHandler implements ResponseHandler
64 {
65   private PortletConnection _connection;
66   private ConnectionContext _context;
67
68   public TopLevelResponseHandler( PortletConnection connection,
69                                   ConnectionContext context )
70   {
71     _connection = connection;
72     _context = context;
73   }
74
75   public void finish()
76     throws IOException JavaDoc
77   {
78   }
79
80   public ResponseHandler getSuccessor()
81   {
82     return null;
83   }
84
85   /**
86    * Set a property to be returned to the client.
87    *
88    * "properties" correspond to HTTP headers in the response for HTTP
89    * connections.
90    *
91    * Properties that begin with "Cache-" or not sent to the
92    * connection.
93    *
94    * @see javax.portlet.PortletResponse#setProperty
95    */

96   public void setProperty(String JavaDoc name, String JavaDoc value)
97   {
98     if (!name.startsWith("Cache-"))
99       _connection.setProperty(name, value);
100   }
101
102   /**
103    * Add a value to a property to be returned to the client.
104    *
105    * "properties" correspond to HTTP headers in the response for HTTP
106    * connections.
107    *
108    * Properties that begin with "Cache-" or not sent to the
109    * connection.
110    *
111    * @see javax.portlet.PortletResponse#addProperty
112    */

113   public void addProperty(String JavaDoc name, String JavaDoc value)
114   {
115     if (!name.startsWith("Cache-"))
116       _connection.addProperty(name, value);
117   }
118
119   public void setLocale(Locale JavaDoc locale)
120   {
121     _connection.setLocale(locale);
122   }
123
124   public Locale JavaDoc getLocale()
125   {
126     return _connection.getLocale();
127   }
128
129   public void setContentType(String JavaDoc contentType)
130   {
131     _connection.setContentType(contentType);
132   }
133
134   public String JavaDoc getContentType()
135   {
136     return _connection.getContentType();
137   }
138
139   public void setBufferSize(int size)
140   {
141     _connection.setBufferSize(size);
142   }
143
144   public int getBufferSize()
145   {
146     return _connection.getBufferSize();
147   }
148
149   public void flushBuffer()
150     throws IOException JavaDoc
151   {
152     _connection.flushBuffer();
153   }
154
155   public void resetBuffer()
156   {
157     _connection.resetBuffer();
158   }
159
160   public void reset()
161   {
162     _connection.reset();
163   }
164
165   public boolean isCommitted()
166   {
167     return _connection.isCommitted();
168   }
169
170   public void setCharacterEncoding(String JavaDoc enc)
171     throws UnsupportedEncodingException JavaDoc
172   {
173     _connection.setCharacterEncoding(enc);
174   }
175
176   /**
177    * Get the character encoding of the writer.
178    */

179   public String JavaDoc getCharacterEncoding()
180   {
181     return _connection.getCharacterEncoding();
182   }
183
184   /**
185    * Get a writer that sends output to the client of the connection.
186    */

187   public PrintWriter JavaDoc getWriter()
188     throws IOException JavaDoc
189   {
190     return _connection.getWriter();
191   }
192
193   public OutputStream JavaDoc getOutputStream()
194     throws IOException JavaDoc
195   {
196     return _connection.getOutputStream();
197   }
198 }
199
Popular Tags