Search in sources :

Example 31 with ResteasyClientBuilder

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

the class RestEasyClientLiveTest method testAddMovie.

@Test
public void testAddMovie() {
    final ResteasyClient client = new ResteasyClientBuilder().build();
    final ResteasyWebTarget target = client.target(FULL_PATH);
    final ServicesInterface proxy = target.proxy(ServicesInterface.class);
    Response moviesResponse = proxy.addMovie(batmanMovie);
    moviesResponse.close();
    moviesResponse = proxy.addMovie(transformerMovie);
    if (moviesResponse.getStatus() != Response.Status.CREATED.getStatusCode()) {
        System.out.println("Failed : HTTP error code : " + moviesResponse.getStatus());
    }
    moviesResponse.close();
    System.out.println("Response Code: " + moviesResponse.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) ResteasyClientBuilder(org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder) ResteasyClient(org.jboss.resteasy.client.jaxrs.ResteasyClient) ResteasyWebTarget(org.jboss.resteasy.client.jaxrs.ResteasyWebTarget) ServicesInterface(com.baeldung.client.ServicesInterface) Test(org.junit.Test)

Example 32 with ResteasyClientBuilder

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

the class RestEasyClientLiveTest method testUpdateMovie.

@Test
public void testUpdateMovie() {
    final ResteasyClient client = new ResteasyClientBuilder().build();
    final ResteasyWebTarget target = client.target(FULL_PATH);
    final ServicesInterface proxy = target.proxy(ServicesInterface.class);
    Response moviesResponse = proxy.addMovie(batmanMovie);
    moviesResponse.close();
    batmanMovie.setTitle("Batman Begins");
    moviesResponse = proxy.updateMovie(batmanMovie);
    if (moviesResponse.getStatus() != Response.Status.OK.getStatusCode()) {
        System.out.println("Failed : HTTP error code : " + moviesResponse.getStatus());
    }
    moviesResponse.close();
    System.out.println("Response Code: " + moviesResponse.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) ResteasyClientBuilder(org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder) ResteasyClient(org.jboss.resteasy.client.jaxrs.ResteasyClient) ResteasyWebTarget(org.jboss.resteasy.client.jaxrs.ResteasyWebTarget) ServicesInterface(com.baeldung.client.ServicesInterface) Test(org.junit.Test)

Example 33 with ResteasyClientBuilder

use of org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder in project wildfly-swarm by wildfly-swarm.

the class ConsulService method start.

@Override
public void start(StartContext startContext) throws StartException {
    Consul.Builder builder = Consul.builder();
    // pool because of multiple threads.
    ResteasyClientBuilder clientBuilder = new ResteasyClientBuilder();
    clientBuilder = clientBuilder.connectionPoolSize(20);
    builder.withClientBuilder(clientBuilder);
    builder.withUrl(this.url);
    try {
        this.consul = builder.build();
    } catch (Exception e) {
        throw new StartException("Failed to connect consul at " + url, e);
    }
}
Also used : ResteasyClientBuilder(org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder) StartException(org.jboss.msc.service.StartException) Consul(com.orbitz.consul.Consul) StartException(org.jboss.msc.service.StartException)

Example 34 with ResteasyClientBuilder

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

the class ResteasyGitRepoClient method createWebClient.

/**
 * Creates a JAXRS web client for the given JAXRS client
 */
protected <T> T createWebClient(Class<T> clientType) {
    String address = getAddress();
    ResteasyProviderFactory providerFactory = ResteasyProviderFactory.getInstance();
    providerFactory.register(ResteasyJackson2Provider.class);
    providerFactory.register(Jackson2JsonpInterceptor.class);
    providerFactory.register(StringTextStar.class);
    providerFactory.register(DefaultTextPlain.class);
    providerFactory.register(FileProvider.class);
    providerFactory.register(InputStreamProvider.class);
    providerFactory.register(new Authenticator());
    providerFactory.register(clientType);
    ResteasyClientBuilder builder = new ResteasyClientBuilder();
    builder.providerFactory(providerFactory);
    builder.connectionPoolSize(3);
    Client client = builder.build();
    ResteasyWebTarget target = (ResteasyWebTarget) client.target(address);
    return target.proxy(clientType);
}
Also used : ResteasyClientBuilder(org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder) ResteasyWebTarget(org.jboss.resteasy.client.jaxrs.ResteasyWebTarget) ResteasyProviderFactory(org.jboss.resteasy.spi.ResteasyProviderFactory) Client(javax.ws.rs.client.Client)

Example 35 with ResteasyClientBuilder

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

the class AbstractEndpointFactory method innerCreateClient.

protected ResteasyWebTarget innerCreateClient(URL url) {
    ResteasyClient client = new ResteasyClientBuilder().build();
    String contextpath = url.getParameter("contextpath", "/");
    if (!contextpath.startsWith("/"))
        contextpath = "/" + contextpath;
    return client.target("http://" + url.getHost() + ":" + url.getPort() + contextpath);
}
Also used : ResteasyClientBuilder(org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder) ResteasyClient(org.jboss.resteasy.client.jaxrs.ResteasyClient)

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