Java 类org.apache.http.conn.ClientConnectionOperator 实例源码

项目:lams    文件:ManagedClientConnectionImpl.java   
ManagedClientConnectionImpl(
        final ClientConnectionManager manager,
        final ClientConnectionOperator operator,
        final HttpPoolEntry entry) {
    super();
    if (manager == null) {
        throw new IllegalArgumentException("Connection manager may not be null");
    }
    if (operator == null) {
        throw new IllegalArgumentException("Connection operator may not be null");
    }
    if (entry == null) {
        throw new IllegalArgumentException("HTTP pool entry may not be null");
    }
    this.manager = manager;
    this.operator = operator;
    this.poolEntry = entry;
    this.reusable = false;
    this.duration = Long.MAX_VALUE;
}
项目:lams    文件:ConnPoolByRoute.java   
/**
 * @since 4.1
 */
public ConnPoolByRoute(
        final ClientConnectionOperator operator,
        final ConnPerRoute connPerRoute,
        int maxTotalConnections,
        long connTTL,
        final TimeUnit connTTLTimeUnit) {
    super();
    if (operator == null) {
        throw new IllegalArgumentException("Connection operator may not be null");
    }
    if (connPerRoute == null) {
        throw new IllegalArgumentException("Connections per route may not be null");
    }
    this.poolLock = super.poolLock;
    this.leasedConnections = super.leasedConnections;
    this.operator = operator;
    this.connPerRoute = connPerRoute;
    this.maxTotalConnections = maxTotalConnections;
    this.freeConnections = createFreeConnQueue();
    this.waitingThreads  = createWaitingThreadQueue();
    this.routeToPool     = createRouteToPoolMap();
    this.connTTL = connTTL;
    this.connTTLTimeUnit = connTTLTimeUnit;
}
项目:lams    文件:ConnPoolByRoute.java   
/**
 * Creates a new pool entry.
 * This method assumes that the new connection will be handed
 * out immediately.
 *
 * @param rospl       the route-specific pool for which to create the entry
 * @param op        the operator for creating a connection
 *
 * @return  the new pool entry for a new connection
 */
protected BasicPoolEntry createEntry(RouteSpecificPool rospl,
                                     ClientConnectionOperator op) {

    if (log.isDebugEnabled()) {
        log.debug("Creating new connection [" + rospl.getRoute() + "]");
    }

    // the entry will create the connection when needed
    BasicPoolEntry entry = new BasicPoolEntry(op, rospl.getRoute(), connTTL, connTTLTimeUnit);

    poolLock.lock();
    try {
        rospl.createdEntry(entry);
        numConnections++;
        leasedConnections.add(entry);
    } finally {
        poolLock.unlock();
    }

    return entry;
}
项目:purecloud-iot    文件:ConnPoolByRoute.java   
/**
 * @since 4.1
 */
public ConnPoolByRoute(
        final ClientConnectionOperator operator,
        final ConnPerRoute connPerRoute,
        final int maxTotalConnections,
        final long connTTL,
        final TimeUnit connTTLTimeUnit) {
    super();
    Args.notNull(operator, "Connection operator");
    Args.notNull(connPerRoute, "Connections per route");
    this.poolLock = super.poolLock;
    this.leasedConnections = super.leasedConnections;
    this.operator = operator;
    this.connPerRoute = connPerRoute;
    this.maxTotalConnections = maxTotalConnections;
    this.freeConnections = createFreeConnQueue();
    this.waitingThreads  = createWaitingThreadQueue();
    this.routeToPool     = createRouteToPoolMap();
    this.connTTL = connTTL;
    this.connTTLTimeUnit = connTTLTimeUnit;
}
项目:purecloud-iot    文件:ConnPoolByRoute.java   
/**
 * Creates a new pool entry.
 * This method assumes that the new connection will be handed
 * out immediately.
 *
 * @param rospl       the route-specific pool for which to create the entry
 * @param op        the operator for creating a connection
 *
 * @return  the new pool entry for a new connection
 */
protected BasicPoolEntry createEntry(final RouteSpecificPool rospl,
                                     final ClientConnectionOperator op) {

    if (log.isDebugEnabled()) {
        log.debug("Creating new connection [" + rospl.getRoute() + "]");
    }

    // the entry will create the connection when needed
    final BasicPoolEntry entry = new BasicPoolEntry(op, rospl.getRoute(), connTTL, connTTLTimeUnit);

    poolLock.lock();
    try {
        rospl.createdEntry(entry);
        numConnections++;
        leasedConnections.add(entry);
    } finally {
        poolLock.unlock();
    }

    return entry;
}
项目:cJUnit-mc626    文件:ConnPoolByRoute.java   
/**
 * Creates a new pool entry.
 * This method assumes that the new connection will be handed
 * out immediately.
 *
 * @param rospl       the route-specific pool for which to create the entry
 * @param op        the operator for creating a connection
 *
 * @return  the new pool entry for a new connection
 */
protected BasicPoolEntry createEntry(RouteSpecificPool rospl,
                                     ClientConnectionOperator op) {

    if (log.isDebugEnabled()) {
        log.debug("Creating new connection [" + rospl.getRoute() + "]");
    }

    // the entry will create the connection when needed
    BasicPoolEntry entry = new BasicPoolEntry(op, rospl.getRoute());

    poolLock.lock();
    try {
        rospl.createdEntry(entry);
        numConnections++;
        leasedConnections.add(entry);
    } finally {
        poolLock.unlock();
    }

    return entry;
}
项目:lams    文件:ConnPoolByRoute.java   
/**
 * Creates a new connection pool, managed by route.
 *
 * @since 4.1
 */
public ConnPoolByRoute(
        final ClientConnectionOperator operator,
        final ConnPerRoute connPerRoute,
        int maxTotalConnections) {
    this(operator, connPerRoute, maxTotalConnections, -1, TimeUnit.MILLISECONDS);
}
项目:lams    文件:BasicPoolEntry.java   
public BasicPoolEntry(ClientConnectionOperator op,
                      HttpRoute route,
                      ReferenceQueue<Object> queue) {
    super(op, route);
    if (route == null) {
        throw new IllegalArgumentException("HTTP route may not be null");
    }
    this.created = System.currentTimeMillis();
    this.validUntil = Long.MAX_VALUE;
    this.expiry = this.validUntil;
}
项目:lams    文件:BasicPoolEntry.java   
/**
 * Creates a new pool entry with a specified maximum lifetime.
 *
 * @param op        the connection operator
 * @param route     the planned route for the connection
 * @param connTTL   maximum lifetime of this entry, <=0 implies "infinity"
 * @param timeunit  TimeUnit of connTTL
 *
 * @since 4.1
 */
public BasicPoolEntry(ClientConnectionOperator op,
                      HttpRoute route, long connTTL, TimeUnit timeunit) {
    super(op, route);
    if (route == null) {
        throw new IllegalArgumentException("HTTP route may not be null");
    }
    this.created = System.currentTimeMillis();
    if (connTTL > 0) {
        this.validUntil = this.created + timeunit.toMillis(connTTL);
    } else {
        this.validUntil = Long.MAX_VALUE;
    }
    this.expiry = this.validUntil;
}
项目:lams    文件:AbstractPoolEntry.java   
/**
 * Creates a new pool entry.
 *
 * @param connOperator     the Connection Operator for this entry
 * @param route   the planned route for the connection,
 *                or <code>null</code>
 */
protected AbstractPoolEntry(ClientConnectionOperator connOperator,
                            HttpRoute route) {
    super();
    if (connOperator == null) {
        throw new IllegalArgumentException("Connection operator may not be null");
    }
    this.connOperator = connOperator;
    this.connection = connOperator.createConnection();
    this.route = route;
    this.tracker = null;
}
项目:purecloud-iot    文件:HttpConnPool.java   
public HttpConnPool(final Log log,
        final ClientConnectionOperator connOperator,
        final int defaultMaxPerRoute, final int maxTotal,
        final long timeToLive, final TimeUnit tunit) {
    super(new InternalConnFactory(connOperator), defaultMaxPerRoute, maxTotal);
    this.log = log;
    this.timeToLive = timeToLive;
    this.tunit = tunit;
}
项目:purecloud-iot    文件:ManagedClientConnectionImpl.java   
ManagedClientConnectionImpl(
        final ClientConnectionManager manager,
        final ClientConnectionOperator operator,
        final HttpPoolEntry entry) {
    super();
    Args.notNull(manager, "Connection manager");
    Args.notNull(operator, "Connection operator");
    Args.notNull(entry, "HTTP pool entry");
    this.manager = manager;
    this.operator = operator;
    this.poolEntry = entry;
    this.reusable = false;
    this.duration = Long.MAX_VALUE;
}
项目:purecloud-iot    文件:ConnPoolByRoute.java   
/**
 * Creates a new connection pool, managed by route.
 *
 * @since 4.1
 */
public ConnPoolByRoute(
        final ClientConnectionOperator operator,
        final ConnPerRoute connPerRoute,
        final int maxTotalConnections) {
    this(operator, connPerRoute, maxTotalConnections, -1, TimeUnit.MILLISECONDS);
}
项目:purecloud-iot    文件:ConnPoolByRoute.java   
/**
 * Creates a new connection pool, managed by route.
 *
 * @deprecated (4.1)  use {@link ConnPoolByRoute#ConnPoolByRoute(ClientConnectionOperator, ConnPerRoute, int)}
 */
@Deprecated
public ConnPoolByRoute(final ClientConnectionOperator operator, final HttpParams params) {
    this(operator,
            ConnManagerParams.getMaxConnectionsPerRoute(params),
            ConnManagerParams.getMaxTotalConnections(params));
}
项目:purecloud-iot    文件:BasicPoolEntry.java   
public BasicPoolEntry(final ClientConnectionOperator op,
                      final HttpRoute route,
                      final ReferenceQueue<Object> queue) {
    super(op, route);
    Args.notNull(route, "HTTP route");
    this.created = System.currentTimeMillis();
    this.validUntil = Long.MAX_VALUE;
    this.expiry = this.validUntil;
}
项目:purecloud-iot    文件:BasicPoolEntry.java   
/**
 * Creates a new pool entry with a specified maximum lifetime.
 *
 * @param op        the connection operator
 * @param route     the planned route for the connection
 * @param connTTL   maximum lifetime of this entry, &lt;=0 implies "infinity"
 * @param timeunit  TimeUnit of connTTL
 *
 * @since 4.1
 */
public BasicPoolEntry(final ClientConnectionOperator op,
                      final HttpRoute route, final long connTTL, final TimeUnit timeunit) {
    super(op, route);
    Args.notNull(route, "HTTP route");
    this.created = System.currentTimeMillis();
    if (connTTL > 0) {
        this.validUntil = this.created + timeunit.toMillis(connTTL);
    } else {
        this.validUntil = Long.MAX_VALUE;
    }
    this.expiry = this.validUntil;
}
项目:purecloud-iot    文件:AbstractPoolEntry.java   
/**
 * Creates a new pool entry.
 *
 * @param connOperator     the Connection Operator for this entry
 * @param route   the planned route for the connection,
 *                or {@code null}
 */
protected AbstractPoolEntry(final ClientConnectionOperator connOperator,
                            final HttpRoute route) {
    super();
    Args.notNull(connOperator, "Connection operator");
    this.connOperator = connOperator;
    this.connection = connOperator.createConnection();
    this.route = route;
    this.tracker = null;
}
项目:cJUnit-mc626    文件:ConnPoolByRoute.java   
/**
 * Creates a new connection pool, managed by route.
 */
public ConnPoolByRoute(final ClientConnectionOperator operator, final HttpParams params) {
    super();
    if (operator == null) {
        throw new IllegalArgumentException("Connection operator may not be null");
    }
    this.operator = operator;
    this.params = params;

    freeConnections = createFreeConnQueue();
    waitingThreads  = createWaitingThreadQueue();
    routeToPool     = createRouteToPoolMap();
}
项目:cJUnit-mc626    文件:BasicPoolEntry.java   
/**
 * @deprecated do not use
 */
@Deprecated
public BasicPoolEntry(ClientConnectionOperator op,
                      HttpRoute route,
                      ReferenceQueue<Object> queue) {
    super(op, route);
    if (route == null) {
        throw new IllegalArgumentException("HTTP route may not be null");
    }
}
项目:cJUnit-mc626    文件:BasicPoolEntry.java   
/**
 * Creates a new pool entry.
 *
 * @param op      the connection operator
 * @param route   the planned route for the connection
 */
public BasicPoolEntry(ClientConnectionOperator op,
                      HttpRoute route) {
    super(op, route);
    if (route == null) {
        throw new IllegalArgumentException("HTTP route may not be null");
    }
}
项目:cJUnit-mc626    文件:AbstractPoolEntry.java   
/**
 * Creates a new pool entry.
 *
 * @param connOperator     the Connection Operator for this entry
 * @param route   the planned route for the connection,
 *                or <code>null</code>
 */
protected AbstractPoolEntry(ClientConnectionOperator connOperator,
                            HttpRoute route) {
    super();
    if (connOperator == null) {
        throw new IllegalArgumentException("Connection operator may not be null");
    }
    this.connOperator = connOperator;
    this.connection = connOperator.createConnection();
    this.route = route;
    this.tracker = null;
}
项目:ribbon    文件:NamedConnectionPool.java   
@Override
protected BasicPoolEntry createEntry(RouteSpecificPool rospl,
        ClientConnectionOperator op) {
    createEntryCounter.increment();
    Stopwatch stopWatch = creationTimer.start();
    try {
        return super.createEntry(rospl, op);
    } finally {
        stopWatch.stop();
    }
}
项目:lams    文件:BasicClientConnectionManager.java   
protected ClientConnectionOperator createConnectionOperator(final SchemeRegistry schreg) {
    return new DefaultClientConnectionOperator(schreg);
}
项目:lams    文件:ConnPoolByRoute.java   
/**
 * Creates a new connection pool, managed by route.
 *
 * @deprecated (4.1)  use {@link ConnPoolByRoute#ConnPoolByRoute(ClientConnectionOperator, ConnPerRoute, int)}
 */
public ConnPoolByRoute(final ClientConnectionOperator operator, final HttpParams params) {
    this(operator,
            ConnManagerParams.getMaxConnectionsPerRoute(params),
            ConnManagerParams.getMaxTotalConnections(params));
}
项目:PhET    文件:OperatorConnectDirect.java   
public static void main(String[] args) throws Exception {
    HttpHost target = new HttpHost("jakarta.apache.org", 80, "http");

    // some general setup
    // Register the "http" protocol scheme, it is required
    // by the default operator to look up socket factories.
    SchemeRegistry supportedSchemes = new SchemeRegistry();
    SocketFactory sf = PlainSocketFactory.getSocketFactory();
    supportedSchemes.register(new Scheme("http", sf, 80));

    // Prepare parameters.
    // Since this example doesn't use the full core framework,
    // only few parameters are actually required.
    HttpParams params = new BasicHttpParams();
    HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
    HttpProtocolParams.setUseExpectContinue(params, false);

    // one operator can be used for many connections
    ClientConnectionOperator scop = new DefaultClientConnectionOperator(supportedSchemes);

    HttpRequest req = new BasicHttpRequest("OPTIONS", "*", HttpVersion.HTTP_1_1);
    req.addHeader("Host", target.getHostName());

    HttpContext ctx = new BasicHttpContext();

    OperatedClientConnection conn = scop.createConnection();
    try {
        System.out.println("opening connection to " + target);
        scop.openConnection(conn, target, null, ctx, params);
        System.out.println("sending request");
        conn.sendRequestHeader(req);
        // there is no request entity
        conn.flush();

        System.out.println("receiving response header");
        HttpResponse rsp = conn.receiveResponseHeader();

        System.out.println("----------------------------------------");
        System.out.println(rsp.getStatusLine());
        Header[] headers = rsp.getAllHeaders();
        for (int i = 0; i < headers.length; i++) {
            System.out.println(headers[i]);
        }
        System.out.println("----------------------------------------");
    } finally {
        System.out.println("closing connection");
        conn.close();
    }
}
项目:cloud-meter    文件:MeasuringConnectionManager.java   
/**
 * Overriden to use {@link JMeterClientConnectionOperator} and fix SNI issue 
 * @see "https://bz.apache.org/bugzilla/show_bug.cgi?id=57935"
 * @see org.apache.http.impl.conn.PoolingClientConnectionManager#createConnectionOperator(org.apache.http.conn.scheme.SchemeRegistry)
 */
@Override
protected ClientConnectionOperator createConnectionOperator(
        SchemeRegistry schreg) {
    return new JMeterClientConnectionOperator(schreg);
}
项目:purecloud-iot    文件:HttpConnPool.java   
InternalConnFactory(final ClientConnectionOperator connOperator) {
    this.connOperator = connOperator;
}
项目:purecloud-iot    文件:BasicClientConnectionManager.java   
protected ClientConnectionOperator createConnectionOperator(final SchemeRegistry schreg) {
    return new DefaultClientConnectionOperator(schreg);
}
项目:FMTech    文件:ElegantThreadSafeConnManager.java   
public ElegantPool(ClientConnectionOperator paramClientConnectionOperator, HttpParams paramHttpParams)
{
  super(paramHttpParams);
}
项目:MediaPlayerProxy    文件:HttpUtils.java   
@Override
protected ClientConnectionOperator createConnectionOperator(final SchemeRegistry sr) {
    return new MyClientConnectionOperator(sr);
}
项目:cJUnit-mc626    文件:OperatorConnectDirect.java   
public static void main(String[] args) throws Exception {
    HttpHost target = new HttpHost("jakarta.apache.org", 80, "http");

    // some general setup
    // Register the "http" protocol scheme, it is required
    // by the default operator to look up socket factories.
    SchemeRegistry supportedSchemes = new SchemeRegistry();
    SocketFactory sf = PlainSocketFactory.getSocketFactory();
    supportedSchemes.register(new Scheme("http", sf, 80));

    // Prepare parameters.
    // Since this example doesn't use the full core framework,
    // only few parameters are actually required.
    HttpParams params = new BasicHttpParams();
    HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
    HttpProtocolParams.setUseExpectContinue(params, false);

    // one operator can be used for many connections
    ClientConnectionOperator scop = new DefaultClientConnectionOperator(supportedSchemes);

    HttpRequest req = new BasicHttpRequest("OPTIONS", "*", HttpVersion.HTTP_1_1);
    req.addHeader("Host", target.getHostName());

    HttpContext ctx = new BasicHttpContext();

    OperatedClientConnection conn = scop.createConnection();
    try {
        System.out.println("opening connection to " + target);
        scop.openConnection(conn, target, null, ctx, params);
        System.out.println("sending request");
        conn.sendRequestHeader(req);
        // there is no request entity
        conn.flush();

        System.out.println("receiving response header");
        HttpResponse rsp = conn.receiveResponseHeader();

        System.out.println("----------------------------------------");
        System.out.println(rsp.getStatusLine());
        Header[] headers = rsp.getAllHeaders();
        for (int i = 0; i < headers.length; i++) {
            System.out.println(headers[i]);
        }
        System.out.println("----------------------------------------");
    } finally {
        System.out.println("closing connection");
        conn.close();
    }
}
项目:olingo-odata4    文件:CustomConnectionsHttpClientFactory.java   
@Override
protected ClientConnectionOperator createConnectionOperator(final SchemeRegistry registry) {
  return new MyClientConnectionOperator(registry);
}
项目:ribbon    文件:NamedConnectionPool.java   
public NamedConnectionPool(String name, ClientConnectionOperator operator,
        ConnPerRoute connPerRoute, int maxTotalConnections, long connTTL,
        TimeUnit connTTLTimeUnit) {
    super(operator, connPerRoute, maxTotalConnections, connTTL, connTTLTimeUnit);
    initMonitors(name);
}
项目:ribbon    文件:NamedConnectionPool.java   
public NamedConnectionPool(String name, ClientConnectionOperator operator,
        ConnPerRoute connPerRoute, int maxTotalConnections) {
    super(operator, connPerRoute, maxTotalConnections);
    initMonitors(name);
}
项目:ribbon    文件:NamedConnectionPool.java   
public NamedConnectionPool(String name, ClientConnectionOperator operator,
        HttpParams params) {
    super(operator, params);
    initMonitors(name);
}
项目:ribbon    文件:NamedConnectionPool.java   
NamedConnectionPool(ClientConnectionOperator operator,
        ConnPerRoute connPerRoute, int maxTotalConnections, long connTTL,
        TimeUnit connTTLTimeUnit) {
    super(operator, connPerRoute, maxTotalConnections, connTTL, connTTLTimeUnit);
}
项目:ribbon    文件:NamedConnectionPool.java   
NamedConnectionPool(ClientConnectionOperator operator,
        ConnPerRoute connPerRoute, int maxTotalConnections) {
    super(operator, connPerRoute, maxTotalConnections);
}
项目:ribbon    文件:NamedConnectionPool.java   
NamedConnectionPool(ClientConnectionOperator operator,
        HttpParams params) {
    super(operator, params);
}
项目:cougar    文件:CougarClientConnManager.java   
private CougarConnPoolByRoute(ClientConnectionOperator operator, ConnPerRoute connPerRoute,
                              int maxTotalConnections, long connTTL, TimeUnit connTTLTimeUnit) {
    super(operator, connPerRoute, maxTotalConnections, connTTL, connTTLTimeUnit);
}
项目:LibraryH3lp-Transfer-Bot    文件:OperatorConnectDirect.java   
public static void main(String[] args) throws Exception {
    HttpHost target = new HttpHost("jakarta.apache.org", 80, "http");

    // some general setup
    // Register the "http" protocol scheme, it is required
    // by the default operator to look up socket factories.
    SchemeRegistry supportedSchemes = new SchemeRegistry();
    supportedSchemes.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));

    // Prepare parameters.
    // Since this example doesn't use the full core framework,
    // only few parameters are actually required.
    HttpParams params = new SyncBasicHttpParams();
    HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
    HttpProtocolParams.setUseExpectContinue(params, false);

    // one operator can be used for many connections
    ClientConnectionOperator scop = new DefaultClientConnectionOperator(supportedSchemes);

    HttpRequest req = new BasicHttpRequest("OPTIONS", "*", HttpVersion.HTTP_1_1);
    req.addHeader("Host", target.getHostName());

    HttpContext ctx = new BasicHttpContext();

    OperatedClientConnection conn = scop.createConnection();
    try {
        System.out.println("opening connection to " + target);
        scop.openConnection(conn, target, null, ctx, params);
        System.out.println("sending request");
        conn.sendRequestHeader(req);
        // there is no request entity
        conn.flush();

        System.out.println("receiving response header");
        HttpResponse rsp = conn.receiveResponseHeader();

        System.out.println("----------------------------------------");
        System.out.println(rsp.getStatusLine());
        Header[] headers = rsp.getAllHeaders();
        for (int i = 0; i < headers.length; i++) {
            System.out.println(headers[i]);
        }
        System.out.println("----------------------------------------");
    } finally {
        System.out.println("closing connection");
        conn.close();
    }
}