com.caucho.filters
Class CauchoResponseWrapper

java.lang.Object
  extended by com.caucho.server.http.ResponseWrapper
      extended by com.caucho.filters.CauchoResponseWrapper
All Implemented Interfaces:
CauchoResponse, HttpServletResponse, ServletResponse

public class CauchoResponseWrapper
extends ResponseWrapper
implements CauchoResponse

Response wrapper that can take advantage of Resin's streams.


Field Summary
protected  AbstractResponseStream _stream
           
 
Fields inherited from class com.caucho.server.http.ResponseWrapper
_response
 
Fields inherited from interface javax.servlet.http.HttpServletResponse
SC_ACCEPTED, SC_BAD_GATEWAY, SC_BAD_REQUEST, SC_CONFLICT, SC_CONTINUE, SC_CREATED, SC_EXPECTATION_FAILED, SC_FORBIDDEN, SC_FOUND, SC_GATEWAY_TIMEOUT, SC_GONE, SC_HTTP_VERSION_NOT_SUPPORTED, SC_INTERNAL_SERVER_ERROR, SC_LENGTH_REQUIRED, SC_METHOD_NOT_ALLOWED, SC_MOVED_PERMANENTLY, SC_MOVED_TEMPORARILY, SC_MULTIPLE_CHOICES, SC_NO_CONTENT, SC_NON_AUTHORITATIVE_INFORMATION, SC_NOT_ACCEPTABLE, SC_NOT_FOUND, SC_NOT_IMPLEMENTED, SC_NOT_MODIFIED, SC_OK, SC_PARTIAL_CONTENT, SC_PAYMENT_REQUIRED, SC_PRECONDITION_FAILED, SC_PROXY_AUTHENTICATION_REQUIRED, SC_REQUEST_ENTITY_TOO_LARGE, SC_REQUEST_TIMEOUT, SC_REQUEST_URI_TOO_LONG, SC_REQUESTED_RANGE_NOT_SATISFIABLE, SC_RESET_CONTENT, SC_SEE_OTHER, SC_SERVICE_UNAVAILABLE, SC_SWITCHING_PROTOCOLS, SC_TEMPORARY_REDIRECT, SC_UNAUTHORIZED, SC_UNSUPPORTED_MEDIA_TYPE, SC_USE_PROXY
 
Constructor Summary
CauchoResponseWrapper()
           
CauchoResponseWrapper(HttpServletResponse response)
           
 
Method Summary
 void addFooter(java.lang.String key, java.lang.String value)
           
 void clearBuffer()
           
 void close()
          complete the response.
 void completeCache()
           
 boolean disableHeaders(boolean disable)
           
 void flushBuffer()
          Flushes the buffer to the client.
 FlushBuffer getFlushBuffer()
          Gets the flush buffer
 boolean getForbidForward()
          Returns true if RequestDispatcher.forward() is disallowed on this stream.
 java.lang.String getHeader(java.lang.String key)
          Retuns value of header with a given name
 java.util.Collection<java.lang.String> getHeaderNames()
          Returns an Iterable for header names set via HttpServletResponse.setHeader(java.lang.String, java.lang.String), HttpServletResponse.addHeader(java.lang.String, java.lang.String), HttpServletResponse.setDateHeader(java.lang.String, long), HttpServletResponse.addDateHeader(java.lang.String, long), HttpServletResponse.setIntHeader(java.lang.String, int), or HttpServletResponse.addIntHeader(java.lang.String, int), respectively.
 java.util.Collection<java.lang.String> getHeaders(java.lang.String name)
          Returns an Iterable for header values with a given name
 ServletOutputStream getOutputStream()
          Returns the servlet output stream.
 int getRemaining()
           
 ServletResponse getResponse()
          Gets the wrapped response
 AbstractResponseStream getResponseStream()
          Gets the response stream.
 int getStatus()
          Returns the current status code of this response
 java.lang.String getStatusMessage()
           
protected  java.io.OutputStream getStream()
          Returns the output stream for this wrapper.
 java.io.PrintWriter getWriter()
          Returns the print writer.
 boolean hasError()
          Returns true if we're processing an error.
 void init(HttpServletResponse response)
          Initialize the response.
 boolean isCauchoResponseStream()
          Returns true for a caucho response stream.
 boolean isForwardEnclosed()
           
 boolean isNoCacheUnlessVary()
           
 void killCache()
          Kills the cache for an error.
 void reset()
          Resets the output stream, clearing headers and the output buffer.
 void resetBuffer()
          Resets the output stream without clearing headers and the output buffer.
 void setContentType(java.lang.String value)
          Sets the response content type.
 void setFlushBuffer(FlushBuffer flushBuffer)
          Sets the flush buffer
 void setFooter(java.lang.String key, java.lang.String value)
           
 void setForbidForward(boolean forbid)
          When set to true, RequestDispatcher.forward() is disallowed on this stream.
 void setForwardEnclosed(boolean isForwardEnclosed)
           
 void setHasError(boolean hasError)
          Set to true while processing an error.
 void setLocale(java.util.Locale locale)
          Sets the output locale.
 void setNoCache(boolean isPrivate)
           
 void setPrivateCache(boolean isPrivate)
           
 void setResponseStream(AbstractResponseStream stream)
          Sets the ResponseStream
 void setSessionId(java.lang.String id)
           
 void writeHeaders(int length)
           
 
Methods inherited from class com.caucho.server.http.ResponseWrapper
addCookie, addDateHeader, addHeader, addIntHeader, containsHeader, disable, enable, encodeRedirectUrl, encodeRedirectURL, encodeUrl, encodeURL, getAbstractHttpResponse, getBufferSize, getCharacterEncoding, getContentType, getLocale, isCommitted, isDisabled, sendError, sendError, sendRedirect, setBufferSize, setCacheInvocation, setCharacterEncoding, setContentLength, setDateHeader, setHeader, setIntHeader, setMatchCacheEntry, setResponse, setStatus, setStatus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.caucho.server.http.CauchoResponse
getAbstractHttpResponse, setCacheInvocation
 
Methods inherited from interface javax.servlet.http.HttpServletResponse
addCookie, addDateHeader, addHeader, addIntHeader, containsHeader, encodeRedirectUrl, encodeRedirectURL, encodeUrl, encodeURL, sendError, sendError, sendRedirect, setDateHeader, setHeader, setIntHeader, setStatus, setStatus
 
Methods inherited from interface javax.servlet.ServletResponse
getBufferSize, getCharacterEncoding, getContentType, getLocale, isCommitted, setBufferSize, setCharacterEncoding, setContentLength
 

Field Detail

_stream

protected AbstractResponseStream _stream
Constructor Detail

CauchoResponseWrapper

public CauchoResponseWrapper()

CauchoResponseWrapper

public CauchoResponseWrapper(HttpServletResponse response)
Method Detail

init

public void init(HttpServletResponse response)
Initialize the response.


close

public void close()
           throws java.io.IOException
complete the response.

Specified by:
close in interface CauchoResponse
Throws:
java.io.IOException

getResponse

public ServletResponse getResponse()
Description copied from class: ResponseWrapper
Gets the wrapped response

Specified by:
getResponse in interface CauchoResponse
Overrides:
getResponse in class ResponseWrapper
Returns:
the wrapped response

setContentType

public void setContentType(java.lang.String value)
Sets the response content type.

Specified by:
setContentType in interface ServletResponse
Overrides:
setContentType in class ResponseWrapper
Parameters:
value - the mime type of the output

setResponseStream

public void setResponseStream(AbstractResponseStream stream)
Sets the ResponseStream

Specified by:
setResponseStream in interface CauchoResponse

getResponseStream

public AbstractResponseStream getResponseStream()
Gets the response stream.

Specified by:
getResponseStream in interface CauchoResponse

isCauchoResponseStream

public boolean isCauchoResponseStream()
Returns true for a caucho response stream.

Specified by:
isCauchoResponseStream in interface CauchoResponse

getOutputStream

public ServletOutputStream getOutputStream()
                                    throws java.io.IOException
Returns the servlet output stream.

Specified by:
getOutputStream in interface ServletResponse
Overrides:
getOutputStream in class ResponseWrapper
Throws:
java.io.IOException

getWriter

public java.io.PrintWriter getWriter()
                              throws java.io.IOException
Returns the print writer.

Specified by:
getWriter in interface ServletResponse
Overrides:
getWriter in class ResponseWrapper
Throws:
java.io.IOException

getStream

protected java.io.OutputStream getStream()
                                  throws java.io.IOException
Returns the output stream for this wrapper.

Throws:
java.io.IOException

setFlushBuffer

public void setFlushBuffer(FlushBuffer flushBuffer)
Sets the flush buffer


getFlushBuffer

public FlushBuffer getFlushBuffer()
Gets the flush buffer


flushBuffer

public void flushBuffer()
                 throws java.io.IOException
Description copied from class: ResponseWrapper
Flushes the buffer to the client.

Specified by:
flushBuffer in interface ServletResponse
Overrides:
flushBuffer in class ResponseWrapper
Throws:
java.io.IOException

reset

public void reset()
Description copied from class: ResponseWrapper
Resets the output stream, clearing headers and the output buffer. Calling reset() after data has been committed is illegal.

Specified by:
reset in interface ServletResponse
Overrides:
reset in class ResponseWrapper

resetBuffer

public void resetBuffer()
Description copied from class: ResponseWrapper
Resets the output stream without clearing headers and the output buffer. Calling resetBuffer() after data has been committed is illegal.

Specified by:
resetBuffer in interface ServletResponse
Overrides:
resetBuffer in class ResponseWrapper

clearBuffer

public void clearBuffer()

setLocale

public void setLocale(java.util.Locale locale)
Description copied from class: ResponseWrapper
Sets the output locale. The response will set the character encoding based on the locale. For example, setting the "kr" locale will set the character encoding to "EUC_KR".

Specified by:
setLocale in interface ServletResponse
Overrides:
setLocale in class ResponseWrapper

getHeader

public java.lang.String getHeader(java.lang.String key)
Description copied from interface: HttpServletResponse
Retuns value of header with a given name

Specified by:
getHeader in interface CauchoResponse
Specified by:
getHeader in interface HttpServletResponse
Returns:

disableHeaders

public boolean disableHeaders(boolean disable)

setFooter

public void setFooter(java.lang.String key,
                      java.lang.String value)
Specified by:
setFooter in interface CauchoResponse
Overrides:
setFooter in class ResponseWrapper

addFooter

public void addFooter(java.lang.String key,
                      java.lang.String value)
Specified by:
addFooter in interface CauchoResponse
Overrides:
addFooter in class ResponseWrapper

getRemaining

public int getRemaining()

setForbidForward

public void setForbidForward(boolean forbid)
When set to true, RequestDispatcher.forward() is disallowed on this stream.

Specified by:
setForbidForward in interface CauchoResponse

getForbidForward

public boolean getForbidForward()
Returns true if RequestDispatcher.forward() is disallowed on this stream.

Specified by:
getForbidForward in interface CauchoResponse

getStatusMessage

public java.lang.String getStatusMessage()
Specified by:
getStatusMessage in interface CauchoResponse

setHasError

public void setHasError(boolean hasError)
Set to true while processing an error.

Specified by:
setHasError in interface CauchoResponse

hasError

public boolean hasError()
Returns true if we're processing an error.

Specified by:
hasError in interface CauchoResponse

killCache

public void killCache()
Kills the cache for an error.

Specified by:
killCache in interface CauchoResponse

completeCache

public void completeCache()
Specified by:
completeCache in interface CauchoResponse

setSessionId

public void setSessionId(java.lang.String id)
Specified by:
setSessionId in interface CauchoResponse

setPrivateCache

public void setPrivateCache(boolean isPrivate)
Specified by:
setPrivateCache in interface CauchoResponse

setNoCache

public void setNoCache(boolean isPrivate)
Specified by:
setNoCache in interface CauchoResponse

writeHeaders

public void writeHeaders(int length)
                  throws java.io.IOException
Specified by:
writeHeaders in interface CauchoResponse
Throws:
java.io.IOException

getStatus

public int getStatus()
Description copied from interface: HttpServletResponse
Returns the current status code of this response

Specified by:
getStatus in interface HttpServletResponse
Returns:

getHeaders

public java.util.Collection<java.lang.String> getHeaders(java.lang.String name)
Description copied from interface: HttpServletResponse
Returns an Iterable for header values with a given name

Specified by:
getHeaders in interface HttpServletResponse
Returns:

getHeaderNames

public java.util.Collection<java.lang.String> getHeaderNames()
Description copied from interface: HttpServletResponse
Returns an Iterable for header names set via HttpServletResponse.setHeader(java.lang.String, java.lang.String), HttpServletResponse.addHeader(java.lang.String, java.lang.String), HttpServletResponse.setDateHeader(java.lang.String, long), HttpServletResponse.addDateHeader(java.lang.String, long), HttpServletResponse.setIntHeader(java.lang.String, int), or HttpServletResponse.addIntHeader(java.lang.String, int), respectively.

Specified by:
getHeaderNames in interface HttpServletResponse
Returns:

setForwardEnclosed

public void setForwardEnclosed(boolean isForwardEnclosed)
Specified by:
setForwardEnclosed in interface CauchoResponse

isForwardEnclosed

public boolean isForwardEnclosed()
Specified by:
isForwardEnclosed in interface CauchoResponse

isNoCacheUnlessVary

public boolean isNoCacheUnlessVary()
Specified by:
isNoCacheUnlessVary in interface CauchoResponse