|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.glassfish.jersey.servlet.internal.ResponseWriter
public class ResponseWriter
An internal implementation of ContainerResponseWriter for Servlet containers.
The writer depends on provided AsyncContextDelegate to support async functionality.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface org.glassfish.jersey.server.spi.ContainerResponseWriter |
|---|
ContainerResponseWriter.TimeoutHandler |
| Constructor Summary | |
|---|---|
ResponseWriter(boolean useSetStatusOn404,
javax.servlet.http.HttpServletResponse response,
AsyncContextDelegate asyncExt,
ScheduledExecutorService timeoutTaskExecutor)
Creates a new instance to write a single Jersey response. |
|
| Method Summary | |
|---|---|
void |
commit()
Commit the response & close the container response writer. |
boolean |
enableResponseBuffering()
Return true if the entity buffering should be enabled in Jersey. |
void |
failure(Throwable error)
Propagate an unhandled error to the I/O container. |
int |
getResponseStatus()
Provides response status captured when writeResponseStatusAndHeaders(long, org.glassfish.jersey.server.ContainerResponse) has been invoked. |
void |
setSuspendTimeout(long timeOut,
TimeUnit timeUnit)
Set the suspend timeout. |
boolean |
suspend(long timeOut,
TimeUnit timeUnit,
ContainerResponseWriter.TimeoutHandler timeoutHandler)
Suspend the request/response processing. |
OutputStream |
writeResponseStatusAndHeaders(long contentLength,
ContainerResponse responseContext)
Write the status and headers of the response and return an output stream for the web application to write the entity of the response. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ResponseWriter(boolean useSetStatusOn404,
javax.servlet.http.HttpServletResponse response,
AsyncContextDelegate asyncExt,
ScheduledExecutorService timeoutTaskExecutor)
useSetStatusOn404 - true if status should be written explicitly when 404 is returnedresponse - original HttpResponseRequestasyncExt - delegate to use for async features implementationtimeoutTaskExecutor - Jersey runtime executor used for background execution of timeout
handling tasks.| Method Detail |
|---|
public boolean suspend(long timeOut,
TimeUnit timeUnit,
ContainerResponseWriter.TimeoutHandler timeoutHandler)
ContainerResponseWritertrue to indicate the response writer was suspended successfully.
In case the provider has already been suspended earlier, the method returns false.
I/O container must not automatically commit the response writer
when the processing on the I/O container thread is finished and the thread is
released. Instead, the Jersey runtime will make sure to manually close
the container response writer instance by explicitly calling the ContainerResponseWriter.commit()
or ContainerResponseWriter.failure(Throwable) method at some later point in time.
Once suspended, the specified suspend timeout can be further updated using
ContainerResponseWriter.setSuspendTimeout(long, java.util.concurrent.TimeUnit) method.
suspend in interface ContainerResponseWritertimeOut - time-out value. Value less or equal to 0, indicates that
the processing is suspended indefinitely.timeUnit - time-out time unit.timeoutHandler - time-out handler to process a time-out event if it
occurs.
true if the suspend operation completed successfully, false otherwise.ContainerResponseWriter.setSuspendTimeout(long, TimeUnit),
ContainerResponseWriter.commit()
public void setSuspendTimeout(long timeOut,
TimeUnit timeUnit)
throws IllegalStateException
ContainerResponseWriter
setSuspendTimeout in interface ContainerResponseWritertimeOut - time-out value. Value less or equal to 0, indicates that
the processing is suspended indefinitely.timeUnit - time-out time unit.
IllegalStateException - in case the response writer has not been suspended
yet.
public OutputStream writeResponseStatusAndHeaders(long contentLength,
ContainerResponse responseContext)
throws ContainerException
ContainerResponseWriter
If the response content length is declared to be greater or equal to 0, it
means that the content length in bytes of the entity to be written is known,
otherwise -1. I/O containers may use this value to determine whether the
"Content-Length" header can be set or utilize chunked transfer encoding.
writeResponseStatusAndHeaders in interface ContainerResponseWritercontentLength - greater or equal to 0 if the content length in bytes
of the entity to be written is known, otherwise -1. Containers
may use this value to determine whether the "Content-Length"
header can be set or utilize chunked transfer encoding.responseContext - the JAX-RS response to be written. The status and headers
are obtained from the response.
ContainerException - if an error occurred when writing out the
status and headers or obtaining the output stream.public void commit()
ContainerResponseWriter
commit in interface ContainerResponseWriterContainerResponseWriter.suspend(long, TimeUnit, TimeoutHandler),
ContainerResponseWriter.failure(Throwable)public void failure(Throwable error)
ContainerResponseWriter
failure in interface ContainerResponseWritererror - unhandled request processing error.ContainerResponseWriter.suspend(long, TimeUnit, TimeoutHandler),
ContainerResponseWriter.commit()public boolean enableResponseBuffering()
ContainerResponseWritertrue if the entity buffering should be enabled in Jersey.
If enabled, the outbound entity is buffered by Jersey runtime up to a configured amount of bytes
prior to being written to the output stream to determine its size that may be used to set the value
of HTTP "Content-Length" header.
Containers that provide it's own solution for determining the message payload size may decide to
return false to prevent Jersey from buffering message entities unnecessarily.
enableResponseBuffering in interface ContainerResponseWritertrue to enable the entity buffering should by Jersey runtime, false otherwise.public int getResponseStatus()
writeResponseStatusAndHeaders(long, org.glassfish.jersey.server.ContainerResponse) has been invoked.
The method will block if the write method has not been called yet.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||