Class IdleConnectionTimeoutThread
java.lang.Object
java.lang.Thread
org.apache.commons.httpclient.util.IdleConnectionTimeoutThread
- All Implemented Interfaces:
Runnable
A utility class for periodically closing idle connections.
- Since:
- 3.0
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
Fields inherited from class Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddConnectionManager(HttpConnectionManager connectionManager) Adds a connection manager to be handled by this class.protected voidhandleCloseIdleConnections(HttpConnectionManager connectionManager) Handles callingcloseIdleConnections()and doing any other cleanup work on the given connection mangaer.voidremoveConnectionManager(HttpConnectionManager connectionManager) Removes the connection manager from this class.voidrun()Closes idle connections.voidsetConnectionTimeout(long connectionTimeout) Sets the timeout value to use when testing for idle connections.voidsetTimeoutInterval(long timeoutInterval) Sets the interval used by this class between closing idle connections.voidshutdown()Stops the thread used to close idle connections.Methods inherited from class Thread
activeCount, checkAccess, clone, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, threadId, toString, yield
-
Constructor Details
-
IdleConnectionTimeoutThread
public IdleConnectionTimeoutThread()
-
-
Method Details
-
addConnectionManager
Adds a connection manager to be handled by this class.HttpConnectionManager.closeIdleConnections(long)will be called on the connection manager everytimeoutIntervalmilliseconds.- Parameters:
connectionManager- The connection manager to add
-
removeConnectionManager
Removes the connection manager from this class. The idle connections from the connection manager will no longer be automatically closed by this class.- Parameters:
connectionManager- The connection manager to remove
-
handleCloseIdleConnections
Handles callingcloseIdleConnections()and doing any other cleanup work on the given connection mangaer.- Parameters:
connectionManager- The connection manager to close idle connections for
-
run
-
shutdown
public void shutdown()Stops the thread used to close idle connections. This class cannot be used once shutdown. -
setConnectionTimeout
public void setConnectionTimeout(long connectionTimeout) Sets the timeout value to use when testing for idle connections.- Parameters:
connectionTimeout- The connection timeout in milliseconds- See Also:
-
setTimeoutInterval
public void setTimeoutInterval(long timeoutInterval) Sets the interval used by this class between closing idle connections. Idle connections will be closed everytimeoutIntervalmilliseconds.- Parameters:
timeoutInterval- The timeout interval in milliseconds
-