org.scache
Class ConnectionHandler

java.lang.Object
  extended byjava.lang.Thread
      extended byorg.scache.ConnectionHandler
All Implemented Interfaces:
java.lang.Runnable

public final class ConnectionHandler
extends java.lang.Thread

A class to handle the connections to the net. Should reuse connections if possible.


Field Summary
static long keepalivetime
           
static boolean trace_keepalive
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
ConnectionHandler()
           
 
Method Summary
static java.util.Enumeration getAddresses()
          Get the addresses we have connections to.
static WebConnection getConnection(java.net.InetAddress ia, int port)
          Get a WebConnection for the given IP:Port
static java.util.Enumeration getConnections()
          Get the connections keept.
static long getKeepaliveTime()
          Get the current keep alive time.
static java.util.Vector getPool(java.lang.String a)
          Get the pool for an Address.
static void init()
          Create a new ConnectionHandler for use.
static boolean isCleanerRunning()
          Check if the cleaner of this ConnectionHandler is running.
static void releaseConnection(WebConnection wc)
          Return a WebConnection to the pool so that it may be reused.
 void run()
          The cleaner thread.
static void setKeepaliveTime(long milis)
          Set the keep alive time for this handler.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

trace_keepalive

public static boolean trace_keepalive

keepalivetime

public static long keepalivetime
Constructor Detail

ConnectionHandler

public ConnectionHandler()
Method Detail

init

public static final void init()
Create a new ConnectionHandler for use.


isCleanerRunning

public static final boolean isCleanerRunning()
Check if the cleaner of this ConnectionHandler is running.


getConnections

public static final java.util.Enumeration getConnections()
Get the connections keept.

Returns:
an Enumeration of Vectors with WebConnections.

getAddresses

public static final java.util.Enumeration getAddresses()
Get the addresses we have connections to.


getPool

public static final java.util.Vector getPool(java.lang.String a)
Get the pool for an Address. NOTE! synchronize on the pool if you are taking connections from it.


getConnection

public static final WebConnection getConnection(java.net.InetAddress ia,
                                                int port)
                                         throws java.io.IOException
Get a WebConnection for the given IP:Port

Returns:
a WebConnection.
Throws:
java.io.IOException

releaseConnection

public static final void releaseConnection(WebConnection wc)
Return a WebConnection to the pool so that it may be reused.

Parameters:
wc - the WebConnection to return.

setKeepaliveTime

public static void setKeepaliveTime(long milis)
Set the keep alive time for this handler.

Parameters:
milis - the keep alive time in miliseconds.

getKeepaliveTime

public static long getKeepaliveTime()
Get the current keep alive time.

Returns:
the keep alive time in miliseconds.

run

public void run()
The cleaner thread.