FileDocCategorySizeDatePackage
ConnPerRouteBean.javaAPI DocAndroid 1.5 API3885Wed May 06 22:41:10 BST 2009org.apache.http.conn.params

ConnPerRouteBean

public final class ConnPerRouteBean extends Object implements ConnPerRoute
This class maintains a map of HTTP routes to maximum number of connections allowed for those routes. This class can be used by pooling {@link org.apache.http.conn.ClientConnectionManager connection managers} for a fine-grained control of connections on a per route basis.
author
Oleg Kalnichevski
version
$Revision: 652947 $
since
4.0

Fields Summary
public static final int
DEFAULT_MAX_CONNECTIONS_PER_ROUTE
The default maximum number of connections allowed per host
private final Map
maxPerHostMap
private int
defaultMax
Constructors Summary
public ConnPerRouteBean(int defaultMax)

    
       
        super();
        this.maxPerHostMap = new HashMap<HttpRoute, Integer>();
        setDefaultMaxPerRoute(defaultMax);
    
public ConnPerRouteBean()

        this(DEFAULT_MAX_CONNECTIONS_PER_ROUTE);
    
Methods Summary
public intgetDefaultMax()

        return this.defaultMax;
    
public intgetMaxForRoute(org.apache.http.conn.routing.HttpRoute route)

        if (route == null) {
            throw new IllegalArgumentException
                ("HTTP route may not be null.");
        }
        Integer max = this.maxPerHostMap.get(route);
        if (max != null) {
            return max.intValue();
        } else {
            return this.defaultMax;
        }
    
public voidsetDefaultMaxPerRoute(int max)

        if (max < 1) {
            throw new IllegalArgumentException
                ("The maximum must be greater than 0.");
        }
        this.defaultMax = max;
    
public voidsetMaxForRoute(org.apache.http.conn.routing.HttpRoute route, int max)

        if (route == null) {
            throw new IllegalArgumentException
                ("HTTP route may not be null.");
        }
        if (max < 1) {
            throw new IllegalArgumentException
                ("The maximum must be greater than 0.");
        }
        this.maxPerHostMap.put(route, Integer.valueOf(max));
    
public voidsetMaxForRoutes(java.util.Map map)

        if (map == null) {
            return;
        }
        this.maxPerHostMap.clear();
        this.maxPerHostMap.putAll(map);