|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.barracudamvc.core.helper.servlet.DeferredResponseWrapper
public class DeferredResponseWrapper
This class acts as a thin wrapper around a ServletResponse. By using this wrapper, the response is actually "absorbed" or "deferred", so that it can be manually extracted later.
Field Summary | |
---|---|
protected static org.apache.log4j.Logger |
logger
|
protected int |
pipeSize
|
protected int |
pipeTimeout
|
protected SimpleDateFormat |
sdf
|
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 | |
---|---|
DeferredResponseWrapper()
Create a DeferredResponseWrapper |
|
DeferredResponseWrapper(int ipipeSize,
int ipipeTimeout)
Create a DeferredResponseWrapper, specifying a pipe size and timeout |
Method Summary | |
---|---|
protected void |
_resetVars()
|
void |
actuallySendResponse(javax.servlet.http.HttpServletResponse resp)
Go ahead and actually write the response |
void |
addCookie(javax.servlet.http.Cookie cookie)
Adds the specified cookie to the response. |
void |
addDateHeader(String name,
long date)
Adds a response header with the given name and date-value. |
void |
addHeader(String name,
String value)
Adds a response header with the given name and value. |
void |
addIntHeader(String name,
int value)
Adds a response header with the given name and integer value. |
boolean |
containsHeader(String name)
Returns a boolean indicating whether the named response header has already been set. |
String |
encodeRedirectUrl(String url)
Deprecated. |
String |
encodeRedirectURL(String url)
Encodes the specified URL for use in the sendRedirect method or, if encoding is not needed, returns the URL unchanged. |
String |
encodeUrl(String url)
Deprecated. |
String |
encodeURL(String url)
Encodes the specified URL by including the session ID in it, or, if encoding is not needed, returns the URL unchanged. |
void |
flushBuffer()
Forces any content in the buffer to be written to the client. |
int |
getBufferSize()
Returns the actual buffer size used for the response. |
String |
getCharacterEncoding()
Returns the name of the charset used for the MIME body sent in this response. |
Locale |
getLocale()
Returns the locale assigned to the response. |
LongRunning |
getLongRunning()
|
Thread |
getLongRunningThread()
|
javax.servlet.ServletOutputStream |
getOutputStream()
Return the servlet output stream associated with this Response. |
static String |
getStatusMessage(int isc)
Returns a default status message for the specified HTTP status code. |
javax.servlet.http.HttpServletResponse |
getUnderlyingResponse()
|
PrintWriter |
getWriter()
Return the print writer associated with this Response (this method may be called multiple times). |
void |
interrupt()
|
boolean |
isCommitted()
Returns a boolean indicating if the response has been committed. |
boolean |
isInterrupted()
|
boolean |
isPaused()
Returns true if the object is paused |
boolean |
isReady()
|
static void |
main(String[] args)
simply for testing purposes |
void |
pause()
|
void |
reset()
Clears any data that exists in the buffer as well as the status code and headers. |
void |
resetBuffer()
Clears the content of the underlying buffer in the response without clearing headers or status code. |
void |
resume()
|
void |
sendError(int sc)
Sends an error response to the client using the specified status code and clearing the buffer. |
void |
sendError(int sc,
String msg)
Sends an error response to the client using the specified status clearing the buffer. |
void |
sendRedirect(String location)
Sends a temporary redirect response to the client using the specified redirect location URL. |
void |
setBufferSize(int size)
Sets the preferred buffer size for the body of the response. |
void |
setContentLength(int len)
Sets the length of the content body in the response In HTTP servlets, this method sets the HTTP Content-Length header. |
void |
setContentType(String type)
Sets the content type of the response being sent to the client. |
void |
setDateHeader(String name,
long date)
Sets a response header with the given name and date-value. |
void |
setHeader(String name,
String value)
Sets a response header with the given name and value. |
void |
setIntHeader(String name,
int value)
Sets a response header with the given name and integer value. |
void |
setLocale(Locale loc)
Sets the locale of the response, setting the headers (including the Content-Type's charset) as appropriate. |
void |
setLongRunning(LongRunning ilr)
|
void |
setLongRunningThread(Thread ith)
|
void |
setPipeSize(int ipipeSize)
|
void |
setPipeTimeout(int ipipeTimeout)
|
void |
setStatus(int isc)
Sets the status code for this response. |
void |
setStatus(int isc,
String ism)
Sets the status code for this response. |
void |
setUnderlyingResponse(javax.servlet.http.HttpServletResponse iuresp,
String ilrid)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final org.apache.log4j.Logger logger
protected final SimpleDateFormat sdf
protected int pipeSize
protected int pipeTimeout
Constructor Detail |
---|
public DeferredResponseWrapper()
public DeferredResponseWrapper(int ipipeSize, int ipipeTimeout)
Method Detail |
---|
protected void _resetVars()
public boolean isReady() throws IOException
IOException
public void actuallySendResponse(javax.servlet.http.HttpServletResponse resp) throws IOException
IOException
public void setUnderlyingResponse(javax.servlet.http.HttpServletResponse iuresp, String ilrid)
public javax.servlet.http.HttpServletResponse getUnderlyingResponse()
public void setLongRunning(LongRunning ilr)
public LongRunning getLongRunning()
public void setLongRunningThread(Thread ith)
public Thread getLongRunningThread()
public void setPipeSize(int ipipeSize)
public void setPipeTimeout(int ipipeTimeout)
public void interrupt()
public boolean isInterrupted()
public void pause()
public void resume()
public boolean isPaused()
Pausable
isPaused
in interface Pausable
public void flushBuffer()
flushBuffer
in interface javax.servlet.ServletResponse
public int getBufferSize()
getBufferSize
in interface javax.servlet.ServletResponse
public String getCharacterEncoding()
getCharacterEncoding
in interface javax.servlet.ServletResponse
public Locale getLocale()
getLocale
in interface javax.servlet.ServletResponse
public javax.servlet.ServletOutputStream getOutputStream() throws IOException
getOutputStream
in interface javax.servlet.ServletResponse
IllegalStateException
- if getWriter
has
already been called for this response, or if the response wrapper
writer has been overridden (in that case you ust use getWriter
)
IOException
- if an input/output error occurspublic PrintWriter getWriter() throws IOException
getWriter
in interface javax.servlet.ServletResponse
IllegalStateException
- if getOutputStream
has
already been called for this response
IOException
- if an input/output error occurspublic boolean isCommitted()
isCommitted
in interface javax.servlet.ServletResponse
public void reset()
reset
in interface javax.servlet.ServletResponse
public void resetBuffer()
resetBuffer
in interface javax.servlet.ServletResponse
public void setBufferSize(int size)
setBufferSize
in interface javax.servlet.ServletResponse
public void setContentLength(int len)
setContentLength
in interface javax.servlet.ServletResponse
public void setContentType(String type)
setContentType
in interface javax.servlet.ServletResponse
public void setLocale(Locale loc)
setLocale
in interface javax.servlet.ServletResponse
public void addCookie(javax.servlet.http.Cookie cookie)
addCookie
in interface javax.servlet.http.HttpServletResponse
public void addDateHeader(String name, long date)
addDateHeader
in interface javax.servlet.http.HttpServletResponse
public void addHeader(String name, String value)
addHeader
in interface javax.servlet.http.HttpServletResponse
public void addIntHeader(String name, int value)
addIntHeader
in interface javax.servlet.http.HttpServletResponse
public boolean containsHeader(String name)
containsHeader
in interface javax.servlet.http.HttpServletResponse
public String encodeRedirectUrl(String url)
encodeRedirectUrl
in interface javax.servlet.http.HttpServletResponse
public String encodeRedirectURL(String url)
encodeRedirectURL
in interface javax.servlet.http.HttpServletResponse
public String encodeUrl(String url)
encodeUrl
in interface javax.servlet.http.HttpServletResponse
public String encodeURL(String url)
encodeURL
in interface javax.servlet.http.HttpServletResponse
public void sendError(int sc)
sendError
in interface javax.servlet.http.HttpServletResponse
public void sendError(int sc, String msg)
sendError
in interface javax.servlet.http.HttpServletResponse
public void sendRedirect(String location)
sendRedirect
in interface javax.servlet.http.HttpServletResponse
public void setDateHeader(String name, long date)
setDateHeader
in interface javax.servlet.http.HttpServletResponse
public void setHeader(String name, String value)
setHeader
in interface javax.servlet.http.HttpServletResponse
public void setIntHeader(String name, int value)
setIntHeader
in interface javax.servlet.http.HttpServletResponse
public void setStatus(int isc)
setStatus
in interface javax.servlet.http.HttpServletResponse
public void setStatus(int isc, String ism)
setStatus
in interface javax.servlet.http.HttpServletResponse
public static String getStatusMessage(int isc)
status
- The status code for which a message is desiredpublic static void main(String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |