com.opencms.flex.cache
Class CmsFlexResponse

java.lang.Object
  |
  +--javax.servlet.ServletResponseWrapper
        |
        +--javax.servlet.http.HttpServletResponseWrapper
              |
              +--com.opencms.flex.cache.CmsFlexResponse
All Implemented Interfaces:
javax.servlet.http.HttpServletResponse, javax.servlet.ServletResponse

public class CmsFlexResponse
extends javax.servlet.http.HttpServletResponseWrapper

Wrapper class for a HttpServletResponse.

This class wrapps the standard HttpServletResponse so that it's output can be delivered to the CmsFlexCache.

Version:
$Revision: 1.16.2.1 $
Author:
Alexander Kandzior (a.kandzior@alkacon.com)

Field Summary
static char C_FLEX_CACHE_DELIMITER
          The cache delimiter char
static String C_SETHEADER
          Static string to indicate a header is "set" in the header maps
 
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_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
CmsFlexResponse(javax.servlet.http.HttpServletResponse res, CmsFlexController controller)
          Constructor for the CmsFlexResponse, this variation one is usually used to wrap responses for further include calls in OpenCms.
CmsFlexResponse(javax.servlet.http.HttpServletResponse res, CmsFlexController controller, boolean streaming, boolean isTopElement)
          Constructor for the CmsFlexResponse, this variation is usually used for the "Top" response.
 
Method Summary
 void addDateHeader(String name, long date)
          Method overlodad from the standard HttpServletRequest API.
 void addHeader(String name, String value)
          Method overlodad from the standard HttpServletRequest API.
 void addIntHeader(String name, int value)
          Method overlodad from the standard HttpServletRequest API.
 void addToIncludeList(String target, Map parameterMap)
          Adds an inclusion target to the list of include results.
 String getEncoding()
          Returns the value of the encoding used for this response.
 Map getHeaders()
          Provides access to the header cache of the top wrapper.
 javax.servlet.ServletOutputStream getOutputStream()
          Method overlodad from the standard HttpServletRequest API.
 PrintWriter getWriter()
          Method overlodad from the standard HttpServletRequest API.
 byte[] getWriterBytes()
          Returns the bytes that have been written on the current writers output stream.
 boolean isSuspended()
          This flag indicates if the response is suspended or not.
 boolean isTopElement()
          Returns true if this response has been constructed for the top level element of this request, false if it was constructed for an included sub-element.
static void processHeaders(Map headers, javax.servlet.http.HttpServletResponse res)
          Process the headers stored in the provided map and add them to the response.
 void sendRedirect(String location)
          Method overlodad from the standard HttpServletRequest API.
 void setContentType(String type)
          Method overlodad from the standard HttpServletRequest API.
 void setDateHeader(String name, long date)
          Method overlodad from the standard HttpServletRequest API.
 void setHeader(String name, String value)
          Method overlodad from the standard HttpServletRequest API.
 void setIntHeader(String name, int value)
          Method overlodad from the standard HttpServletRequest API.
 void setOnlyBuffering(boolean value)
          Sets buffering status of the response.
 
Methods inherited from class javax.servlet.http.HttpServletResponseWrapper
addCookie, containsHeader, encodeRedirectUrl, encodeRedirectURL, encodeUrl, encodeURL, sendError, sendError, setStatus, setStatus
 
Methods inherited from class javax.servlet.ServletResponseWrapper
flushBuffer, getBufferSize, getCharacterEncoding, getLocale, getResponse, isCommitted, reset, resetBuffer, setBufferSize, setContentLength, setLocale, setResponse
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.servlet.ServletResponse
flushBuffer, getBufferSize, getCharacterEncoding, getLocale, isCommitted, reset, resetBuffer, setBufferSize, setContentLength, setLocale
 

Field Detail

C_SETHEADER

public static final String C_SETHEADER
Static string to indicate a header is "set" in the header maps

See Also:
Constant Field Values

C_FLEX_CACHE_DELIMITER

public static final char C_FLEX_CACHE_DELIMITER
The cache delimiter char

See Also:
Constant Field Values
Constructor Detail

CmsFlexResponse

public CmsFlexResponse(javax.servlet.http.HttpServletResponse res,
                       CmsFlexController controller,
                       boolean streaming,
                       boolean isTopElement)
Constructor for the CmsFlexResponse, this variation is usually used for the "Top" response.

Parameters:
res - the HttpServletResponse to wrap
controller - the controller to use
streaming - indicates if streaming should be enabled or not
isTopElement - indicates if this is the top element of an include cascade

CmsFlexResponse

public CmsFlexResponse(javax.servlet.http.HttpServletResponse res,
                       CmsFlexController controller)
Constructor for the CmsFlexResponse, this variation one is usually used to wrap responses for further include calls in OpenCms.

Parameters:
res - the CmsFlexResponse to wrap
controller - the controller to use
Method Detail

getEncoding

public String getEncoding()
Returns the value of the encoding used for this response.

Returns:
the value of the encoding used for this response

isTopElement

public boolean isTopElement()
Returns true if this response has been constructed for the top level element of this request, false if it was constructed for an included sub-element.

Returns:
true if this response has been constructed for the top level element of this request, false if it was constructed for an included sub-element.

setOnlyBuffering

public void setOnlyBuffering(boolean value)
Sets buffering status of the response.

This must be done before the first output is written. Buffering is needed to process elements that can not be written directly to the output stream because their sub - elements have to be processed seperatly. Which is so far true only for JSP pages.

If buffering is on, nothing is written to the output stream even if streaming for this resonse is enabled.

Parameters:
value - the value to set

isSuspended

public boolean isSuspended()
This flag indicates if the response is suspended or not.

A suspended response mut not write further output to any stream or process a cache entry for itself.

Currently, a response is only suspended if it is redirected.

Returns:
true if the response is suspended, false otherwise

getHeaders

public Map getHeaders()
Provides access to the header cache of the top wrapper.

Returns:
the Map of cached headers

addToIncludeList

public void addToIncludeList(String target,
                             Map parameterMap)
Adds an inclusion target to the list of include results.

Should be used only in inclusion-scenarios like the JSP cms:include tag processing.

Parameters:
target - the include target name to add

getWriterBytes

public byte[] getWriterBytes()
Returns the bytes that have been written on the current writers output stream.

Returns:
the bytes that have been written on the current writers output stream

getWriter

public PrintWriter getWriter()
                      throws IOException
Method overlodad from the standard HttpServletRequest API.

Specified by:
getWriter in interface javax.servlet.ServletResponse
Overrides:
getWriter in class javax.servlet.ServletResponseWrapper
IOException
See Also:
ServletResponse.getWriter()

getOutputStream

public javax.servlet.ServletOutputStream getOutputStream()
                                                  throws IOException
Method overlodad from the standard HttpServletRequest API.

Specified by:
getOutputStream in interface javax.servlet.ServletResponse
Overrides:
getOutputStream in class javax.servlet.ServletResponseWrapper
IOException
See Also:
ServletResponse.getOutputStream()

sendRedirect

public void sendRedirect(String location)
                  throws IOException
Method overlodad from the standard HttpServletRequest API.

Specified by:
sendRedirect in interface javax.servlet.http.HttpServletResponse
Overrides:
sendRedirect in class javax.servlet.http.HttpServletResponseWrapper
IOException
See Also:
HttpServletResponse.sendRedirect(java.lang.String)

processHeaders

public static void processHeaders(Map headers,
                                  javax.servlet.http.HttpServletResponse res)
Process the headers stored in the provided map and add them to the response.

Parameters:
headers - the headers to add
res - the resonse to add the headers to

setHeader

public void setHeader(String name,
                      String value)
Method overlodad from the standard HttpServletRequest API.

Specified by:
setHeader in interface javax.servlet.http.HttpServletResponse
Overrides:
setHeader in class javax.servlet.http.HttpServletResponseWrapper
See Also:
HttpServletResponse.setHeader(java.lang.String, java.lang.String)

addHeader

public void addHeader(String name,
                      String value)
Method overlodad from the standard HttpServletRequest API.

Specified by:
addHeader in interface javax.servlet.http.HttpServletResponse
Overrides:
addHeader in class javax.servlet.http.HttpServletResponseWrapper
See Also:
HttpServletResponse.addHeader(java.lang.String, java.lang.String)

setDateHeader

public void setDateHeader(String name,
                          long date)
Method overlodad from the standard HttpServletRequest API.

Specified by:
setDateHeader in interface javax.servlet.http.HttpServletResponse
Overrides:
setDateHeader in class javax.servlet.http.HttpServletResponseWrapper
See Also:
HttpServletResponse.setDateHeader(java.lang.String, long)

addDateHeader

public void addDateHeader(String name,
                          long date)
Method overlodad from the standard HttpServletRequest API.

Specified by:
addDateHeader in interface javax.servlet.http.HttpServletResponse
Overrides:
addDateHeader in class javax.servlet.http.HttpServletResponseWrapper
See Also:
HttpServletResponse.addDateHeader(java.lang.String, long)

setIntHeader

public void setIntHeader(String name,
                         int value)
Method overlodad from the standard HttpServletRequest API.

Specified by:
setIntHeader in interface javax.servlet.http.HttpServletResponse
Overrides:
setIntHeader in class javax.servlet.http.HttpServletResponseWrapper
See Also:
HttpServletResponse.setIntHeader(java.lang.String, int)

addIntHeader

public void addIntHeader(String name,
                         int value)
Method overlodad from the standard HttpServletRequest API.

Specified by:
addIntHeader in interface javax.servlet.http.HttpServletResponse
Overrides:
addIntHeader in class javax.servlet.http.HttpServletResponseWrapper
See Also:
HttpServletResponse.addIntHeader(java.lang.String, int)

setContentType

public void setContentType(String type)
Method overlodad from the standard HttpServletRequest API.

Specified by:
setContentType in interface javax.servlet.ServletResponse
Overrides:
setContentType in class javax.servlet.ServletResponseWrapper
See Also:
ServletResponse.setContentType(java.lang.String)