com.sun.jini.jeri.internal.http
Class ConnectionTimer

java.lang.Object
  extended by com.sun.jini.jeri.internal.http.ConnectionTimer

public class ConnectionTimer
extends Object

Utility class for timing out connections.

Author:
Sun Microsystems, Inc.

Nested Class Summary
private static class ConnectionTimer.TimeoutMap
          Map for tracking idle connection timeouts.
 
Field Summary
private static Executor systemThreadPool
           
private  ConnectionTimer.TimeoutMap timeouts
           
 
Constructor Summary
ConnectionTimer(long timeout)
          Creates new ConnectionTimer which shuts down overdue connections after the given timeout.
 
Method Summary
 boolean cancelTimeout(TimedConnection conn)
          Attempts to cancel timeout for the given connection.
 void scheduleTimeout(TimedConnection conn, boolean force)
          Schedules timeout for given connection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

systemThreadPool

private static final Executor systemThreadPool

timeouts

private final ConnectionTimer.TimeoutMap timeouts
Constructor Detail

ConnectionTimer

public ConnectionTimer(long timeout)
Creates new ConnectionTimer which shuts down overdue connections after the given timeout.

Method Detail

scheduleTimeout

public void scheduleTimeout(TimedConnection conn,
                            boolean force)
Schedules timeout for given connection. If timeout is already scheduled for given connection, renews timeout. When the timeout occurs, the connection's shutdown method will be called with the given force value.


cancelTimeout

public boolean cancelTimeout(TimedConnection conn)
Attempts to cancel timeout for the given connection. Returns true if a timeout was successfully cancelled, false otherwise (e.g. if connection was never scheduled for a timeout, has already been timed out, or is already in the midst of being timed out).



Copyright 2007-2010, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.