Example usage for org.apache.http.impl.nio.conn CPoolProxy getPoolEntry

List of usage examples for org.apache.http.impl.nio.conn CPoolProxy getPoolEntry

Introduction

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

Prototype

public static CPoolEntry getPoolEntry(final NHttpClientConnection proxy) 

Source Link

Usage

From source file:org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.java

@Override
public void startRoute(final NHttpClientConnection managedConn, final HttpRoute route,
        final HttpContext context) throws IOException {
    Args.notNull(managedConn, "Managed connection");
    Args.notNull(route, "HTTP route");
    final HttpHost host;
    if (route.getProxyHost() != null) {
        host = route.getProxyHost();// w  w w. jav  a  2s. com
    } else {
        host = route.getTargetHost();
    }
    final Lookup<SchemeIOSessionStrategy> reg = getIOSessionFactoryRegistry(context);
    final SchemeIOSessionStrategy sf = reg.lookup(host.getSchemeName());
    if (sf == null) {
        throw new UnsupportedSchemeException(host.getSchemeName() + " protocol is not supported");
    }
    if (sf.isLayeringRequired()) {
        synchronized (managedConn) {
            final CPoolEntry entry = CPoolProxy.getPoolEntry(managedConn);
            final ManagedNHttpClientConnection conn = entry.getConnection();
            final IOSession ioSession = conn.getIOSession();
            final IOSession currentSession = sf.upgrade(host, ioSession);
            conn.bind(currentSession);
        }
    }
}

From source file:org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.java

@Override
public void upgrade(final NHttpClientConnection managedConn, final HttpRoute route, final HttpContext context)
        throws IOException {
    Args.notNull(managedConn, "Managed connection");
    Args.notNull(route, "HTTP route");
    final HttpHost host = route.getTargetHost();
    final Lookup<SchemeIOSessionStrategy> reg = getIOSessionFactoryRegistry(context);
    final SchemeIOSessionStrategy sf = reg.lookup(host.getSchemeName());
    if (sf == null) {
        throw new UnsupportedSchemeException(host.getSchemeName() + " protocol is not supported");
    }/*from   w w w  . j a  v  a  2 s.  c o  m*/
    if (!sf.isLayeringRequired()) {
        throw new UnsupportedSchemeException(
                host.getSchemeName() + " protocol does not support connection upgrade");
    }
    synchronized (managedConn) {
        final CPoolEntry entry = CPoolProxy.getPoolEntry(managedConn);
        final ManagedNHttpClientConnection conn = entry.getConnection();
        final IOSession currentSession = sf.upgrade(host, conn.getIOSession());
        conn.bind(currentSession);
    }
}

From source file:org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.java

@Override
public void routeComplete(final NHttpClientConnection managedConn, final HttpRoute route,
        final HttpContext context) {
    Args.notNull(managedConn, "Managed connection");
    Args.notNull(route, "HTTP route");
    synchronized (managedConn) {
        final CPoolEntry entry = CPoolProxy.getPoolEntry(managedConn);
        entry.markRouteComplete();//www .ja v a 2s  . com
    }
}

From source file:org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.java

@Override
public boolean isRouteComplete(final NHttpClientConnection managedConn) {
    Args.notNull(managedConn, "Managed connection");
    synchronized (managedConn) {
        final CPoolEntry entry = CPoolProxy.getPoolEntry(managedConn);
        return entry.isRouteComplete();
    }//  www .  ja v  a2s  .c o m
}