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());
}
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());
}
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);
}
}
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);
}
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);
}
Aggregations