public class JerseyRequestTimeoutHandler
extends java.lang.Object
ContainerResponseWriter.suspend(long, TimeUnit, ContainerResponseWriter.TimeoutHandler)
and ContainerResponseWriter.setSuspendTimeout(long, TimeUnit)
handler that can be used in
ContainerResponseWriter
implementations instead of the underlying infrastructure.Modifier and Type | Field and Description |
---|---|
private ContainerResponseWriter |
containerResponseWriter |
private java.util.concurrent.ScheduledExecutorService |
executor |
private static java.util.logging.Logger |
LOGGER |
private java.lang.Object |
runtimeLock |
private boolean |
suspended |
private ContainerResponseWriter.TimeoutHandler |
timeoutHandler |
private java.util.concurrent.ScheduledFuture<?> |
timeoutTask |
Constructor and Description |
---|
JerseyRequestTimeoutHandler(ContainerResponseWriter containerResponseWriter,
java.util.concurrent.ScheduledExecutorService timeoutTaskExecutor)
Create request timeout handler for the giver
response writer . |
Modifier and Type | Method and Description |
---|---|
void |
close()
Cancel the suspended task.
|
private void |
close(boolean interruptIfRunning) |
void |
setSuspendTimeout(long timeOut,
java.util.concurrent.TimeUnit unit)
Set the suspend timeout.
|
boolean |
suspend(long timeOut,
java.util.concurrent.TimeUnit unit,
ContainerResponseWriter.TimeoutHandler handler)
Suspend the request/response processing.
|
private static final java.util.logging.Logger LOGGER
private java.util.concurrent.ScheduledFuture<?> timeoutTask
private ContainerResponseWriter.TimeoutHandler timeoutHandler
private boolean suspended
private final java.lang.Object runtimeLock
private final ContainerResponseWriter containerResponseWriter
private final java.util.concurrent.ScheduledExecutorService executor
public JerseyRequestTimeoutHandler(ContainerResponseWriter containerResponseWriter, java.util.concurrent.ScheduledExecutorService timeoutTaskExecutor)
response writer
.containerResponseWriter
- response writer to create request timeout handler for.timeoutTaskExecutor
- Jersey runtime executor used for background execution of timeout
handling tasks.public boolean suspend(long timeOut, java.util.concurrent.TimeUnit unit, ContainerResponseWriter.TimeoutHandler handler)
timeOut
- time-out value. Value less or equal to 0, indicates that
the processing is suspended indefinitely.unit
- time-out time unit.handler
- time-out handler to process a time-out event if it occurs.true
if the suspend operation completed successfully, false
otherwise.ContainerResponseWriter.suspend(long, TimeUnit, ContainerResponseWriter.TimeoutHandler)
public void setSuspendTimeout(long timeOut, java.util.concurrent.TimeUnit unit) throws java.lang.IllegalStateException
timeOut
- time-out value. Value less or equal to 0, indicates that
the processing is suspended indefinitely.unit
- time-out time unit.java.lang.IllegalStateException
- in case the response writer has not been suspended yet.ContainerResponseWriter.setSuspendTimeout(long, TimeUnit)
public void close()
private void close(boolean interruptIfRunning)