Class ServConnectionManager

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--ServConnectionManager
All Implemented Interfaces:
java.lang.Runnable

public class ServConnectionManager
extends java.lang.Thread

A class to Manage ServConnection. It tries to reuse ServConnections when possible.


Field Summary
protected  java.lang.Thread cleaner
          The cleaner thread.
 long KEEP_ALIVE_TIME
          the keepalivetime time we keep ServConnections.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
ServConnectionManager()
          Create a new ServConnectionManager for use.
 
Method Summary
 java.util.Vector find(ServConnection s)
          Look for a matching active ServConnection inside the pool, match is done uppon InetAddress and Port
 ServConnection getConnection(HTTPHeader header)
          Get a ServConnection for the given header.
 void releaseConnection(ServConnection c)
          Return a ServConnection to the pool so that it may be reused.
 void run()
          The cleaner thread is used to drop old connections where keepalive time is over. after each clean session, cleaner sleeps for an amount of time of this.KEEP_ALIVE_TIME in order to save CPU
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, 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

cleaner

protected java.lang.Thread cleaner
The cleaner thread. It is used to remove old connections from pool

KEEP_ALIVE_TIME

public long KEEP_ALIVE_TIME
the keepalivetime time we keep ServConnections.
Constructor Detail

ServConnectionManager

public ServConnectionManager()
Create a new ServConnectionManager for use.
Method Detail

find

public java.util.Vector find(ServConnection s)
Look for a matching active ServConnection inside the pool, match is done uppon InetAddress and Port
Parameters:
s - the connection we are looking for
Returns:
as sub-set vector of active ServConnections matching

getConnection

public ServConnection getConnection(HTTPHeader header)
                             throws java.io.IOException
Get a ServConnection for the given header.
Parameters:
header - the HTTPHeader containing the URL to connect to.
Returns:
a ServConnection.

releaseConnection

public void releaseConnection(ServConnection c)
Return a ServConnection to the pool so that it may be reused.
Parameters:
c - the ServConnection to return.

run

public void run()
The cleaner thread is used to drop old connections where keepalive time is over. after each clean session, cleaner sleeps for an amount of time of this.KEEP_ALIVE_TIME in order to save CPU
Overrides:
run in class java.lang.Thread