Example usage for org.apache.http.impl.conn.tsccm ThreadSafeClientConnManager ThreadSafeClientConnManager

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

Introduction

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

Prototype

public ThreadSafeClientConnManager() 

Source Link

Usage

From source file:de.hanbei.httpserver.MockHttpServerTest.java

@Before
public void setUp() throws Exception {
    this.httpServer = new MockHttpServer(7001);
    this.httpServer.start();
    httpServer.addResponse(Method.GET, new URI("/test"), Response.ok().build());
    httpServer.addResponse(Method.GET, new URI("/test3"), Response.ok().content("TestContent").build());
    httpServer.addResponse(Method.GET, new URI("/test2"), Response.status(Status.NOT_FOUND).build());
    httpServer.addResponse(Method.GET, new URI("/test4"),
            Response.ok().content(new byte[] { 1, 2, 3, 4, 5 }).build());
    httpServer.addResponse(Method.GET, new URI("/testUtf8"), Response.ok()
            .content("Celo", Charsets.ISO_8859_1).type("text/plain; charset=iso-8859-1").build());

    httpServer.addRequestProcessor(Method.POST, URI.create("post"), new RequestProcessor() {
        @Override/*from w ww  .j  av a2s.c o m*/
        public Response process(Request request) {
            if (request.getContent().getContentAsString().equals("Test")) {
                return Response.ok().build();
            } else {
                return Response.status(Status.UNAUTHORIZED).build();
            }
        }
    });
    assertTrue(this.httpServer.isRunning());

    httpclient = new DefaultHttpClient(new ThreadSafeClientConnManager());
}

From source file:de.fhg.fokus.odp.registry.solr.impl.SOLRClientImpl.java

@Override
public void init(Properties props) {

    RegisterBuiltin.register(ResteasyProviderFactory.getInstance());
    ClientExecutor executor = new ApacheHttpClient4Executor(
            new DefaultHttpClient(new ThreadSafeClientConnManager()));

    String solrurl = props.getProperty(PROPERTY_NAME_SOLR_URL);
    solrutil = ProxyFactory.create(SOLRClientUtil.class, solrurl, executor);
}

From source file:com.netflix.http4.NFHttpClient.java

protected NFHttpClient() {
    super(new ThreadSafeClientConnManager());
    this.name = "UNNAMED_" + numNonNamedHttpClients.incrementAndGet();
    init();//  w w  w. j  a  v a2 s  . c o m
}

From source file:com.basho.riak.client.raw.http.HTTPClusterClient.java

@Override
protected RawClient[] fromConfig(ClusterConfig<HTTPClientConfig> clusterConfig) throws IOException {
    List<RawClient> clients = new ArrayList<RawClient>();
    int maxTotal = clusterConfig.getTotalMaximumConnections();

    // IE limitless
    if (maxTotal == ClusterConfig.UNLIMITED_CONNECTIONS) {
        // independent pools, independent clients
        HTTPRiakClientFactory fac = HTTPRiakClientFactory.getInstance();
        for (HTTPClientConfig node : clusterConfig.getClients()) {
            clients.add(fac.newClient(node));
        }//from   w  ww .j  a  va  2 s.c om
    } else {
        // create a ThreadSafeClientConnManager to be shared by all the
        // RiakClient instances
        // in the cluster
        // add a route per host and a max per route
        ThreadSafeClientConnManager cm = new ThreadSafeClientConnManager();
        cm.setMaxTotal(maxTotal);

        for (HTTPClientConfig node : clusterConfig.getClients()) {
            if (node.getMaxConnections() != null) {
                cm.setMaxForRoute(makeRoute(node.getUrl()), node.getMaxConnections());
            }
            DefaultHttpClient httpClient = new DefaultHttpClient(cm);

            if (node.getRetryHandler() != null) {
                httpClient.setHttpRequestRetryHandler(node.getRetryHandler());
            }

            RiakConfig riakConfig = new RiakConfig(node.getUrl());
            riakConfig.setMapReducePath(node.getMapreducePath());
            riakConfig.setTimeout(node.getTimeout());
            riakConfig.setHttpClient(httpClient);

            clients.add(new HTTPClientAdapter(new RiakClient(riakConfig)));
        }
    }
    return clients.toArray(new RawClient[clients.size()]);
}

From source file:org.springframework.ws.transport.http.HttpComponentsMessageSender.java

/**
 * Create a new instance of the {@code HttpClientMessageSender} with a default {@link HttpClient} that uses a
 * default {@link SingleClientConnManager}.
 *///from   www  .j a v a  2  s . c o  m
public HttpComponentsMessageSender() {
    DefaultHttpClient defaultClient = new DefaultHttpClient(new ThreadSafeClientConnManager());
    defaultClient.addRequestInterceptor(new RemoveSoapHeadersInterceptor(), 0);

    this.httpClient = defaultClient;
    setConnectionTimeout(DEFAULT_CONNECTION_TIMEOUT_MILLISECONDS);
    setReadTimeout(DEFAULT_READ_TIMEOUT_MILLISECONDS);
}

From source file:org.wrml.core.www.WebClient.java

public WebClient(Context context) {
    super(context);

    final ThreadSafeClientConnManager connectionManager = new ThreadSafeClientConnManager();

    // TODO: Make this configurable
    connectionManager.setMaxTotal(100);/*from   ww  w.j  a va  2 s  .c  om*/

    _HttpClient = new DefaultHttpClient(connectionManager);

    // TODO: Make this configurable
    _DefaultFormatter = new DefaultFormatter();
}

From source file:com.netflix.http4.NFHttpClient.java

protected NFHttpClient(String name) {
    super(new ThreadSafeClientConnManager());
    this.name = name;
    init();
}

From source file:interactivespaces.util.web.HttpClientHttpContentCopier.java

@Override
public void startup() {
    httpConnectionManager = new ThreadSafeClientConnManager();
    httpConnectionManager.setDefaultMaxPerRoute(totalConnectionsAllowed);
    httpConnectionManager.setMaxTotal(totalConnectionsAllowed);

    httpClient = new DefaultHttpClient(httpConnectionManager);
}

From source file:com.aol.webservice_base.util.http.HttpHelper.java

/**
 * Inits the./*from  w ww .ja  v a2  s .c o m*/
 */
public void init() {
    inited = true;
    ThreadSafeClientConnManager connectionManager = new ThreadSafeClientConnManager();
    connectionManager.setDefaultMaxPerRoute(maxConnectionsPerHost);
    connectionManager.setMaxTotal(maxTotalConnections);

    httpClient = new DefaultHttpClient(connectionManager);
    HttpParams params = httpClient.getParams();
    HttpConnectionParams.setConnectionTimeout(params, connectionTimeout);
    HttpConnectionParams.setSoTimeout(params, socketTimeout);
}

From source file:gov.nih.nci.cagrid.portal.portlet.workflow.service.impl.MyExperimentWorkflowRegistry.java

public MyExperimentWorkflowRegistry() {
    this.connMgr = new ThreadSafeClientConnManager();
    this.httpClient = new DefaultHttpClient(connMgr);
}