Search in sources :

Example 21 with PoolingClientConnectionManager

use of org.apache.http.impl.conn.PoolingClientConnectionManager in project tdi-studio-se by Talend.

the class RestClient method main.

public static void main(String[] args) {
    PoolingClientConnectionManager conMan = getConnectionManager();
    RestClient client = new RestClient(new DefaultHttpClient(conMan), BONITA_URI);
    client.loginAs("walter.bates", "bpm");
    //deploy it
    String processId = client.deployProcess("C:/Users/Talend/Desktop/login--1.0.bar");
    processId = client.getProcessID("login", "1.0");
    System.out.println(processId);
    //start it
    Map<String, String> map = new HashMap<String, String>();
    map.put("id", "1");
    map.put("name", "wangwei");
    client.startProcess(processId, map);
    client.logout();
    client.close();
}
Also used : PoolingClientConnectionManager(org.apache.http.impl.conn.PoolingClientConnectionManager) HashMap(java.util.HashMap) DefaultHttpClient(org.apache.http.impl.client.DefaultHttpClient)

Example 22 with PoolingClientConnectionManager

use of org.apache.http.impl.conn.PoolingClientConnectionManager in project maven-plugins by apache.

the class JavadocUtil method createHttpClient.

/**
     * Creates a new {@code HttpClient} instance.
     *
     * @param settings The settings to use for setting up the client or {@code null}.
     * @param url The {@code URL} to use for setting up the client or {@code null}.
     *
     * @return A new {@code HttpClient} instance.
     *
     * @see #DEFAULT_TIMEOUT
     * @since 2.8
     */
private static HttpClient createHttpClient(Settings settings, URL url) {
    DefaultHttpClient httpClient = new DefaultHttpClient(new PoolingClientConnectionManager());
    httpClient.getParams().setIntParameter(CoreConnectionPNames.SO_TIMEOUT, DEFAULT_TIMEOUT);
    httpClient.getParams().setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, DEFAULT_TIMEOUT);
    httpClient.getParams().setBooleanParameter(ClientPNames.ALLOW_CIRCULAR_REDIRECTS, true);
    // Some web servers don't allow the default user-agent sent by httpClient
    httpClient.getParams().setParameter(CoreProtocolPNames.USER_AGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)");
    if (settings != null && settings.getActiveProxy() != null) {
        Proxy activeProxy = settings.getActiveProxy();
        ProxyInfo proxyInfo = new ProxyInfo();
        proxyInfo.setNonProxyHosts(activeProxy.getNonProxyHosts());
        if (StringUtils.isNotEmpty(activeProxy.getHost()) && (url == null || !ProxyUtils.validateNonProxyHosts(proxyInfo, url.getHost()))) {
            HttpHost proxy = new HttpHost(activeProxy.getHost(), activeProxy.getPort());
            httpClient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
            if (StringUtils.isNotEmpty(activeProxy.getUsername()) && activeProxy.getPassword() != null) {
                Credentials credentials = new UsernamePasswordCredentials(activeProxy.getUsername(), activeProxy.getPassword());
                httpClient.getCredentialsProvider().setCredentials(AuthScope.ANY, credentials);
            }
        }
    }
    return httpClient;
}
Also used : ProxyInfo(org.apache.maven.wagon.proxy.ProxyInfo) PoolingClientConnectionManager(org.apache.http.impl.conn.PoolingClientConnectionManager) Proxy(org.apache.maven.settings.Proxy) HttpHost(org.apache.http.HttpHost) DefaultHttpClient(org.apache.http.impl.client.DefaultHttpClient) Credentials(org.apache.http.auth.Credentials) UsernamePasswordCredentials(org.apache.http.auth.UsernamePasswordCredentials) UsernamePasswordCredentials(org.apache.http.auth.UsernamePasswordCredentials)

Aggregations

PoolingClientConnectionManager (org.apache.http.impl.conn.PoolingClientConnectionManager)22 DefaultHttpClient (org.apache.http.impl.client.DefaultHttpClient)19 HttpResponse (org.apache.http.HttpResponse)9 HttpGet (org.apache.http.client.methods.HttpGet)9 Test (org.junit.Test)9 Scheme (org.apache.http.conn.scheme.Scheme)7 ClientConnectionManager (org.apache.http.conn.ClientConnectionManager)6 SchemeRegistry (org.apache.http.conn.scheme.SchemeRegistry)6 SSLSocketFactory (org.apache.http.conn.ssl.SSLSocketFactory)6 IOException (java.io.IOException)4 CertificateException (java.security.cert.CertificateException)4 X509Certificate (java.security.cert.X509Certificate)3 UsernamePasswordCredentials (org.apache.http.auth.UsernamePasswordCredentials)3 TrustStrategy (org.apache.http.conn.ssl.TrustStrategy)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 URI (java.net.URI)2 URISyntaxException (java.net.URISyntaxException)2 Activate (org.apache.felix.scr.annotations.Activate)2 ClientProtocolException (org.apache.http.client.ClientProtocolException)2 PlainSocketFactory (org.apache.http.conn.scheme.PlainSocketFactory)2