Example usage for org.apache.http.impl.conn HttpPoolEntry HttpPoolEntry

List of usage examples for org.apache.http.impl.conn HttpPoolEntry HttpPoolEntry

Introduction

In this page you can find the example usage for org.apache.http.impl.conn HttpPoolEntry HttpPoolEntry.

Prototype

public HttpPoolEntry(final Log log, final String id, final HttpRoute route, final OperatedClientConnection conn,
            final long timeToLive, final TimeUnit tunit) 

Source Link

Usage

From source file:org.apache.http.impl.conn.BasicClientConnectionManager.java

ManagedClientConnection getConnection(final HttpRoute route, final Object state) {
    Args.notNull(route, "Route");
    synchronized (this) {
        assertNotShutdown();/*from  ww  w . ja  v a2 s .c o m*/
        if (this.log.isDebugEnabled()) {
            this.log.debug("Get connection for route " + route);
        }
        Asserts.check(this.conn == null, MISUSE_MESSAGE);
        if (this.poolEntry != null && !this.poolEntry.getPlannedRoute().equals(route)) {
            this.poolEntry.close();
            this.poolEntry = null;
        }
        if (this.poolEntry == null) {
            final String id = Long.toString(COUNTER.getAndIncrement());
            final OperatedClientConnection conn = this.connOperator.createConnection();
            this.poolEntry = new HttpPoolEntry(this.log, id, route, conn, 0, TimeUnit.MILLISECONDS);
        }
        final long now = System.currentTimeMillis();
        if (this.poolEntry.isExpired(now)) {
            this.poolEntry.close();
            this.poolEntry.getTracker().reset();
        }
        this.conn = new ManagedClientConnectionImpl(this, this.connOperator, this.poolEntry);
        return this.conn;
    }
}

From source file:org.apache.http.impl.conn.FixedHttpConnPool.java

@Override
protected HttpPoolEntry createEntry(final HttpRoute route, final OperatedClientConnection conn) {
    String id = Long.toString(COUNTER.getAndIncrement());
    return new HttpPoolEntry(this.log, id, route, conn, this.timeToLive, this.tunit);
}

From source file:org.apache.http.impl.conn.HttpConnPool.java

@Override
protected HttpPoolEntry createEntry(final HttpRoute route, final OperatedClientConnection conn) {
    final String id = Long.toString(COUNTER.getAndIncrement());
    return new HttpPoolEntry(this.log, id, route, conn, this.timeToLive, this.tunit);
}