|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface ContainerResponseWriter
A suspendable, request-scoped I/O container response writer.
I/O container sends a new instance of the response writer with every request as part
of the call to the Jersey application
ApplicationHandler.apply(org.glassfish.jersey.server.ContainerRequest) apply(...)}
method. Each container response writer represents an open connection to the client
(waiting for a response).
For each request the Jersey runtime will make sure to directly call either
suspend(...)
or commit() method on a response writer supplied to the
JerseyApplication.apply(...) method before the method has finished. Therefore
the I/O container implementations may assume that when the JerseyApplication.apply(...)
method is finished, the container response writer is either commited,
or suspended.
| Nested Class Summary | |
|---|---|
static interface |
ContainerResponseWriter.TimeoutHandler
Time-out handler can be registered when the container response writer gets suspended. |
| Method Summary | |
|---|---|
void |
commit()
Commit the response & close the container response writer. |
void |
failure(Throwable error)
Propagate an unhandled error to the I/O container. |
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. |
| Method Detail |
|---|
OutputStream writeResponseStatusAndHeaders(long contentLength,
ContainerResponse responseContext)
throws ContainerException
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.
contentLength - 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.
boolean suspend(long timeOut,
TimeUnit timeUnit,
ContainerResponseWriter.TimeoutHandler timeoutHandler)
true 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 commit()
or failure(Throwable) method at some later point in time.
Once suspended, the specified suspend timeout can be further updated using
setSuspendTimeout(long, java.util.concurrent.TimeUnit) method.
timeOut - 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.setSuspendTimeout(long, TimeUnit),
commit()
void setSuspendTimeout(long timeOut,
TimeUnit timeUnit)
throws IllegalStateException
timeOut - 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.setSuspendTimeout(long, TimeUnit)void commit()
suspend(long, TimeUnit, TimeoutHandler),
failure(Throwable)void failure(Throwable error)
error - unhandled request processing error.suspend(long, TimeUnit, TimeoutHandler),
commit()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||