@Override protected Object buildProxy(ClientTransportConfig transportConfig) throws SofaRpcException { SofaResteasyClientBuilder builder = new SofaResteasyClientBuilder(); ResteasyClient client = builder .registerProvider().logProviders() .establishConnectionTimeout(transportConfig.getConnectTimeout(), TimeUnit.MILLISECONDS) .socketTimeout(transportConfig.getInvokeTimeout(), TimeUnit.MILLISECONDS) .connectionPoolSize(Math.max(transportConfig.getConnectionNum(), MIN_CONNECTION_POOL_SIZE)) .build(); ProviderInfo provider = transportConfig.getProviderInfo(); String url = "http://" + provider.getHost() + ":" + provider.getPort() + StringUtils.CONTEXT_SEP + StringUtils.trimToEmpty(provider.getPath()); ResteasyWebTarget target = client.target(url); return target.proxy(ClassUtils.forName(transportConfig.getConsumerConfig().getInterfaceId())); }
@Override protected Object buildProxy(ClientTransportConfig transportConfig) throws SofaRpcException { SofaResteasyClientBuilder builder = new SofaResteasyClientBuilder(); ResteasyClient client = builder .registerProvider().logProviders() .establishConnectionTimeout(transportConfig.getConnectTimeout(), TimeUnit.MILLISECONDS) .socketTimeout(transportConfig.getInvokeTimeout(), TimeUnit.MILLISECONDS) .connectionPoolSize(Math.max(transportConfig.getConnectionNum(), MIN_CONNECTION_POOL_SIZE)) .build(); ProviderInfo provider = transportConfig.getProviderInfo(); String url = "http://" + provider.getHost() + ":" + provider.getPort() + StringUtils.CONTEXT_SEP + StringUtils.trimToEmpty(provider.getPath()); ResteasyWebTarget target = client.target(url); return target.proxy(ClassUtils.forName(transportConfig.getConsumerConfig().getInterfaceId())); }
ResteasyClientBuilder builder = new ResteasyClientBuilder(); builder.connectionPoolSize(200);
@Inject public ImportControllerImpl() { restClient = new ResteasyClientBuilder().connectionPoolSize(4).build(); }
public BPMClientImpl() { client = new ResteasyClientBuilder().connectionPoolSize(4).build(); }
@Inject public PncClientImpl(CausewayConfig config) { this(new RestEndpointProxyFactory(config, new ResteasyClientBuilder().connectionPoolSize(10).build())); }
public void start() { if (client == null) { client = new ResteasyClientBuilder().trustStore(truststore) .hostnameVerification(ResteasyClientBuilder.HostnameVerificationPolicy.ANY) .connectionPoolSize(10) .build(); } }
public KubernetesAPI createAPI(URI uri, String userName, String password) { // Configure HttpClient to authenticate preemptively // by prepopulating the authentication data cache. // http://docs.jboss.org/resteasy/docs/3.0.9.Final/userguide/html/RESTEasy_Client_Framework.html#transport_layer // http://hc.apache.org/httpcomponents-client-4.2.x/tutorial/html/authentication.html#d5e1032 HttpHost targetHost = new HttpHost(uri.getHost(), uri.getPort(), uri.getScheme()); DefaultHttpClient httpclient = new DefaultHttpClient(); httpclient.getCredentialsProvider().setCredentials( new AuthScope(targetHost.getHostName(), targetHost.getPort()), new UsernamePasswordCredentials(userName, password)); // Create AuthCache instance AuthCache authCache = new BasicAuthCache(); // Generate BASIC scheme object and add it to the local auth cache BasicScheme basicAuth = new BasicScheme(); authCache.put(targetHost, basicAuth); // Add AuthCache to the execution context BasicHttpContext localcontext = new BasicHttpContext(); localcontext.setAttribute(ClientContext.AUTH_CACHE, authCache); // 4. Create client executor and proxy ApacheHttpClient4Engine engine = new ApacheHttpClient4Engine(httpclient, localcontext); ResteasyClient client = new ResteasyClientBuilder().connectionPoolSize(connectionPoolSize).httpEngine(engine) .build(); client.register(JacksonJaxbJsonProvider.class).register(JacksonConfig.class); ProxyBuilder<KubernetesAPI> proxyBuilder = client.target(uri).proxyBuilder(KubernetesAPI.class); if (classLoader != null) { proxyBuilder = proxyBuilder.classloader(classLoader); } return proxyBuilder.build(); }
@Inject public HttpNotificationSender(Config systemConfig) { this.client = new ResteasyClientBuilder() .register(new JacksonJsonProvider(objectMapper())) .connectionPoolSize(32) .build(); this.url = systemConfig.get(NOTIFICATION_HTTP_URL, String.class); this.target = client.target(url); this.headers = headers(systemConfig); this.method = systemConfig.get(NOTIFICATION_HTTP_METHOD, String.class, NOTIFICATION_HTTP_METHOD_DEFAULT); }
public static Keycloak getInstance(String serverUrl, String realm, String username, String password, String clientId, String clientSecret, SSLContext sslContext, ResteasyJackson2Provider customJacksonProvider) { ResteasyClientBuilder clientBuilder = new ResteasyClientBuilder() .sslContext(sslContext) .hostnameVerification(ResteasyClientBuilder.HostnameVerificationPolicy.WILDCARD) .connectionPoolSize(10); if (customJacksonProvider != null) { clientBuilder.register(customJacksonProvider, 100); } return new Keycloak(serverUrl, realm, username, password, clientId, clientSecret, PASSWORD, clientBuilder.build(), null); }
@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); } }
private static ResteasyClient createRestClient(DatabaseIdentifier database) { ResteasyClientBuilder clientBuilder = new ResteasyClientBuilder(); if ( database.getUserName() != null ) { clientBuilder.register( new BasicAuthentication( database.getUserName(), database.getPassword() ) ); } // using a connection pool size > 1 causes a thread-safe pool implementation to be used under the hoods return clientBuilder .connectionPoolSize( CONNECTION_POOL_SIZE ) .build(); }
public Kubernetes createKubernetes() { ResteasyProviderFactory providerFactory = ResteasyProviderFactory.getInstance(); providerFactory.register(ResteasyJackson2Provider.class); // handle JSON coming back as text/plain providerFactory.register(PlainTextJacksonProvider.class); providerFactory.register(Jackson2JsonpInterceptor.class); providerFactory.register(StringTextStar.class); providerFactory.register(DefaultTextPlain.class); providerFactory.register(FileProvider.class); providerFactory.register(InputStreamProvider.class); ResteasyClientBuilder builder = new ResteasyClientBuilder(); builder.providerFactory(providerFactory); builder.connectionPoolSize(Integer.parseInt(System.getProperty("docker.connection.pool", "3"))); Client client = builder.build(); ResteasyWebTarget target = (ResteasyWebTarget) client.target(address); return target.proxy(Kubernetes.class); /* List<Object> providers = new ArrayList<Object>(); providers.add(new JacksonJaxbJsonProvider()); return JAXRSClientFactory.create(address, Kubernetes.class, providers); */ }
Keycloak(String serverUrl, String realm, String username, String password, String clientId, String clientSecret, String grantType, ResteasyClient resteasyClient, String authtoken) { config = new Config(serverUrl, realm, username, password, clientId, clientSecret, grantType); client = resteasyClient != null ? resteasyClient : new ResteasyClientBuilder().connectionPoolSize(10).build(); authToken = authtoken; tokenManager = authtoken == null ? new TokenManager(config, client) : null; target = client.target(config.getServerUrl()); target.register(newAuthFilter()); }
public MonitoringHawkular(String deployment) { MetricProperties metricProperties = DeploymentMetricProperties.getDeploymentMetricProperties().getDeploymentMetricProperty(deployment); APPLICATION_JSON = "application/json"; REST_SERVER_PORT = Integer.parseInt(metricProperties.getHawkularServerPort()); REST_SERVER_USERNAME = metricProperties.getHawkularServerUsername(); REST_SERVER_PASSWORD = metricProperties.getHawkularServerPassword(); REST_SERVER_ADDRESS = metricProperties.getHawkularServerUrl(); ResteasyClient client = new ResteasyClientBuilder().connectionPoolSize(10).maxPooledPerRoute(5).build(); ResteasyWebTarget target = client.target("http://" + REST_SERVER_ADDRESS + ":" + REST_SERVER_PORT); target.register(new BasicAuthentication(REST_SERVER_USERNAME, REST_SERVER_PASSWORD)); postHawkular = target.proxy(PostDataHawkular.class); }
public MonitoringRhq(String deployment) { MetricProperties metricProperties = DeploymentMetricProperties.getDeploymentMetricProperties().getDeploymentMetricProperty(deployment); APPLICATION_JSON = "application/json"; REST_SERVER_PORT = Integer.parseInt(metricProperties.getRhqServerPort()); REST_SERVER_USERNAME = metricProperties.getRhqServerUsername(); REST_SERVER_PASSWORD = metricProperties.getRhqServerPassword(); REST_SERVER_ADDRESS = metricProperties.getRhqServerUrl(); ResteasyClient client = new ResteasyClientBuilder().connectionPoolSize(10).maxPooledPerRoute(5).build(); ResteasyWebTarget target = client.target("http://" + REST_SERVER_ADDRESS + ":" + REST_SERVER_PORT); target.register(new BasicAuthentication(REST_SERVER_USERNAME, REST_SERVER_PASSWORD)); postRhq = target.proxy(PostDataRhq.class); }
public MonitoringRhq(String deployment) { MetricProperties metricProperties = DeploymentMetricProperties.getDeploymentMetricProperties().getDeploymentMetricProperty(deployment); APPLICATION_JSON = "application/json"; REST_SERVER_PORT = Integer.parseInt(metricProperties.getRhqServerPort()); REST_SERVER_USERNAME = metricProperties.getRhqServerUsername(); REST_SERVER_PASSWORD = metricProperties.getRhqServerPassword(); REST_SERVER_ADDRESS = metricProperties.getRhqServerUrl(); ResteasyClient client = new ResteasyClientBuilder().connectionPoolSize(10).maxPooledPerRoute(5).build(); ResteasyWebTarget target = client.target("http://" + REST_SERVER_ADDRESS + ":" + REST_SERVER_PORT); target.register(new BasicAuthentication(REST_SERVER_USERNAME, REST_SERVER_PASSWORD)); postRhq = target.proxy(PostDataRhq.class); }
/** * 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); }
@Override protected Object buildProxy(ClientTransportConfig transportConfig) throws SofaRpcException { SofaResteasyClientBuilder builder = new SofaResteasyClientBuilder(); ResteasyClient client = builder .registerProvider().logProviders() .establishConnectionTimeout(transportConfig.getConnectTimeout(), TimeUnit.MILLISECONDS) .socketTimeout(transportConfig.getInvokeTimeout(), TimeUnit.MILLISECONDS) .connectionPoolSize(Math.max(transportConfig.getConnectionNum(), MIN_CONNECTION_POOL_SIZE)) .build(); ProviderInfo provider = transportConfig.getProviderInfo(); String url = "http://" + provider.getHost() + ":" + provider.getPort() + StringUtils.CONTEXT_SEP + StringUtils.trimToEmpty(provider.getPath()); ResteasyWebTarget target = client.target(url); return target.proxy(ClassUtils.forName(transportConfig.getConsumerConfig().getInterfaceId())); }
private static ResteasyClient createRestClient(RemoteNeo4jDatabaseIdentifier database, RemoteNeo4jConfiguration configuration) { ResteasyClientBuilder clientBuilder = new ResteasyClientBuilder(); if ( database.getUserName() != null ) { clientBuilder.register( new BasicAuthentication( database.getUserName(), database.getPassword() ) ); } if ( configuration.getConnectionCheckoutTimeout() != null ) { clientBuilder.connectionCheckoutTimeout( configuration.getConnectionCheckoutTimeout(), TimeUnit.MILLISECONDS ); } if ( configuration.getEstablishConnectionTimeout() != null ) { clientBuilder.establishConnectionTimeout( configuration.getEstablishConnectionTimeout(), TimeUnit.MILLISECONDS ); } if ( configuration.getConnectionTTL() != null ) { clientBuilder.connectionTTL( configuration.getConnectionTTL(), TimeUnit.MILLISECONDS ); } if ( configuration.getSocketTimeout() != null ) { clientBuilder.socketTimeout( configuration.getSocketTimeout(), TimeUnit.MILLISECONDS ); } clientBuilder.register( XStreamRequestHeaderFilter.INSTANCE ); // using a connection pool size > 1 causes a thread-safe pool implementation to be used under the hoods return clientBuilder.connectionPoolSize( configuration.getClientPoolSize() ).build(); }