Example usage for org.apache.http.util Args notNull

List of usage examples for org.apache.http.util Args notNull

Introduction

In this page you can find the example usage for org.apache.http.util Args notNull.

Prototype

public static <T> T notNull(T t, String str) 

Source Link

Usage

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

public void closeIdleConnections(final long idletime, final TimeUnit tunit) {
    Args.notNull(tunit, "Time unit");
    synchronized (this) {
        assertNotShutdown();/*from  w w w .j a va  2 s  .  c  o m*/
        long time = tunit.toMillis(idletime);
        if (time < 0) {
            time = 0;
        }
        final long deadline = System.currentTimeMillis() - time;
        if (this.poolEntry != null && this.poolEntry.getUpdated() <= deadline) {
            this.poolEntry.close();
            this.poolEntry.getTracker().reset();
        }
    }
}

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

public final ConnectionRequest requestConnection(final HttpRoute route, final Object state) {
    Args.notNull(route, "Route");
    return new ConnectionRequest() {

        public boolean cancel() {
            // Nothing to abort, since requests are immediate.
            return false;
        }//from w  w  w .  java  2s.c o m

        public HttpClientConnection get(final long timeout, final TimeUnit tunit) {
            return BasicHttpClientConnectionManager.this.getConnection(route, state);
        }

    };
}

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

public synchronized void releaseConnection(final HttpClientConnection conn, final Object state,
        final long keepalive, final TimeUnit tunit) {
    Args.notNull(conn, "Connection");
    Asserts.check(conn == this.conn, "Connection not obtained from this manager");
    if (this.log.isDebugEnabled()) {
        this.log.debug("Releasing connection " + conn);
    }/*from   w  w  w  .j  a va2s.  c  om*/
    if (this.shutdown) {
        shutdownConnection();
        return;
    }
    try {
        this.updated = System.currentTimeMillis();
        if (!this.conn.isOpen()) {
            this.conn = null;
            this.route = null;
            this.conn = null;
            this.expiry = Long.MAX_VALUE;
        } else {
            this.state = state;
            if (this.log.isDebugEnabled()) {
                final String s;
                if (keepalive > 0) {
                    s = "for " + keepalive + " " + tunit;
                } else {
                    s = "indefinitely";
                }
                this.log.debug("Connection can be kept alive " + s);
            }
            if (keepalive > 0) {
                this.expiry = this.updated + tunit.toMillis(keepalive);
            } else {
                this.expiry = Long.MAX_VALUE;
            }
        }
    } finally {
        this.leased = false;
    }
}

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

public void connect(final HttpClientConnection conn, final HttpRoute route, final int connectTimeout,
        final HttpContext context) throws IOException {
    Args.notNull(conn, "Connection");
    Args.notNull(route, "HTTP route");
    Asserts.check(conn == this.conn, "Connection not obtained from this manager");
    final HttpHost host;
    if (route.getProxyHost() != null) {
        host = route.getProxyHost();/*from   w ww  . jav  a2  s.  c o m*/
    } else {
        host = route.getTargetHost();
    }
    final InetSocketAddress localAddress = route.getLocalSocketAddress();
    this.connectionOperator.connect(this.conn, host, localAddress, connectTimeout, this.socketConfig, context);
}

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

public void upgrade(final HttpClientConnection conn, final HttpRoute route, final HttpContext context)
        throws IOException {
    Args.notNull(conn, "Connection");
    Args.notNull(route, "HTTP route");
    Asserts.check(conn == this.conn, "Connection not obtained from this manager");
    this.connectionOperator.upgrade(this.conn, route.getTargetHost(), context);
}

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

public synchronized void closeIdleConnections(final long idletime, final TimeUnit tunit) {
    Args.notNull(tunit, "Time unit");
    if (this.shutdown) {
        return;/*from  w w w. j ava2  s .  c  o m*/
    }
    if (!this.leased) {
        long time = tunit.toMillis(idletime);
        if (time < 0) {
            time = 0;
        }
        final long deadline = System.currentTimeMillis() - time;
        if (this.updated <= deadline) {
            closeConnection();
        }
    }
}

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

public void openCompleted(final boolean secure, final HttpParams params) throws IOException {
    Args.notNull(params, "Parameters");
    assertNotOpen();//  w ww . j  av a  2s. c om
    this.connSecure = secure;
    bind(this.socket, params);
}

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

public void update(final Socket sock, final HttpHost target, final boolean secure, final HttpParams params)
        throws IOException {

    assertOpen();//from   w  w w.  j av  a2 s  .  c o  m
    Args.notNull(target, "Target host");
    Args.notNull(params, "Parameters");

    if (sock != null) {
        this.socket = sock;
        bind(sock, params);
    }
    targetHost = target;
    connSecure = secure;
}

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

/**
 * Creates a new client connection operator for the given scheme registry.
 *
 * @param schemes   the scheme registry//from  www . j a va  2s.  c  o  m
 *
 * @since 4.2
 */
public DefaultClientConnectionOperator(final SchemeRegistry schemes) {
    Args.notNull(schemes, "Scheme registry");
    this.schemeRegistry = schemes;
    this.dnsResolver = new SystemDefaultDnsResolver();
}

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

/**
* Creates a new client connection operator for the given scheme registry
* and the given custom DNS lookup mechanism.
*
* @param schemes//from   w w  w. j a  va 2 s  . c  o m
*            the scheme registry
* @param dnsResolver
*            the custom DNS lookup mechanism
*/
public DefaultClientConnectionOperator(final SchemeRegistry schemes, final DnsResolver dnsResolver) {
    Args.notNull(schemes, "Scheme registry");

    Args.notNull(dnsResolver, "DNS resolver");

    this.schemeRegistry = schemes;
    this.dnsResolver = dnsResolver;
}