Class JerseyRequestTimeoutHandler
java.lang.Object
org.glassfish.jersey.server.internal.JerseyRequestTimeoutHandler
Common
ContainerResponseWriter.suspend(long, TimeUnit, ContainerResponseWriter.TimeoutHandler)
and ContainerResponseWriter.setSuspendTimeout(long, TimeUnit)
handler that can be used in
ContainerResponseWriter
implementations instead of the underlying infrastructure.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ContainerResponseWriter
private final ScheduledExecutorService
private static final Logger
private final Object
private boolean
private ScheduledFuture
<?> -
Constructor Summary
ConstructorsConstructorDescriptionJerseyRequestTimeoutHandler
(ContainerResponseWriter containerResponseWriter, ScheduledExecutorService timeoutTaskExecutor) Create request timeout handler for the giverresponse writer
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Cancel the suspended task.private void
close
(boolean interruptIfRunning) void
setSuspendTimeout
(long timeOut, TimeUnit unit) Set the suspend timeout.boolean
suspend
(long timeOut, TimeUnit unit, ContainerResponseWriter.TimeoutHandler handler) Suspend the request/response processing.
-
Field Details
-
LOGGER
-
timeoutTask
-
timeoutHandler
-
suspended
private boolean suspended -
runtimeLock
-
containerResponseWriter
-
executor
-
-
Constructor Details
-
JerseyRequestTimeoutHandler
public JerseyRequestTimeoutHandler(ContainerResponseWriter containerResponseWriter, ScheduledExecutorService timeoutTaskExecutor) Create request timeout handler for the giverresponse writer
.- Parameters:
containerResponseWriter
- response writer to create request timeout handler for.timeoutTaskExecutor
- Jersey runtime executor used for background execution of timeout handling tasks.
-
-
Method Details
-
suspend
Suspend the request/response processing.- Parameters:
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.- Returns:
true
if the suspend operation completed successfully,false
otherwise.- See Also:
-
setSuspendTimeout
Set the suspend timeout.- Parameters:
timeOut
- time-out value. Value less or equal to 0, indicates that the processing is suspended indefinitely.unit
- time-out time unit.- Throws:
IllegalStateException
- in case the response writer has not been suspended yet.- See Also:
-
close
public void close()Cancel the suspended task. -
close
private void close(boolean interruptIfRunning)
-