use of org.jboss.resteasy.spi.ResteasyProviderFactory in project scheduling by ow2-proactive.
the class SchedulerClient method init.
@Override
public void init(ConnectionInfo connectionInfo) throws Exception {
HttpClient client = new HttpClientBuilder().insecure(connectionInfo.isInsecure()).useSystemProperties().build();
SchedulerRestClient restApiClient = new SchedulerRestClient(connectionInfo.getUrl(), new ApacheHttpClient4Engine(client));
ResteasyProviderFactory factory = ResteasyProviderFactory.getInstance();
factory.register(new WildCardTypeReader());
factory.register(new OctetStreamReader());
factory.register(new TaskResultReader());
SchedulerRestClient.registerGzipEncoding(factory);
setApiClient(restApiClient);
this.connectionInfo = connectionInfo;
this.initialized = true;
renewSession();
}
use of org.jboss.resteasy.spi.ResteasyProviderFactory in project scheduling by ow2-proactive.
the class MyResteasyBootstrap method contextInitialized.
public void contextInitialized(ServletContextEvent event) {
super.contextInitialized(event);
ResteasyProviderFactory dispatcher = ResteasyProviderFactory.getInstance();
dispatcher.registerProvider(OctetStreamWriter.class, false);
dispatcher.registerProvider(PlainTextReader.class, false);
restRuntime = new RestRuntime();
initPortalConfiguration(event);
restRuntime.start(dispatcher, findConfigurationFile(event.getServletContext(), "log4j.properties"), findConfigurationFile(event.getServletContext(), File.separator + "config" + File.separator + "network" + File.separator + "server.ini"));
}
use of org.jboss.resteasy.spi.ResteasyProviderFactory 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.spi.ResteasyProviderFactory in project java by wavefrontHQ.
the class HttpClientTest method httpClientTimeoutsWork.
@Test(expected = ProcessingException.class)
public void httpClientTimeoutsWork() throws Exception {
ResteasyProviderFactory factory = ResteasyProviderFactory.getInstance();
factory.registerProvider(JsonNodeWriter.class);
factory.registerProvider(ResteasyJackson2Provider.class);
HttpClient httpClient = HttpClientBuilder.create().useSystemProperties().setMaxConnTotal(200).setMaxConnPerRoute(100).setConnectionTimeToLive(1, TimeUnit.MINUTES).setDefaultSocketConfig(SocketConfig.custom().setSoTimeout(100).build()).setDefaultRequestConfig(RequestConfig.custom().setContentCompressionEnabled(true).setRedirectsEnabled(true).setConnectTimeout(5000).setConnectionRequestTimeout(5000).setSocketTimeout(60000).build()).setSSLSocketFactory(new LayeredConnectionSocketFactory() {
@Override
public Socket createLayeredSocket(Socket socket, String target, int port, HttpContext context) throws IOException, UnknownHostException {
return SSLConnectionSocketFactory.getSystemSocketFactory().createLayeredSocket(socket, target, port, context);
}
@Override
public Socket createSocket(HttpContext context) throws IOException {
return SSLConnectionSocketFactory.getSystemSocketFactory().createSocket(context);
}
@Override
public Socket connectSocket(int connectTimeout, Socket sock, HttpHost host, InetSocketAddress remoteAddress, InetSocketAddress localAddress, HttpContext context) throws IOException {
assertTrue("Non-zero timeout passed to connect socket is expected", connectTimeout > 0);
throw new ProcessingException("OK");
}
}).build();
ResteasyClient client = new ResteasyClientBuilder().httpEngine(new ApacheHttpClient4Engine(httpClient, true)).providerFactory(factory).build();
SocketServerRunnable sr = new SocketServerRunnable();
Thread serverThread = new Thread(sr);
serverThread.start();
ResteasyWebTarget target = client.target("https://localhost:" + sr.getPort());
SimpleRESTEasyAPI proxy = target.proxy(SimpleRESTEasyAPI.class);
proxy.search("resteasy");
}
Aggregations