Search in sources :

Example 1 with ResteasyClientBuilder

use of org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder in project openremote by openremote.

the class WebTargetBuilder method initClient.

protected static void initClient() {
    if (client != null) {
        return;
    }
    ResteasyClientBuilder clientBuilder = new ResteasyClientBuilder().connectionPoolSize(CONNECTION_POOL_SIZE).connectionCheckoutTimeout(CONNECTION_CHECKOUT_TIMEOUT_MILLISECONDS, TimeUnit.MILLISECONDS).socketTimeout(CONNECTION_TIMEOUT_MILLISECONDS, TimeUnit.MILLISECONDS).establishConnectionTimeout(CONNECTION_TIMEOUT_MILLISECONDS, TimeUnit.MILLISECONDS).register(new JacksonConfig());
    if (asyncExecutorService != null) {
        clientBuilder.asyncExecutor(asyncExecutorService);
    }
    client = clientBuilder.build();
}
Also used : JacksonConfig(org.openremote.container.json.JacksonConfig) ResteasyClientBuilder(org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder)

Example 2 with ResteasyClientBuilder

use of org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder in project syndesis-qe by syndesisio.

the class RestUtils method getClient.

public static Client getClient(ResteasyJackson2Provider jackson2Provider) throws RestClientException {
    final ApacheHttpClient4Engine engine = new ApacheHttpClient4Engine(RestUtils.createAllTrustingClient());
    final Client client = new ResteasyClientBuilder().providerFactory(// this is needed otherwise default jackson2provider is used, which causes problems with JDK8 Optional
    new ResteasyProviderFactory()).register(jackson2Provider).httpEngine(engine).build();
    return client;
}
Also used : ResteasyClientBuilder(org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder) ApacheHttpClient4Engine(org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine) Client(javax.ws.rs.client.Client) HttpClient(org.apache.http.client.HttpClient) ResteasyProviderFactory(org.jboss.resteasy.spi.ResteasyProviderFactory)

Example 3 with ResteasyClientBuilder

use of org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder in project brave by openzipkin.

the class ITTracingFeature_Client method currentSpanVisibleToUserFilters.

@Test
public void currentSpanVisibleToUserFilters() throws Exception {
    server.enqueue(new MockResponse());
    closeClient(client);
    client = new ResteasyClientBuilder().asyncExecutor(httpTracing.tracing().currentTraceContext().executorService(executor)).register(TracingFeature.create(httpTracing)).register((ClientRequestFilter) requestContext -> requestContext.getHeaders().putSingle("my-id", currentTraceContext.get().traceIdString())).build();
    get(client, "/foo");
    RecordedRequest request = server.takeRequest();
    assertThat(request.getHeader("x-b3-traceId")).isEqualTo(request.getHeader("my-id"));
    takeSpan();
}
Also used : AssumptionViolatedException(org.junit.AssumptionViolatedException) ITHttpAsyncClient(brave.test.http.ITHttpAsyncClient) RecordedRequest(okhttp3.mockwebserver.RecordedRequest) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Client(javax.ws.rs.client.Client) Span(zipkin2.Span) Test(org.junit.Test) ClientRequestFilter(javax.ws.rs.client.ClientRequestFilter) ResteasyClientBuilder(org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder) Entity(javax.ws.rs.client.Entity) Executors(java.util.concurrent.Executors) TimeUnit(java.util.concurrent.TimeUnit) Ignore(org.junit.Ignore) MockResponse(okhttp3.mockwebserver.MockResponse) ExecutorService(java.util.concurrent.ExecutorService) RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) ResteasyClientBuilder(org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder) Test(org.junit.Test)

Example 4 with ResteasyClientBuilder

use of org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder in project microservices by pwillhan.

the class ConsulModule method clientBuilder.

@Provides
@Singleton
public ClientBuilder clientBuilder(ObjectMapper objectMapper) {
    ResteasyClientBuilder builder = new ResteasyClientBuilder();
    builder.connectionPoolSize(20);
    builder.register(new JacksonJaxbJsonProvider(objectMapper, JacksonJaxbJsonProvider.DEFAULT_ANNOTATIONS), 100000);
    return builder;
}
Also used : ResteasyClientBuilder(org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder) JacksonJaxbJsonProvider(com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider) Singleton(com.google.inject.Singleton) Provides(com.google.inject.Provides)

Example 5 with ResteasyClientBuilder

use of org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder in project microservices by pwillhan.

the class ConsulModule method clientBuilder.

@Provides
@Singleton
public ClientBuilder clientBuilder(ObjectMapper objectMapper) {
    ResteasyClientBuilder builder = new ResteasyClientBuilder();
    builder.connectionPoolSize(20);
    builder.register(new JacksonJaxbJsonProvider(objectMapper, JacksonJaxbJsonProvider.DEFAULT_ANNOTATIONS), 100000);
    return builder;
}
Also used : ResteasyClientBuilder(org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder) JacksonJaxbJsonProvider(com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider) Singleton(com.google.inject.Singleton) Provides(com.google.inject.Provides)

Aggregations

ResteasyClientBuilder (org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder)40 ResteasyClient (org.jboss.resteasy.client.jaxrs.ResteasyClient)22 ResteasyWebTarget (org.jboss.resteasy.client.jaxrs.ResteasyWebTarget)18 Response (javax.ws.rs.core.Response)11 Test (org.junit.Test)9 ApacheHttpClient4Engine (org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine)8 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)7 ServicesInterface (com.baeldung.client.ServicesInterface)6 PoolingHttpClientConnectionManager (org.apache.http.impl.conn.PoolingHttpClientConnectionManager)6 ResteasyProviderFactory (org.jboss.resteasy.spi.ResteasyProviderFactory)6 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)6 RequestConfig (org.apache.http.client.config.RequestConfig)5 ApacheHttpClient43Engine (org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient43Engine)5 IOException (java.io.IOException)4 Client (javax.ws.rs.client.Client)4 HttpClient (org.apache.http.client.HttpClient)4 ProcessingException (javax.ws.rs.ProcessingException)3 ClientHttpEngine (org.jboss.resteasy.client.jaxrs.ClientHttpEngine)3 Movie (com.baeldung.model.Movie)2 JacksonJaxbJsonProvider (com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider)2