org.glassfish.jersey.server.internal
Class JerseyRequestTimeoutHandler

java.lang.Object
  extended by org.glassfish.jersey.server.internal.JerseyRequestTimeoutHandler

public class JerseyRequestTimeoutHandler
extends Object

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.

Author:
Michal Gajdos (michal.gajdos at oracle.com), Marek Potociar (marek.potociar at oracle.com)

Constructor Summary
JerseyRequestTimeoutHandler(ContainerResponseWriter containerResponseWriter, ScheduledExecutorService timeoutTaskExecutor)
          Create request timeout handler for the giver response writer.
 
Method Summary
 void setSuspendTimeout(long timeOut, TimeUnit unit)
          Set the suspend timeout.
 boolean suspend(long timeOut, TimeUnit unit, ContainerResponseWriter.TimeoutHandler handler)
          Suspend the request/response processing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JerseyRequestTimeoutHandler

public JerseyRequestTimeoutHandler(ContainerResponseWriter containerResponseWriter,
                                   ScheduledExecutorService timeoutTaskExecutor)
Create request timeout handler for the giver response 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:
true if the suspend operation completed successfully, false otherwise.
See Also:
ContainerResponseWriter.suspend(long, TimeUnit, ContainerResponseWriter.TimeoutHandler)

setSuspendTimeout

public void setSuspendTimeout(long timeOut,
                              TimeUnit unit)
                       throws 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:
IllegalStateException - in case the response writer has not been suspended yet.
See Also:
ContainerResponseWriter.setSuspendTimeout(long, TimeUnit)


Copyright © 2007-2013, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.