Package org.apache.http.nio

Examples of org.apache.http.nio.NHttpClientConnection


            return false;
        }
    }

    public boolean isStale() {
        final NHttpClientConnection conn = getConnection();
        if (conn != null) {
            return conn.isStale() || !conn.isOpen();
        } else {
            return true;
        }
    }
View Full Code Here


        } else if (method.equals(IS_STALE_METHOD)) {
            return Boolean.valueOf(isStale());
        } else if (method.equals(TO_STRING)) {
            return "Managed connection";
        } else {
            final NHttpClientConnection conn = getConnection();
            if (conn == null) {
                throw new ConnectionShutdownException();
            }
            try {
                return method.invoke(conn, args);
View Full Code Here

            final InternalConnManager connManager) throws IOException, HttpException {
        final HttpClientContext localContext = state.getLocalContext();
        final HttpAsyncRequestProducer requestProducer = state.getRequestProducer();
        final HttpRoute route = state.getRoute();
        final RouteTracker routeTracker = state.getRouteTracker();
        final NHttpClientConnection managedConn = connManager.getConnection();
        if (!state.isRouteEstablished()) {
            int step;
            loop:
            do {
                final HttpRoute fact = routeTracker.toRoute();
View Full Code Here

                                    decoder.read(buf);
                                }

                                @Override
                                protected Object buildResult(final HttpContext context) throws Exception {
                                    final NHttpClientConnection conn = (NHttpClientConnection) context.getAttribute(
                                            IOEventDispatch.CONNECTION_KEY);

                                    final PoolEntry<?, ?> entry = CPoolUtils.getPoolEntry(conn);
                                    return entry.getState();
                                }
View Full Code Here

        Args.notNull(responseConsumer, "HTTP response consumer");
        Args.notNull(connPool, "HTTP connection pool");
        Args.notNull(poolEntry, "Pool entry");
        Args.notNull(context, "HTTP context");
        final BasicFuture<T> future = new BasicFuture<T>(callback);
        final NHttpClientConnection conn = poolEntry.getConnection();
        final BasicAsyncClientExchangeHandler<T> handler = new BasicAsyncClientExchangeHandler<T>(
                requestProducer, responseConsumer,
                new RequestExecutionCallback<T, E>(future, poolEntry, connPool),
                context, conn,
                this.httpprocessor, this.connReuseStrategy);
View Full Code Here

        Args.notEmpty(responseConsumers, "Response consumer list");
        Args.notNull(connPool, "HTTP connection pool");
        Args.notNull(poolEntry, "Pool entry");
        Args.notNull(context, "HTTP context");
        final BasicFuture<List<T>> future = new BasicFuture<List<T>>(callback);
        final NHttpClientConnection conn = poolEntry.getConnection();
        final PipeliningClientExchangeHandler<T> handler = new PipeliningClientExchangeHandler<T>(
                requestProducers, responseConsumers,
                new RequestExecutionCallback<List<T>, E>(future, poolEntry, connPool),
                context, conn,
                this.httpprocessor, this.connReuseStrategy);
View Full Code Here

        public void completed(final E result) {
            if (this.requestFuture.isDone()) {
                this.connPool.release(result, true);
                return;
            }
            final NHttpClientConnection conn = result.getConnection();
            final BasicAsyncClientExchangeHandler<T> handler = new BasicAsyncClientExchangeHandler<T>(
                    this.requestProducer, this.responseConsumer,
                    new RequestExecutionCallback<T, E>(this.requestFuture, result, this.connPool),
                    this.context, conn, httpprocessor, connReuseStrategy);
            initExection(handler, conn);
View Full Code Here

        public void completed(final E result) {
            if (this.requestFuture.isDone()) {
                this.connPool.release(result, true);
                return;
            }
            final NHttpClientConnection conn = result.getConnection();
            final PipeliningClientExchangeHandler<T> handler = new PipeliningClientExchangeHandler<T>(
                    this.requestProducers, this.responseConsumers,
                    new RequestExecutionCallback<List<T>, E>(this.requestFuture, result, this.connPool),
                    this.context, conn, httpprocessor, connReuseStrategy);
            initExection(handler, conn);
View Full Code Here

            }
            HttpHost httpHost = new HttpHost(url.getHost(), port, url.getProtocol());

            Axis2HttpRequest axis2Req = new Axis2HttpRequest(epr, httpHost, msgContext);

            NHttpClientConnection conn = ConnectionPool.getConnection(url.getHost(), port);

            if (conn == null) {
                ioReactor.connect(new InetSocketAddress(url.getHost(), port),
                    null, axis2Req, sessionRequestCallback);
                if (log.isDebugEnabled()) {
View Full Code Here

                return;
            }
            if (this.log.isDebugEnabled()) {
                this.log.debug("Releasing connection: " + format(entry) + formatStats(entry.getRoute()));
            }
            final NHttpClientConnection conn = entry.getConnection();
            try {
                if (conn.isOpen()) {
                    entry.setState(state);
                    entry.updateExpiry(keepalive, tunit != null ? tunit : TimeUnit.MILLISECONDS);
                    if (this.log.isDebugEnabled()) {
                        final String s;
                        if (keepalive > 0) {
                            s = "for " + (double) keepalive / 1000 + " seconds";
                        } else {
                            s = "indefinitely";
                        }
                        this.log.debug("Connection " + format(entry) + " can be kept alive " + s);
                    }
                }
            } finally {
                this.pool.release(entry, conn.isOpen() && entry.isRouteComplete());
                if (this.log.isDebugEnabled()) {
                    this.log.debug("Connection released: " + format(entry) + formatStats(entry.getRoute()));
                }
            }
        }
View Full Code Here

TOP

Related Classes of org.apache.http.nio.NHttpClientConnection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.