|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.grizzly.tcp.http11.GrizzlyResponse<A>
public class GrizzlyResponse<A>
Wrapper object for the Coyote response.
Field Summary | |
---|---|
protected boolean |
appCommitted
The application commit flag. |
protected ArrayList |
cookies
The set of Cookies associated with this Response. |
protected boolean |
error
The error flag. |
protected SimpleDateFormat |
format
The date format we will use for creating date headers. |
protected boolean |
included
The included flag. |
protected static String |
info
Descriptive information about this Response implementation. |
protected GrizzlyOutputBuffer |
outputBuffer
The associated output buffer. |
protected GrizzlyOutputStream |
outputStream
The associated output stream. |
protected MessageBytes |
redirectURLCC
Recyclable buffer to hold the redirect URL. |
protected GrizzlyRequest |
request
The request with which this response is associated. |
protected Response |
response
Coyote response. |
protected static StringManager |
sm
The string manager for this package. |
protected UEncoder |
urlEncoder
URL encoder. |
protected boolean |
usingOutputStream
Using output stream flag. |
protected boolean |
usingWriter
Using writer flag. |
protected GrizzlyWriter |
writer
The associated writer. |
Constructor Summary | |
---|---|
GrizzlyResponse()
|
|
GrizzlyResponse(boolean chunkingDisabled,
boolean cacheEnabled)
|
Method Summary | |
---|---|
void |
addCookie(Cookie cookie)
Add the specified Cookie to those that will be included with this Response. |
void |
addDateHeader(String name,
long value)
Add the specified date header to the specified value. |
void |
addHeader(String name,
String value)
Add the specified header to the specified value. |
void |
addIntHeader(String name,
int value)
Add the specified integer header to the specified value. |
void |
addResponseFilter(ResponseFilter responseFilter)
Add a ResponseFilter , which will be called every bytes are
ready to be written. |
void |
cancel()
Cancel the GrizzlyResponse and finish/commit it. |
boolean |
containsHeader(String name)
Has the specified header been set already in this response? |
GrizzlyOutputStream |
createOutputStream()
Create and return a ServletOutputStream to write the content associated with this Response. |
void |
enableCache(boolean cacheEnabled)
Enable/disable the cache |
String |
encodeURL(String url)
Encode the session identifier associated with this response into the specified URL, if necessary. |
static String |
filter(String message)
Filter the specified message string for characters that are sensitive in HTML. |
void |
finishResponse()
Perform whatever actions are required to flush and close the output stream or writer, in a single operation. |
void |
flushBuffer()
Flush the buffer and commit this response. |
int |
getBufferSize()
Return the actual buffer size used for this Response. |
String |
getCharacterEncoding()
Return the character encoding used for this Response. |
boolean |
getChunkingDisabled()
Is chunking enabled? |
int |
getContentCount()
Return the number of bytes actually written to the output stream. |
int |
getContentLength()
Return the content length that was set or calculated for this Response. |
String |
getContentType()
Return the content type that was set or calculated for this response, or null if no content type was set. |
Cookie[] |
getCookies()
Return an array of all cookies set for this response, or a zero-length array if no cookies have been set. |
String |
getDetailMessage()
Gets detail error message. |
String |
getHeader(String name)
Return the value for the specified header, or null if this
header has not been set. |
String[] |
getHeaderNames()
Return an array of all the header names set for this response, or a zero-length array if no headers have been set. |
String[] |
getHeaderValues(String name)
Return an array of all the header values associated with the specified header name, or an zero-length array if there are no such header values. |
boolean |
getIncluded()
Return the "processing inside an include" flag. |
String |
getInfo()
Return descriptive information about this Response implementation and the corresponding version number, in the format <description>/<version> . |
Locale |
getLocale()
Return the Locale assigned to this response. |
String |
getMessage()
Return the error message that was set with sendError()
for this Response. |
GrizzlyOutputBuffer |
getOutputBuffer()
Return the underlying OutputBuffer |
GrizzlyOutputStream |
getOutputStream()
Return the servlet output stream associated with this Response. |
PrintWriter |
getReporter()
Return a PrintWriter that can be used to render error messages, regardless of whether a stream or writer has already been acquired. |
GrizzlyRequest |
getRequest()
Return the Request with which this Response is associated. |
Response |
getResponse()
Get the Coyote response. |
int |
getStatus()
Return the HTTP status code associated with this Response. |
OutputStream |
getStream()
Return the output stream associated with this Response. |
PrintWriter |
getWriter()
Return the writer associated with this Response. |
boolean |
isAppCommitted()
Application commit flag accessor. |
boolean |
isBufferSuspended()
Suspended flag accessor. |
boolean |
isCacheEnabled()
Is the file cache enabled? |
boolean |
isCommitted()
Has the output of this response already been committed? |
protected boolean |
isEncodeable(String location)
Return true if the specified URL should be encoded with a session identifier. |
boolean |
isError()
Error flag accessor. |
boolean |
isSuspended()
Return true/tt> if that suspend() has been
invoked and set to true |
void |
recycle()
Release all object references, and initialize instance variables, in preparation for reuse of this object. |
void |
reset()
Clear any content written to the buffer. |
void |
reset(int status,
String message)
Reset this response, and specify the values for the HTTP status code and corresponding message. |
void |
resetBuffer()
Reset the data buffer but not any status or header information. |
void |
resetBuffer(boolean resetWriterStreamFlags)
Reset the data buffer and the using Writer/Stream flags but not any status or header information. |
void |
resume()
Complete the GrizzlyResponse and finish/commit it. |
void |
sendAcknowledgement()
Send an acknowledgment of a request. |
void |
sendError(int status)
Send an error response with the specified status and a default message. |
void |
sendError(int status,
String message)
Send an error response with the specified status and message. |
void |
sendRedirect(String location)
Send a temporary redirect to the specified redirect location URL. |
void |
setAppCommitted(boolean appCommitted)
Set the application commit flag. |
void |
setBufferSize(int size)
Set the buffer size to be used for this Response. |
void |
setCharacterEncoding(String charset)
|
void |
setChunkingDisabled(boolean chunkingDisabled)
Enabled or Disable response chunking. |
void |
setContentLength(int length)
Set the content length (in bytes) for this Response. |
void |
setContentLengthLong(long length)
Set the content length (in bytes) for this Response. |
void |
setContentType(String type)
Set the content type for this Response. |
void |
setDateHeader(String name,
long value)
Set the specified date header to the specified value. |
void |
setDetailMessage(String message)
Sets detail error message. |
void |
setError()
Set the error flag. |
void |
setHeader(String name,
String value)
Set the specified header to the specified value. |
void |
setIncluded(boolean included)
Set the "processing inside an include" flag. |
void |
setIntHeader(String name,
int value)
Set the specified integer header to the specified value. |
void |
setLocale(Locale locale)
Set the Locale that is appropriate for this response, including setting the appropriate character encoding. |
void |
setRequest(GrizzlyRequest request)
Set the Request with which this Response is associated. |
void |
setResponse(Response response)
Set the Coyote response. |
void |
setStatus(int status)
Set the HTTP status to be returned with this response. |
void |
setStatus(int status,
String message)
Set the HTTP status and message to be returned with this response. |
void |
setStream(OutputStream stream)
Set the output stream associated with this Response. |
void |
setSuspended(boolean suspended)
Set the suspended flag. |
void |
suspend()
Suspend the Response . |
void |
suspend(long timeout)
Suspend the GrizzlyResponse . |
void |
suspend(long timeout,
A attachment,
CompletionHandler<? super A> competionHandler)
Suspend the GrizzlyResponse . |
protected String |
toAbsolute(String location,
boolean normalize)
Convert (if necessary) and return the absolute URL that represents the resource referenced by this possibly relative URL. |
protected String |
toEncoded(String url,
String sessionId)
Return the specified URL with the specified session identifier suitably encoded. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected SimpleDateFormat format
protected static final String info
protected static StringManager sm
protected GrizzlyRequest request
protected Response response
protected final GrizzlyOutputBuffer outputBuffer
protected GrizzlyOutputStream outputStream
protected GrizzlyWriter writer
protected boolean appCommitted
protected boolean included
protected boolean error
protected ArrayList cookies
protected boolean usingOutputStream
protected boolean usingWriter
protected UEncoder urlEncoder
protected MessageBytes redirectURLCC
Constructor Detail |
---|
public GrizzlyResponse()
public GrizzlyResponse(boolean chunkingDisabled, boolean cacheEnabled)
Method Detail |
---|
public GrizzlyRequest getRequest()
public void setRequest(GrizzlyRequest request)
request
- The new associated requestpublic void setResponse(Response response)
response
- The Coyote responsepublic Response getResponse()
public void recycle()
public String encodeURL(String url)
url
- URL to be encodedprotected boolean isEncodeable(String location)
location
- Absolute URL to be validatedpublic int getContentCount()
public void setAppCommitted(boolean appCommitted)
appCommitted
- The new application committed flag valuepublic boolean isAppCommitted()
public boolean getIncluded()
public void setIncluded(boolean included)
included
- true if we are currently inside a
RequestDispatcher.include(), else falsepublic String getInfo()
<description>/<version>
.
public OutputStream getStream()
public void setStream(OutputStream stream)
stream
- The new output streampublic void setSuspended(boolean suspended)
suspended
- The new suspended flag valuepublic boolean isBufferSuspended()
public void setError()
public boolean isError()
public void setDetailMessage(String message)
message
- detail error messagepublic String getDetailMessage()
public GrizzlyOutputStream createOutputStream() throws IOException
IOException
- if an input/output error occurspublic void finishResponse() throws IOException
IOException
- if an input/output error occurspublic int getContentLength()
public String getContentType()
null
if no content type was set.
public PrintWriter getReporter() throws IOException
IOException
- if an input/output error occurspublic void flushBuffer() throws IOException
IOException
- if an input/output error occurspublic int getBufferSize()
public String getCharacterEncoding()
public GrizzlyOutputStream getOutputStream() throws IOException
IllegalStateException
- if getWriter
has
already been called for this response
IOException
- if an input/output error occurspublic Locale getLocale()
public PrintWriter getWriter() throws IOException
IllegalStateException
- if getOutputStream
has
already been called for this response
IOException
- if an input/output error occurspublic boolean isCommitted()
public void reset()
IllegalStateException
- if this response has already
been committedpublic void resetBuffer()
IllegalStateException
- if the response has already
been committedpublic void resetBuffer(boolean resetWriterStreamFlags)
resetWriterStreamFlags
- true
if the internal
usingWriter
, usingOutputStream
,
isCharacterEncodingSet
flags should also be reset
IllegalStateException
- if the response has already
been committedpublic void setBufferSize(int size)
size
- The new buffer size
IllegalStateException
- if this method is called after
output has been committed for this responsepublic void setContentLengthLong(long length)
length
- The new content lengthpublic void setContentLength(int length)
length
- The new content lengthpublic void setContentType(String type)
type
- The new content typepublic void setCharacterEncoding(String charset)
public void setLocale(Locale locale)
locale
- The new localepublic Cookie[] getCookies()
public String getHeader(String name)
null
if this
header has not been set. If more than one value was added for this
name, only the first is returned; use getHeaderValues() to retrieve all
of them.
name
- Header name to look uppublic String[] getHeaderNames()
public String[] getHeaderValues(String name)
name
- Header name to look uppublic String getMessage()
sendError()
for this Response.
public int getStatus()
public void reset(int status, String message)
IllegalStateException
- if this response has already been
committedpublic void addCookie(Cookie cookie)
cookie
- Cookie to be addedpublic void addDateHeader(String name, long value)
name
- Name of the header to setvalue
- Date value to be setpublic void addHeader(String name, String value)
name
- Name of the header to setvalue
- Value to be setpublic void addIntHeader(String name, int value)
name
- Name of the header to setvalue
- Integer value to be setpublic boolean containsHeader(String name)
name
- Name of the header to checkpublic void sendAcknowledgement() throws IOException
IOException
- if an input/output error occurspublic void sendError(int status) throws IOException
status
- HTTP status code to send
IllegalStateException
- if this response has
already been committed
IOException
- if an input/output error occurspublic void sendError(int status, String message) throws IOException
status
- HTTP status code to sendmessage
- Corresponding message to send
IllegalStateException
- if this response has
already been committed
IOException
- if an input/output error occurspublic void sendRedirect(String location) throws IOException
location
- Location URL to redirect to
IllegalStateException
- if this response has
already been committed
IOException
- if an input/output error occurspublic void setDateHeader(String name, long value)
name
- Name of the header to setvalue
- Date value to be setpublic void setHeader(String name, String value)
name
- Name of the header to setvalue
- Value to be setpublic void setIntHeader(String name, int value)
name
- Name of the header to setvalue
- Integer value to be setpublic void setStatus(int status)
status
- The new HTTP statuspublic void setStatus(int status, String message)
status
- The new HTTP statusmessage
- The associated text messageprotected String toAbsolute(String location, boolean normalize)
location
- URL to be (possibly) converted and then returned
IllegalArgumentException
- if a MalformedURLException is
thrown when converting the relative URL to an absolute onepublic static String filter(String message)
message
- The message string to be filteredprotected String toEncoded(String url, String sessionId)
url
- URL to be encoded with the session idsessionId
- Session id to be included in the encoded URLpublic boolean isCacheEnabled()
public void enableCache(boolean cacheEnabled)
public GrizzlyOutputBuffer getOutputBuffer()
OutputBuffer
public void setChunkingDisabled(boolean chunkingDisabled)
chunkingDisabled
- public boolean getChunkingDisabled()
public void resume()
GrizzlyResponse
and finish/commit it. If a
CompletionHandler
has been defined, its CompletionHandler#resumed(A)
will first be invoked, then the finishResponse()
.
Those operations commit the response.
public void cancel()
GrizzlyResponse
and finish/commit it. If a
CompletionHandler
has been defined, its CompletionHandler#cancelled(A)
will first be invoked, then the finishResponse()
.
Those operations commit the response.
public boolean isSuspended()
suspend()
has been
invoked and set to true
suspend()
has been
invoked and set to truepublic void suspend()
Response
. Suspending a Response
will
tell the underlying container to avoid recycling objects associated with
the current instance, and also to avoid commiting response.
public void suspend(long timeout)
GrizzlyResponse
. Suspending a GrizzlyResponse
will
tell the underlying container to avoid recycling objects associated with
the current instance, and also to avoid commiting response.
timeout
- The maximum amount of time, in milliseconds,
a GrizzlyResponse
can be suspended. When the timeout expires (because
nothing has been written or because the Response.resume()
or cancel()
), the GrizzlyResponse
will be automatically
resumed and commited. Usage of any methods of a GrizzlyResponse
that
times out will throw an IllegalStateException
.public void suspend(long timeout, A attachment, CompletionHandler<? super A> competionHandler)
GrizzlyResponse
. Suspending a GrizzlyResponse
will
tell the underlying container to avoid recycling objects associated with
the current instance, and also to avoid commiting response. When the
resume()
is invoked, the container will
make sure CompletionHandler.resumed(E)
is invoked with the original attachement. When the
cancel()
is invoked, the container will
make sure CompletionHandler.cancelled(E)
is invoked with the original attachement. If the timeout expires, the
CompletionHandler.cancelled(E)
is invoked with the original attachement and
the Response
commited.
timeout
- The maximum amount of time, in milliseconds,
a GrizzlyResponse
can be suspended. When the timeout expires (because
nothing has been written or because the resume()
or cancel()
), the GrizzlyResponse
will be automatically
resumed and commited. Usage of any methods of a Response
that
times out will throw an IllegalStateException
.attachment
- Any Object that will be passed back to the CompletionHandler
competionHandler
- a CompletionHandler
public void addResponseFilter(ResponseFilter responseFilter)
ResponseFilter
, which will be called every bytes are
ready to be written.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |