Class JerseyRequestTimeoutHandler
- java.lang.Object
-
- org.glassfish.jersey.server.internal.JerseyRequestTimeoutHandler
-
public class JerseyRequestTimeoutHandler extends java.lang.Object
CommonContainerResponseWriter.suspend(long, TimeUnit, ContainerResponseWriter.TimeoutHandler)
andContainerResponseWriter.setSuspendTimeout(long, TimeUnit)
handler that can be used inContainerResponseWriter
implementations instead of the underlying infrastructure.
-
-
Field Summary
Fields Modifier and Type Field 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 Summary
Constructors Constructor Description JerseyRequestTimeoutHandler(ContainerResponseWriter containerResponseWriter, java.util.concurrent.ScheduledExecutorService timeoutTaskExecutor)
Create request timeout handler for the giverresponse writer
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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.
-
-
-
Field Detail
-
LOGGER
private static final java.util.logging.Logger LOGGER
-
timeoutTask
private java.util.concurrent.ScheduledFuture<?> timeoutTask
-
timeoutHandler
private ContainerResponseWriter.TimeoutHandler timeoutHandler
-
suspended
private boolean suspended
-
runtimeLock
private final java.lang.Object runtimeLock
-
containerResponseWriter
private final ContainerResponseWriter containerResponseWriter
-
executor
private final java.util.concurrent.ScheduledExecutorService executor
-
-
Constructor Detail
-
JerseyRequestTimeoutHandler
public JerseyRequestTimeoutHandler(ContainerResponseWriter containerResponseWriter, java.util.concurrent.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 Detail
-
suspend
public boolean suspend(long timeOut, java.util.concurrent.TimeUnit unit, ContainerResponseWriter.TimeoutHandler handler)
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:
ContainerResponseWriter.suspend(long, TimeUnit, ContainerResponseWriter.TimeoutHandler)
-
setSuspendTimeout
public void setSuspendTimeout(long timeOut, java.util.concurrent.TimeUnit unit) throws java.lang.IllegalStateException
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:
java.lang.IllegalStateException
- in case the response writer has not been suspended yet.- See Also:
ContainerResponseWriter.setSuspendTimeout(long, TimeUnit)
-
close
public void close()
Cancel the suspended task.
-
close
private void close(boolean interruptIfRunning)
-
-