Class JerseyRequestTimeoutHandler
- java.lang.Object
-
- org.glassfish.jersey.server.internal.JerseyRequestTimeoutHandler
-
public class JerseyRequestTimeoutHandler extends Object
CommonContainerResponseWriter.suspend(long, TimeUnit, ContainerResponseWriter.TimeoutHandler)andContainerResponseWriter.setSuspendTimeout(long, TimeUnit)handler that can be used inContainerResponseWriterimplementations instead of the underlying infrastructure.- Author:
- Michal Gajdos, Marek Potociar
-
-
Constructor Summary
Constructors Constructor Description JerseyRequestTimeoutHandler(ContainerResponseWriter containerResponseWriter, ScheduledExecutorService timeoutTaskExecutor)Create request timeout handler for the giverresponse writer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Cancel the suspended task.voidsetSuspendTimeout(long timeOut, TimeUnit unit)Set the suspend timeout.booleansuspend(long timeOut, TimeUnit unit, ContainerResponseWriter.TimeoutHandler handler)Suspend the request/response processing.
-
-
-
Constructor Detail
-
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 Detail
-
suspend
public boolean suspend(long timeOut, 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:
trueif the suspend operation completed successfully,falseotherwise.- See Also:
ContainerResponseWriter.suspend(long, TimeUnit, ContainerResponseWriter.TimeoutHandler)
-
setSuspendTimeout
public void setSuspendTimeout(long timeOut, TimeUnit unit) throws IllegalStateExceptionSet 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:
ContainerResponseWriter.setSuspendTimeout(long, TimeUnit)
-
close
public void close()
Cancel the suspended task.
-
-