List of usage examples for org.apache.commons.httpclient MultiThreadedHttpConnectionManager MultiThreadedHttpConnectionManager
public MultiThreadedHttpConnectionManager()
From source file:com.fluidops.iwb.wiki.WikiBot.java
/** * //from w ww. ja v a2s . c om * @param wikimediaSource the wikimedia url, e.g. http://en.wikipedia.org/w/ */ public WikiBot(String wikimediaSource) { this.wikimediaSource = wikimediaSource; httpClient = new HttpClient(new MultiThreadedHttpConnectionManager()); }
From source file:com.intellij.tasks.impl.BaseRepositoryImpl.java
private HttpClient createClient() { HttpClient client = new HttpClient(new MultiThreadedHttpConnectionManager()); configureHttpClient(client);//w ww .j av a 2 s. c o m return client; }
From source file:fedora.common.http.WebClient.java
private void configureConnectionManager() { m_cManager = new MultiThreadedHttpConnectionManager(); m_cManager.getParams().setDefaultMaxConnectionsPerHost(MAX_CONNECTIONS_PER_HOST); m_cManager.getParams().setMaxTotalConnections(MAX_TOTAL_CONNECTIONS); m_cManager.getParams().setConnectionTimeout(TIMEOUT_SECONDS * 1000); m_cManager.getParams().setSoTimeout(SOCKET_TIMEOUT_SECONDS * 1000); }
From source file:com.gisgraphy.domain.geoloc.service.fulltextsearch.SolrClientTest.java
@Test public void testBindToUrlShouldAddEndingSlashIfNotPresent() { IsolrClient client = new SolrClient("http://127.0.0.2/solr", new MultiThreadedHttpConnectionManager()); client.bindToUrl("http://127.0.0.2/solr"); Assert.assertTrue("SolrClient should add a '/' if not present ", client.getURL().equals("http://127.0.0.2/solr/")); }
From source file:ensen.controler.AnnotationClient.java
public String request(HttpMethod method) throws AnnotationException { String response = null;//from w w w . j av a2 s. c o m // Provide custom retry handler is necessary method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, false)); try { // Execute the method. client.setHttpConnectionManager(new MultiThreadedHttpConnectionManager()); int statusCode = client.executeMethod(method); if (statusCode != HttpStatus.SC_OK) { System.out.println("Method failed: " + method.getStatusLine()); } // Read the response body. InputStream responseBodyStream = method.getResponseBodyAsStream(); //Going to buffer response body of large or unknown size. Using getResponseBodyAsStream instead is recommended. int b = responseBodyStream.read(); ArrayList<Integer> bytes = new ArrayList<Integer>(); while (b != -1) { bytes.add(b); b = responseBodyStream.read(); } byte[] responseBody = new byte[bytes.size()]; for (int i = 0; i < bytes.size(); i++) { responseBody[i] = bytes.get(i).byteValue(); } // Deal with the response. // Use caution: ensure correct character encoding and is not binary data response = new String(responseBody); } catch (HttpException e) { System.out.println("Fatal protocol violation: " + e.getMessage()); try { System.err.println(method.getURI()); } catch (URIException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } throw new AnnotationException("Protocol error executing HTTP request.", e); } catch (IOException e) { System.out.println("Fatal transport error: " + e.getMessage()); System.out.println(method.getQueryString()); throw new AnnotationException("Transport error executing HTTP request.", e); } finally { // Release the connection. method.releaseConnection(); } return response; }
From source file:edu.harvard.iq.dvn.core.web.dvnremote.DvnTermsOfUseAccess.java
private HttpClient getClient() { if (client == null) { client = new HttpClient(new MultiThreadedHttpConnectionManager()); }//from w w w.j a va 2 s .c o m return client; //return new HttpClient(); }
From source file:jails.http.client.CommonsClientHttpRequestFactory.java
/** * Create a new instance of the <code>CommonsHttpRequestFactory</code> with a default * {@link HttpClient} that uses a default {@link MultiThreadedHttpConnectionManager}. *//* w w w . ja v a 2s . c o m*/ public CommonsClientHttpRequestFactory() { httpClient = new HttpClient(new MultiThreadedHttpConnectionManager()); this.setReadTimeout(DEFAULT_READ_TIMEOUT_MILLISECONDS); }
From source file:com.itude.mobile.mobbl.server.http.HttpDelegate.java
private HttpDelegate() { logger.debug("HttpDelegate.HttpDelegate()"); MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); HttpConnectionManagerParams connectionParameters = connectionManager.getParams(); connectionParameters.setDefaultMaxConnectionsPerHost(CONNECTIONS_PER_HOST); connectionParameters.setMaxTotalConnections(TOTAL_CONNECTIONS); connectionParameters.setConnectionTimeout(CONNECTION_TIMEOUT); httpClient = new HttpClient(connectionManager); }
From source file:com.foglyn.core.FoglynCorePlugin.java
public void start(BundleContext context) throws Exception { super.start(context); ServiceTracker pt = new ServiceTracker(context, IProxyService.class.getName(), null); proxyServiceTracker.set(pt);/* ww w . j av a2 s.co m*/ pt.open(); this.connectionManager.set(new MultiThreadedHttpConnectionManager()); HttpClient hc = createHttpClient(connectionManager.get()); this.httpClient.set(hc); this.clientFactory.set(new FogBugzClientFactory(hc)); plugin.set(this); }
From source file:com.agiletec.plugins.jpcasclient.aps.system.services.controller.control.CasClientTicketValidationUtil.java
/** * ticket validation /*ww w . j a v a 2 s .co m*/ * */ public Assertion validateTicket(String service, String ticket_key) throws ApsSystemException { Assertion assertion = null; MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); _client = new HttpClient(connectionManager); GetMethod authget = new GetMethod(); Map<String, String> params = new HashMap<String, String>(); params.put("service", service); params.put("ticket", ticket_key); authget.getParams().setCookiePolicy(CookiePolicy.DEFAULT); String responseBodyValidation = null; String responseAssertion = null; String responseUser = null; responseBodyValidation = this.CASgetMethod(authget, _client, this._urlCasValidate, params); try { // controllo della risposta sulla richiesta validazione ticket if (null != responseBodyValidation && responseBodyValidation.length() > 0) { InputStreamReader reader; reader = new InputStreamReader(authget.getResponseBodyAsStream()); BufferedReader bufferedReader = new BufferedReader(reader); responseAssertion = bufferedReader.readLine(); if (responseAssertion.equals(_positiveResponse)) { responseUser = bufferedReader.readLine(); } ApsSystemUtils.getLogger().info("CasClientTicketValidationUtil - Assertion: " + responseAssertion + " user: " + responseUser); } } catch (Throwable t) { _logger.error("Error in CasClientTicketValidationUtil - validateTicket", t); throw new ApsSystemException("Error in CasClientTicketValidationUtil - validateTicket", t); } if (null != responseAssertion && null != responseUser && responseAssertion.equalsIgnoreCase(_positiveResponse) && responseUser.length() > 0) { assertion = new AssertionImpl(responseUser); } return assertion; }