Example usage for org.apache.http.impl.conn.tsccm BasicPoolEntry getConnection

List of usage examples for org.apache.http.impl.conn.tsccm BasicPoolEntry getConnection

Introduction

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

Prototype

protected final OperatedClientConnection getConnection() 

Source Link

Usage

From source file:org.apache.http.impl.conn.tsccm.AbstractConnPool.java

/**
 * Shuts down this pool and all associated resources.
 * Overriding methods MUST call the implementation here!
 *///from   w  w  w. ja  va 2s .  com
public void shutdown() {

    poolLock.lock();
    try {

        if (isShutDown) {
            return;
        }

        // close all connections that are issued to an application
        final Iterator<BasicPoolEntry> iter = leasedConnections.iterator();
        while (iter.hasNext()) {
            final BasicPoolEntry entry = iter.next();
            iter.remove();
            closeConnection(entry.getConnection());
        }
        idleConnHandler.removeAll();

        isShutDown = true;

    } finally {
        poolLock.unlock();
    }
}

From source file:org.apache.http.impl.conn.tsccm.ConnPoolByRoute.java

private void closeConnection(final BasicPoolEntry entry) {
    final OperatedClientConnection conn = entry.getConnection();
    if (conn != null) {
        try {// w w w. j a va 2s.c  om
            conn.close();
        } catch (final IOException ex) {
            log.debug("I/O error closing connection", ex);
        }
    }
}

From source file:org.apache.http.impl.conn.tsccm.ConnPoolByRoute.java

@Override
public void deleteClosedConnections() {
    poolLock.lock();//from  ww w  . java  2 s  .c  o m
    try {
        final Iterator<BasicPoolEntry> iter = freeConnections.iterator();
        while (iter.hasNext()) {
            final BasicPoolEntry entry = iter.next();
            if (!entry.getConnection().isOpen()) {
                iter.remove();
                deleteEntry(entry);
            }
        }
    } finally {
        poolLock.unlock();
    }
}

From source file:org.apache.http.impl.conn.tsccm.RouteSpecificPool.java

/**
 * Obtains a free entry from this pool, if one is available.
 *
 * @return an available pool entry, or <code>null</code> if there is none
 *///  w w w.ja va2 s.  c o m
public BasicPoolEntry allocEntry(final Object state) {
    if (!freeEntries.isEmpty()) {
        final ListIterator<BasicPoolEntry> it = freeEntries.listIterator(freeEntries.size());
        while (it.hasPrevious()) {
            final BasicPoolEntry entry = it.previous();
            if (entry.getState() == null || LangUtils.equals(state, entry.getState())) {
                it.remove();
                return entry;
            }
        }
    }
    if (getCapacity() == 0 && !freeEntries.isEmpty()) {
        final BasicPoolEntry entry = freeEntries.remove();
        entry.shutdownEntry();
        final OperatedClientConnection conn = entry.getConnection();
        try {
            conn.close();
        } catch (final IOException ex) {
            log.debug("I/O error closing connection", ex);
        }
        return entry;
    }
    return null;
}