|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.grizzly.tcp.Response<A>
public class Response<A>
Response object.
Nested Class Summary | |
---|---|
static class |
Response.ResponseAttachment<A>
|
Field Summary | |
---|---|
protected String |
characterEncoding
|
protected boolean |
charsetSet
Has the charset been explicitly set. |
protected boolean |
commited
Committed flag. |
protected String |
contentLanguage
|
protected long |
contentLength
|
protected String |
contentType
HTTP specific fields. |
static boolean |
discardDisconnectEvent
|
protected Exception |
errorException
Holds request error exception. |
protected String |
errorURI
Request error URI. |
protected MimeHeaders |
headers
Response headers. |
ActionHook |
hook
Action hook. |
protected String |
message
Status message. |
protected OutputBuffer |
outputBuffer
Associated output buffer. |
protected Request |
req
|
protected int |
status
Status code. |
Constructor Summary | |
---|---|
Response()
|
Method Summary | |
---|---|
void |
acknowledge()
|
void |
action(ActionCode actionCode,
Object param)
|
void |
addHeader(String name,
String value)
|
void |
addResponseFilter(ResponseFilter responseFilter)
Add a ResponseFilter , which will be called every bytes are
ready to be written. |
void |
cancel()
Cancel the Response and finish/commit it. |
boolean |
containsHeader(String name)
|
void |
discardUpstreamWrites()
Discard any write operations on the Response . |
void |
doWrite(ByteChunk chunk)
Write a chunk of bytes. |
void |
finish()
|
void |
flush()
|
void |
flushHeaders()
Write all headers into our internal buffer and flush the to the client. |
long |
getBytesWritten()
|
SocketChannel |
getChannel()
Return the underlying SocketChannel
WARNING. |
String |
getCharacterEncoding()
|
String |
getContentLanguage()
Return the content language. |
int |
getContentLength()
|
long |
getContentLengthLong()
|
String |
getContentType()
|
Exception |
getErrorException()
Get the Exception that occurred during request processing. |
String |
getErrorURI()
Get the request URI that caused the original error. |
ActionHook |
getHook()
|
Locale |
getLocale()
|
String |
getMessage()
Get the status message. |
MimeHeaders |
getMimeHeaders()
|
Object |
getNote(int pos)
|
NotesManagerImpl |
getNotesManager()
|
OutputBuffer |
getOutputBuffer()
|
Request |
getRequest()
|
Response.ResponseAttachment |
getResponseAttachment()
Return the Response.ResponseAttachment associated with this instance, or
null if the isSuspended() return false. |
SelectionKey |
getSelectionKey()
Return the underlying SelectionKey |
int |
getStatus()
|
boolean |
isAllowCustomReasonPhrase()
|
boolean |
isCommitted()
|
boolean |
isExceptionPresent()
|
boolean |
isSuspended()
Return true/tt> if that suspend() has been
invoked and set to true |
void |
recycle()
|
void |
removeSessionCookies()
Removes any Set-Cookie response headers whose value contains the string "JSESSIONID=" or "JSESSIONIDSSO=" |
void |
reset()
|
void |
resume()
Complete the Response and finish/commit it. |
void |
sendHeaders()
Write all headers into our internal buffer but don't flush them to the client yet. |
void |
setAllowCustomReasonPhrase(boolean allowCustomReasonPhrase)
|
void |
setBytesWritten(long bytesWritten)
|
void |
setCharacterEncoding(String charset)
|
void |
setCommitted(boolean v)
|
void |
setContentLength(int contentLength)
|
void |
setContentLengthLong(long contentLength)
|
void |
setContentType(String type)
Sets the content type. |
void |
setErrorException(Exception ex)
Set the error Exception that occurred during request processing. |
void |
setErrorURI(String uri)
Set request URI that caused an error during request processing. |
void |
setHeader(String name,
String value)
|
void |
setHook(ActionHook hook)
|
void |
setLocale(Locale locale)
Called explicitely by user to set the Content-Language and the default encoding |
void |
setMessage(String message)
Set the status message. |
void |
setNote(int pos,
Object value)
|
void |
setNotesManager(NotesManagerImpl notesManager)
|
void |
setOutputBuffer(OutputBuffer outputBuffer)
|
void |
setRequest(Request req)
|
void |
setSelectionKey(SelectionKey selectionKey)
Set the underlying SelectionKey |
void |
setStatus(int status)
Set the response status |
void |
suspend()
Suspend the Response . |
void |
suspend(long timeout)
Suspend the Response . |
void |
suspend(long timeout,
A attachment,
CompletionHandler<? super A> competionHandler)
Suspend the Response . |
void |
suspend(long timeout,
A attachment,
CompletionHandler<? super A> competionHandler,
Response.ResponseAttachment<A> ra)
Suspend the Response . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected int status
protected String message
protected MimeHeaders headers
protected OutputBuffer outputBuffer
protected boolean commited
public ActionHook hook
protected String contentType
protected String contentLanguage
protected String characterEncoding
protected long contentLength
protected Exception errorException
protected boolean charsetSet
protected String errorURI
protected Request req
public static final boolean discardDisconnectEvent
Constructor Detail |
---|
public Response()
Method Detail |
---|
public Request getRequest()
public void setRequest(Request req)
public OutputBuffer getOutputBuffer()
public void setOutputBuffer(OutputBuffer outputBuffer)
public MimeHeaders getMimeHeaders()
public ActionHook getHook()
public void setHook(ActionHook hook)
public final void setNote(int pos, Object value)
public final Object getNote(int pos)
public NotesManagerImpl getNotesManager()
public void setNotesManager(NotesManagerImpl notesManager)
public void action(ActionCode actionCode, Object param)
public int getStatus()
public void setStatus(int status)
public String getMessage()
public void setMessage(String message)
public boolean isCommitted()
public void setCommitted(boolean v)
public void setErrorException(Exception ex)
public Exception getErrorException()
public boolean isExceptionPresent()
public void setErrorURI(String uri)
public String getErrorURI()
public boolean isAllowCustomReasonPhrase()
public void setAllowCustomReasonPhrase(boolean allowCustomReasonPhrase)
public void reset() throws IllegalStateException
IllegalStateException
public void discardUpstreamWrites() throws IllegalStateException
Response
. Invoking that method
prevent any write operation to be fluxhed on the network.
IllegalStateException
public void flush() throws IOException
IOException
public void finish() throws IOException
IOException
public void acknowledge() throws IOException
IOException
public boolean containsHeader(String name)
public void setHeader(String name, String value)
public void addHeader(String name, String value)
public void sendHeaders() throws IOException
flush()
in order to make that operation.
IOException
public void flushHeaders() throws IOException
IOException
public Locale getLocale()
public void setLocale(Locale locale)
public String getContentLanguage()
public void setCharacterEncoding(String charset)
public String getCharacterEncoding()
public void setContentType(String type)
type
- the content typepublic String getContentType()
public void setContentLength(int contentLength)
public int getContentLength()
public void setContentLengthLong(long contentLength)
public long getContentLengthLong()
public void doWrite(ByteChunk chunk) throws IOException
IOException
public void recycle()
public long getBytesWritten()
public void setBytesWritten(long bytesWritten)
public void removeSessionCookies()
public void setSelectionKey(SelectionKey selectionKey)
SelectionKey
public SelectionKey getSelectionKey()
SelectionKey
public SocketChannel getChannel()
SocketChannel
WARNING. If you directly use the SocketChannel
,
you must make sure sendHeaders()
followed by a flush()
if you just want to manipulate the response body, but not the header.
If you don't want to let Grizzly write the headers for you,
Invoke setCommitted(boolean)
with true before starting writing bytes
to the SocketChannel
public void resume()
Response
and finish/commit it. If a
CompletionHandler
has been defined, its CompletionHandler.resumed(E)
will first be invoked, then the setCommitted(boolean)
followed
by finish()
. Those operations commit the response.
public void cancel()
Response
and finish/commit it. If a
CompletionHandler
has been defined, its CompletionHandler.cancelled(E)
will first be invoked, then the setCommitted(boolean)
followed
by finish()
. 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)
Response
. Suspending a Response
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 Response
can be suspended. When the timeout expires (because
nothing has been written or because the resume()
or cancel()
), the Response
will be automatically
resumed and commited. Usage of any methods of a Response
that
times out will throw an IllegalStateException
.public void suspend(long timeout, A attachment, CompletionHandler<? super A> competionHandler)
Response
. Suspending a Response
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 Response
can be suspended. When the timeout expires (because
nothing has been written or because the resume()
or cancel()
), the Response
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 suspend(long timeout, A attachment, CompletionHandler<? super A> competionHandler, Response.ResponseAttachment<A> ra)
Response
. Suspending a Response
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 Response
can be suspended. When the timeout expires (because
nothing has been written or because the resume()
or cancel()
), the Response
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
ra
- Response.ResponseAttachment
used to times out idle connection.public Response.ResponseAttachment getResponseAttachment()
Response.ResponseAttachment
associated with this instance, or
null if the isSuspended()
return false.
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 |