rabbit.io
Class ConnectionHandler

java.lang.Object
  extended by rabbit.io.ConnectionHandler

public class ConnectionHandler
extends Object

A class to handle the connections to the net. Tries to reuse connections whenever possible.

Author:
Robert Olofsson

Constructor Summary
ConnectionHandler(Counter counter, Resolver resolver, NioHandler nioHandler)
           
 
Method Summary
 Map<Address,List<WebConnection>> getActiveConnections()
           
 void getConnection(HttpHeader header, WebConnectionListener wcl)
          Get a WebConnection for the given header.
 long getKeepaliveTime()
          Get the current keep alive time.
 void markForPipelining(WebConnection wc)
          Mark a WebConnection ready for pipelining.
 void releaseConnection(WebConnection wc)
          Return a WebConnection to the pool so that it may be reused.
 void setKeepaliveTime(long milis)
          Set the keep alive time for this handler.
 void setup(SProperties config)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConnectionHandler

public ConnectionHandler(Counter counter,
                         Resolver resolver,
                         NioHandler nioHandler)
Method Detail

setKeepaliveTime

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

Parameters:
milis - the keep alive time in miliseconds.

getKeepaliveTime

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

Returns:
the keep alive time in miliseconds.

getActiveConnections

public Map<Address,List<WebConnection>> getActiveConnections()

getConnection

public void getConnection(HttpHeader header,
                          WebConnectionListener wcl)
Get a WebConnection for the given header.

Parameters:
header - the HttpHeader containing the URL to connect to.
wcl - the Listener that wants the connection.

releaseConnection

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

Parameters:
wc - the WebConnection to return.

markForPipelining

public void markForPipelining(WebConnection wc)
Mark a WebConnection ready for pipelining.

Parameters:
wc - the WebConnection to mark ready for pipelining.

setup

public void setup(SProperties config)