Package org.eclipse.jetty.client

Examples of org.eclipse.jetty.client.HttpClient


    @Test
    public void testLogin() throws Exception {

        final SslContextFactory sslContextFactory = new SslContextFactory();
        sslContextFactory.setSslContext(new SSLContextParameters().createSSLContext());
        final HttpClient httpClient = new HttpClient(sslContextFactory);
        httpClient.setConnectTimeout(TIMEOUT);
        httpClient.setTimeout(TIMEOUT);
        httpClient.registerListener(RedirectListener.class.getName());
        httpClient.start();

        final SalesforceSession session = new SalesforceSession(
            httpClient, LoginConfigHelper.getLoginConfig());
        session.addListener(this);
View Full Code Here


        } else {
            // create a new client
            // thread pool min/max from endpoint take precedence over from component
            Integer min = httpClientMinThreads != null ? httpClientMinThreads : getComponent().getHttpClientMinThreads();
            Integer max = httpClientMaxThreads != null ? httpClientMaxThreads : getComponent().getHttpClientMaxThreads();
            HttpClient httpClient = getComponent().createHttpClient(this, min, max, sslContextParameters);

            // set optional http client parameters
            if (httpClientParameters != null) {
                // copy parameters as we need to re-use them again if creating a new producer later
                Map<String, Object> params = new HashMap<String, Object>(httpClientParameters);
View Full Code Here

            } else {
                final SslContextFactory sslContextFactory = new SslContextFactory();
                final SSLContextParameters contextParameters =
                    sslContextParameters != null ? sslContextParameters : new SSLContextParameters();
                sslContextFactory.setSslContext(contextParameters.createSSLContext());
                httpClient = new HttpClient(sslContextFactory);
                httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
                httpClient.setMaxConnectionsPerAddress(MAX_CONNECTIONS_PER_ADDRESS);
                httpClient.setConnectTimeout(CONNECTION_TIMEOUT);
                httpClient.setTimeout(RESPONSE_TIMEOUT);
            }
View Full Code Here

        objectMapper.setSerializationInclusion(JsonSerialize.Inclusion.NON_EMPTY);
        return objectMapper;
    }

    private HttpClient createHttpClient() {
        HttpClient httpClient = new HttpClient();
        try {
            if (Boolean.parseBoolean(System.getProperty("proxySet"))) {
                httpClient.setProxy(new Address(System.getProperty("http.proxyHost"), Integer.parseInt(System.getProperty("http.proxyPort"))));
            }
            httpClient.start();
        } catch (Exception e) {
            throw new RuntimeException("Exception creating HttpClient", e);
        }
        return httpClient;
    }
View Full Code Here

        } else {
            // create a new client
            // thread pool min/max from endpoint take precedence over from component
            Integer min = httpClientMinThreads != null ? httpClientMinThreads : getComponent().getHttpClientMinThreads();
            Integer max = httpClientMaxThreads != null ? httpClientMaxThreads : getComponent().getHttpClientMaxThreads();
            HttpClient httpClient = JettyHttpComponent.createHttpClient(this, min, max, sslContextParameters);

            // set optional http client parameters
            if (httpClientParameters != null) {
                // copy parameters as we need to re-use them again if creating a new producer later
                Map<String, Object> params = new HashMap<String, Object>(httpClientParameters);
View Full Code Here

        SSLContextParameters sslContextParameters = resolveAndRemoveReferenceParameter(parameters, "sslContextParametersRef", SSLContextParameters.class);
       
       
        // configure http client if we have url configuration for it
        // http client is only used for jetty http producer (hence not very commonly used)
        HttpClient client = null;
        if (IntrospectionSupport.hasProperties(parameters, "httpClient.") || sslContextParameters != null) {
            client = getNewHttpClient();
           
            if (IntrospectionSupport.hasProperties(parameters, "httpClient.")) {
                if (isExplicitHttpClient) {
View Full Code Here

    private final HttpClient client;

    public TestJettyHttpClient() {
        super();
        this.client = new HttpClient();
        this.client.setConnectorType(HttpClient.CONNECTOR_SOCKET);
        this.client.setRequestBufferSize(8 * 1024);
        this.client.setResponseBufferSize(8 * 1024);
    }
View Full Code Here

        Boolean matchOnUriPrefix = getAndRemoveParameter(parameters, "matchOnUriPrefix", Boolean.class);
        Boolean enableJmx = getAndRemoveParameter(parameters, "enableJmx", Boolean.class);

        // configure http client if we have url configuration for it
        // http client is only used for jetty http producer (hence not very commonly used)
        HttpClient client = null;
        if (IntrospectionSupport.hasProperties(parameters, "httpClient.")) {
            // set additional parameters on http client
            // only create client when needed
            client = getHttpClient();
            IntrospectionSupport.setProperties(client, parameters, "httpClient.");
View Full Code Here

        sslSocketConnectors = connectors;
    }

    public synchronized HttpClient getHttpClient() {
        if (httpClient == null) {
            httpClient = new HttpClient();
            httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);

            if (System.getProperty("http.proxyHost") != null && System.getProperty("http.proxyPort") != null) {
                String host = System.getProperty("http.proxyHost");
                int port = Integer.parseInt(System.getProperty("http.proxyPort"));
View Full Code Here

  public void testConsume() throws Exception {
      producer.send(session.createTextMessage("test"));
      LOG.info("message sent");

      HttpClient httpClient = new HttpClient();
        httpClient.start();
        ContentExchange contentExchange = new ContentExchange();
        httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
        contentExchange.setURL("http://localhost:8080/message/test?readTimeout=1000&type=queue");
        httpClient.send(contentExchange);
        contentExchange.waitForDone();
        assertEquals("test", contentExchange.getResponseContent());
  }
View Full Code Here

TOP

Related Classes of org.eclipse.jetty.client.HttpClient

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.