Source Code Cross Referenced for JspResponseWrapper.java in  » EJB-Server-resin-3.1.5 » resin » com » caucho » jsf » context » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » EJB Server resin 3.1.5 » resin » com.caucho.jsf.context 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003:         *
004:         * This file is part of Resin(R) Open Source
005:         *
006:         * Each copy or derived work must preserve the copyright notice and this
007:         * notice unmodified.
008:         *
009:         * Resin Open Source is free software; you can redistribute it and/or modify
010:         * it under the terms of the GNU General Public License version 2
011:         * as published by the Free Software Foundation.
012:         *
013:         * Resin Open Source is distributed in the hope that it will be useful,
014:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
015:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
016:         * of NON-INFRINGEMENT.  See the GNU General Public License for more
017:         * details.
018:         *
019:         * You should have received a copy of the GNU General Public License
020:         * along with Resin Open Source; if not, write to the
021:         *
022:         *   Free Software Foundation, Inc.
023:         *   59 Temple Place, Suite 330
024:         *   Boston, MA 02111-1307  USA
025:         *
026:         * @author Scott Ferguson
027:         */
028:
029:        package com.caucho.jsf.context;
030:
031:        import javax.servlet.*;
032:        import javax.servlet.http.*;
033:
034:        import java.io.*;
035:        import java.util.*;
036:        import java.util.logging.*;
037:
038:        import com.caucho.filters.*;
039:        import com.caucho.util.*;
040:        import com.caucho.vfs.*;
041:        import com.caucho.jsp.*;
042:        import com.caucho.server.connection.*;
043:
044:        public class JspResponseWrapper extends ResponseWrapper implements 
045:                CauchoResponse {
046:            private static final Logger log = Logger
047:                    .getLogger(JspResponseWrapper.class.getName());
048:            private static final L10N L = new L10N(JspResponseWrapper.class);
049:
050:            private boolean _hasError;
051:            private BodyResponseStream _bodyStream;
052:            private AbstractResponseStream _stream;
053:
054:            private HttpServletResponse _response;
055:
056:            private TempStream _tempStream = new TempStream();
057:            private WriteStream _out;
058:
059:            private FlushBuffer _flushBuffer;
060:
061:            private ResponseWriter _writer = new ResponseWriter();
062:            private ServletOutputStreamImpl _os = new ServletOutputStreamImpl();
063:
064:            /**
065:             * Initialize the response.
066:             */
067:            public void init(HttpServletResponse response) {
068:                _bodyStream = new BodyResponseStream();
069:                _stream = _bodyStream;
070:
071:                _out = new WriteStream(_tempStream);
072:                _bodyStream.setWriter(_out.getPrintWriter());
073:
074:                setResponse(response);
075:                _response = response;
076:
077:                _os.init(_stream);
078:                _writer.init(_stream);
079:
080:                _hasError = false;
081:            }
082:
083:            /**
084:             * Sets the ResponseStream
085:             */
086:            public void setResponseStream(AbstractResponseStream stream) {
087:                try {
088:                    _stream.flushBuffer();
089:                } catch (IOException e) {
090:                    log.log(Level.FINER, e.toString(), e);
091:                }
092:
093:                _stream = stream;
094:
095:                _os.init(stream);
096:                _writer.init(stream);
097:            }
098:
099:            /**
100:             * Gets the response stream.
101:             */
102:            public AbstractResponseStream getResponseStream() {
103:                return _stream;
104:            }
105:
106:            /**
107:             * Returns true for a caucho response stream.
108:             */
109:            public boolean isCauchoResponseStream() {
110:                return true;
111:            }
112:
113:            /**
114:             * Returns the servlet output stream.
115:             */
116:            public ServletOutputStream getOutputStream() throws IOException {
117:                return _os;
118:            }
119:
120:            /**
121:             * Returns the print writer.
122:             */
123:            public PrintWriter getWriter() throws IOException {
124:                return _writer;
125:            }
126:
127:            /**
128:             * Returns the output stream for this wrapper.
129:             */
130:            protected OutputStream getStream() throws IOException {
131:                return _response.getOutputStream();
132:            }
133:
134:            /**
135:             * Sets the flush buffer
136:             */
137:            public void setFlushBuffer(FlushBuffer flushBuffer) {
138:                _flushBuffer = flushBuffer;
139:            }
140:
141:            /**
142:             * Gets the flush buffer
143:             */
144:            public FlushBuffer getFlushBuffer() {
145:                return _flushBuffer;
146:            }
147:
148:            public void flushBuffer() throws IOException {
149:                //if (_flushBuffer != null)
150:                //   _flushBuffer.flushBuffer();
151:
152:                //_stream.flushBuffer();
153:
154:                //_response.flushBuffer();
155:            }
156:
157:            public void resetBuffer() {
158:                if (_stream != null)
159:                    _stream.clearBuffer();
160:            }
161:
162:            public void clearBuffer() {
163:                resetBuffer();
164:            }
165:
166:            public void setLocale(Locale locale) {
167:                _response.setLocale(locale);
168:
169:                try {
170:                    _stream.setLocale(_response.getLocale());
171:                } catch (UnsupportedEncodingException e) {
172:                }
173:            }
174:
175:            /*
176:             * caucho
177:             */
178:
179:            public String getHeader(String key) {
180:                return null;
181:            }
182:
183:            public boolean disableHeaders(boolean disable) {
184:                return false;
185:            }
186:
187:            public int getRemaining() {
188:                /*
189:                if (_response instanceof CauchoResponse)
190:                  return ((CauchoResponse) _response).getRemaining();
191:                else
192:                  return 0;
193:                 */
194:                return _stream.getRemaining();
195:            }
196:
197:            /**
198:             * When set to true, RequestDispatcher.forward() is disallowed on
199:             * this stream.
200:             */
201:            public void setForbidForward(boolean forbid) {
202:            }
203:
204:            /**
205:             * Returns true if RequestDispatcher.forward() is disallowed on
206:             * this stream.
207:             */
208:            public boolean getForbidForward() {
209:                return false;
210:            }
211:
212:            /**
213:             * Set to true while processing an error.
214:             */
215:            public void setHasError(boolean hasError) {
216:                _hasError = hasError;
217:            }
218:
219:            /**
220:             * Returns true if we're processing an error.
221:             */
222:            public boolean hasError() {
223:                return _hasError;
224:            }
225:
226:            /**
227:             * Kills the cache for an error.
228:             */
229:            public void killCache() {
230:            }
231:
232:            public void setSessionId(String id) {
233:
234:            }
235:
236:            public void setPrivateCache(boolean isPrivate) {
237:            }
238:
239:            public void setNoCache(boolean isPrivate) {
240:            }
241:
242:            /**
243:             * complete the response.
244:             */
245:            public void close() throws IOException {
246:                WriteStream out = _out;
247:                _out = null;
248:
249:                if (out != null)
250:                    out.close();
251:            }
252:
253:            public void flushResponse() throws IOException {
254:                _out.flush();
255:
256:                ReadStream rs = _tempStream.openRead();
257:                PrintWriter out = _response.getWriter();
258:
259:                int ch;
260:
261:                while ((ch = rs.readChar()) >= 0)
262:                    out.write((char) ch);
263:
264:                rs.close();
265:            }
266:
267:            public String complete() throws IOException {
268:                WriteStream out = _out;
269:                _out = null;
270:
271:                if (out != null)
272:                    out.flush();
273:
274:                ReadStream rs = _tempStream.openRead();
275:                StringBuilder sb = new StringBuilder();
276:
277:                int ch;
278:
279:                while ((ch = rs.readChar()) >= 0)
280:                    sb.append((char) ch);
281:
282:                rs.close();
283:
284:                return sb.toString();
285:            }
286:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.