本文整理汇总了Java中org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine类的典型用法代码示例。如果您正苦于以下问题:Java ApacheHttpClient4Engine类的具体用法?Java ApacheHttpClient4Engine怎么用?Java ApacheHttpClient4Engine使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ApacheHttpClient4Engine类属于org.jboss.resteasy.client.jaxrs.engines包,在下文中一共展示了ApacheHttpClient4Engine类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: create
import org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine; //导入依赖的package包/类
@Override
public Client create(final RestClientConfiguration configuration) {
checkNotNull(configuration);
try (TcclBlock tccl = TcclBlock.begin(ResteasyClientBuilder.class)) {
HttpContext httpContext = new BasicHttpContext();
if (configuration.getUseTrustStore()) {
httpContext.setAttribute(SSLContextSelector.USE_TRUST_STORE, true);
}
HttpClient client;
if (configuration.getHttpClient() != null) {
client = checkNotNull(configuration.getHttpClient().get());
}
else {
client = httpClient.get();
}
ClientHttpEngine httpEngine = new ApacheHttpClient4Engine(client, httpContext);
ResteasyClientBuilder builder = new ResteasyClientBuilder().httpEngine(httpEngine);
if (configuration.getCustomizer() != null) {
configuration.getCustomizer().apply(builder);
}
return builder.build();
}
}
开发者ID:sonatype,项目名称:nexus-public,代码行数:28,代码来源:RestClientFactoryImpl.java
示例2: init
import org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine; //导入依赖的package包/类
@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());
setApiClient(restApiClient);
this.connectionInfo = connectionInfo;
this.initialized = true;
renewSession();
}
开发者ID:ow2-proactive,项目名称:scheduling,代码行数:19,代码来源:SchedulerClient.java
示例3: getClient
import org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine; //导入依赖的package包/类
public static Client getClient() throws RestClientException {
final ResteasyJackson2Provider jackson2Provider = RestUtils.createJacksonProvider();
final ApacheHttpClient4Engine engine = new ApacheHttpClient4Engine(RestUtils.createAllTrustingClient());
final Client client = new ResteasyClientBuilder()
.providerFactory(new ResteasyProviderFactory()) // this is needed otherwise default jackson2provider is used, which causes problems with JDK8 Optional
.register(jackson2Provider)
.httpEngine(engine)
.build();
return client;
}
开发者ID:syndesisio,项目名称:syndesis-qe,代码行数:13,代码来源:RestUtils.java
示例4: getClient
import org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine; //导入依赖的package包/类
private static ResteasyClient getClient() {
// Setting digest credentials
CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
UsernamePasswordCredentials credentials = new UsernamePasswordCredentials("admin", "admin");
credentialsProvider.setCredentials(AuthScope.ANY, credentials);
HttpClient httpclient = HttpClientBuilder.create().setDefaultCredentialsProvider(credentialsProvider).build();
ApacheHttpClient4Engine engine = new ApacheHttpClient4Engine(httpclient, true);
// Creating HTTP client
return new ResteasyClientBuilder().httpEngine(engine).build();
}
开发者ID:arcuri82,项目名称:testing_security_development_enterprise_systems,代码行数:12,代码来源:JBossUtil.java
示例5: getResteasyClient
import org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine; //导入依赖的package包/类
private ResteasyClient getResteasyClient(String targetServerUri) throws RestInterfaceFactoryException {
ResteasyClient client = clients.get(targetServerUri);
if(client == null) {
ApacheHttpClient4Engine engine = new ApacheHttpClient4Engine(httpClient);
ResteasyClientBuilder clientBuilder = new ResteasyClientBuilder();
clientBuilder.httpEngine(engine);
client = clientBuilder.build();
clients.put(targetServerUri, client);
}
return client;
}
开发者ID:labsai,项目名称:EDDI,代码行数:15,代码来源:RestInterfaceFactory.java
示例6: getRestClientProxy
import org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine; //导入依赖的package包/类
private RestClient getRestClientProxy() {
ResteasyClient client = new ResteasyClientBuilder().asyncExecutor(threadPool)
.httpEngine(new ApacheHttpClient4Engine(httpClient))
.build();
ResteasyWebTarget target = client.target(SchedulerConfig.get().getRestUrl());
return target.proxy(RestClient.class);
}
开发者ID:ow2-proactive,项目名称:scheduling-portal,代码行数:9,代码来源:SchedulerServiceImpl.java
示例7: getRestClientProxy
import org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine; //导入依赖的package包/类
private RestClient getRestClientProxy() {
ResteasyClient client = new ResteasyClientBuilder().asyncExecutor(threadPool)
.httpEngine(new ApacheHttpClient4Engine(httpClient))
.build();
ResteasyWebTarget target = client.target(RMConfig.get().getRestUrl());
return target.proxy(RestClient.class);
}
开发者ID:ow2-proactive,项目名称:scheduling-portal,代码行数:10,代码来源:RMServiceImpl.java
示例8: getRestClient
import org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine; //导入依赖的package包/类
@Override
public SchedulerRestClient getRestClient() {
CommonHttpClientBuilder httpClientBuilder = new HttpClientBuilder().useSystemProperties();
if (canInsecureAccess()) {
httpClientBuilder.insecure(true);
}
return new SchedulerRestClient(restServerUrl, new ApacheHttpClient4Engine(httpClientBuilder.build()));
}
开发者ID:ow2-proactive,项目名称:scheduling,代码行数:9,代码来源:ApplicationContextImpl.java
示例9: init
import org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine; //导入依赖的package包/类
public void init(String restServerUrl, ISchedulerClient client) {
this.httpEngine = new ApacheHttpClient4Engine(new HttpClientBuilder().disableContentCompression()
.useSystemProperties()
.build());
this.restDataspaceUrl = restDataspaceUrl(restServerUrl);
this.sessionId = client.getSession();
if (log.isDebugEnabled()) {
log.debug("Error : trying to retrieve session from disconnected client.");
}
this.schedulerClient = client;
}
开发者ID:ow2-proactive,项目名称:scheduling,代码行数:12,代码来源:DataSpaceClient.java
示例10: newClient
import org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine; //导入依赖的package包/类
@Override
protected Client newClient() {
ResteasyClientBuilder resteasyClientBuilder = new ResteasyClientBuilder();
ResteasyClient client = resteasyClientBuilder.establishConnectionTimeout(getTimeout(), TimeUnit.MILLISECONDS).socketTimeout(getTimeout(), TimeUnit.MILLISECONDS).build();
AbstractHttpClient httpClient = (AbstractHttpClient) ((ApacheHttpClient4Engine) client.httpEngine()).getHttpClient();
httpClient.setRedirectStrategy(new DefaultRedirectStrategy() {
@Override
protected boolean isRedirectable(String method) {
return true;
}
});
httpClient.addRequestInterceptor(new HttpRequestInterceptor() {
@Override
public void process(HttpRequest request, HttpContext context) throws HttpException, IOException {
request.setParams(new AllowRedirectHttpParams(request.getParams()));
}
});
return client;
}
开发者ID:CurrentContinuation,项目名称:gigasetelements,代码行数:22,代码来源:GigasetElementsRestEasy.java
示例11: createAPI
import org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine; //导入依赖的package包/类
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();
}
开发者ID:nirmal070125,项目名称:KubernetesAPIJavaClient,代码行数:38,代码来源:RestFactory.java
示例12: initDefaultEngine
import org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Override
protected ClientHttpEngine initDefaultEngine() {
ApacheHttpClient4Engine httpEngine = (ApacheHttpClient4Engine) super.initDefaultEngine();
if (proxyCredentials != null) {
((DefaultHttpClient) httpEngine.getHttpClient()).setCredentialsProvider(proxyCredentials);
}
return httpEngine;
}
开发者ID:jenkinsci,项目名称:gitlab-plugin,代码行数:10,代码来源:ResteasyGitLabClientBuilder.java
示例13: getOrCreateClient
import org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine; //导入依赖的package包/类
private ResteasyClient getOrCreateClient(Consumer<HttpClientBuilder> httpCustomiser,
Consumer<ResteasyClientBuilder> resteasyCustomiser)
{
if (httpCustomiser == null && resteasyCustomiser == null)
{
// Recursively call self to create a shared client for other non-customised consumers
if (client == null)
client = getOrCreateClient(Objects:: requireNonNull, Objects:: requireNonNull);
return client; // use shared client
}
else
{
final CloseableHttpClient http = createHttpClient(httpCustomiser);
// Now build a resteasy client
{
ResteasyClientBuilder builder = new ResteasyClientBuilder();
builder.httpEngine(new ApacheHttpClient4Engine(http)).providerFactory(resteasyProviderFactory);
if (resteasyCustomiser != null)
resteasyCustomiser.accept(builder);
return builder.build();
}
}
}
开发者ID:petergeneric,项目名称:stdlib,代码行数:30,代码来源:ResteasyClientFactoryImpl.java
示例14: doRefer
import org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine; //导入依赖的package包/类
protected <T> T doRefer(Class<T> serviceType, URL url) throws RpcException {
if (connectionMonitor == null) {
connectionMonitor = new ConnectionMonitor();
}
// TODO more configs to add
PoolingClientConnectionManager connectionManager = new PoolingClientConnectionManager();
// 20 is the default maxTotal of current PoolingClientConnectionManager
connectionManager.setMaxTotal(url.getParameter(Constants.CONNECTIONS_KEY, 20));
connectionManager.setDefaultMaxPerRoute(url.getParameter(Constants.CONNECTIONS_KEY, 20));
connectionMonitor.addConnectionManager(connectionManager);
// BasicHttpContext localContext = new BasicHttpContext();
DefaultHttpClient httpClient = new DefaultHttpClient(connectionManager);
httpClient.setKeepAliveStrategy(new ConnectionKeepAliveStrategy() {
public long getKeepAliveDuration(HttpResponse response, HttpContext context) {
HeaderElementIterator it = new BasicHeaderElementIterator(response.headerIterator(HTTP.CONN_KEEP_ALIVE));
while (it.hasNext()) {
HeaderElement he = it.nextElement();
String param = he.getName();
String value = he.getValue();
if (value != null && param.equalsIgnoreCase("timeout")) {
return Long.parseLong(value) * 1000;
}
}
// TODO constant
return 30 * 1000;
}
});
HttpParams params = httpClient.getParams();
// TODO currently no xml config for Constants.CONNECT_TIMEOUT_KEY so we directly reuse Constants.TIMEOUT_KEY for now
HttpConnectionParams.setConnectionTimeout(params, url.getParameter(Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT));
HttpConnectionParams.setSoTimeout(params, url.getParameter(Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT));
HttpConnectionParams.setTcpNoDelay(params, true);
HttpConnectionParams.setSoKeepalive(params, true);
ApacheHttpClient4Engine engine = new ApacheHttpClient4Engine(httpClient/*, localContext*/);
ResteasyClient client = new ResteasyClientBuilder().httpEngine(engine).build();
clients.add(client);
client.register(RpcContextFilter.class);
for (String clazz : Constants.COMMA_SPLIT_PATTERN.split(url.getParameter(Constants.EXTENSION_KEY, ""))) {
if (!StringUtils.isEmpty(clazz)) {
try {
client.register(Thread.currentThread().getContextClassLoader().loadClass(clazz.trim()));
} catch (ClassNotFoundException e) {
throw new RpcException("Error loading JAX-RS extension class: " + clazz.trim(), e);
}
}
}
// TODO protocol
ResteasyWebTarget target = client.target("http://" + url.getHost() + ":" + url.getPort() + "/" + getContextPath(url));
return target.proxy(serviceType);
}
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:62,代码来源:RestProtocol.java
示例15: doRefer
import org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine; //导入依赖的package包/类
protected <T> T doRefer(Class<T> serviceType, URL url) throws RpcException {
if (connectionMonitor == null) {
connectionMonitor = new ConnectionMonitor();
}
// TODO more configs to add
PoolingClientConnectionManager connectionManager = new PoolingClientConnectionManager();
// 20 is the default maxTotal of current PoolingClientConnectionManager
connectionManager.setMaxTotal(url.getParameter(Constants.CONNECTIONS_KEY, 20));
connectionManager.setDefaultMaxPerRoute(url.getParameter(Constants.CONNECTIONS_KEY, 20));
connectionMonitor.addConnectionManager(connectionManager);
// BasicHttpContext localContext = new BasicHttpContext();
DefaultHttpClient httpClient = new DefaultHttpClient(connectionManager);
httpClient.setKeepAliveStrategy(new ConnectionKeepAliveStrategy() {
public long getKeepAliveDuration(HttpResponse response, HttpContext context) {
HeaderElementIterator it = new BasicHeaderElementIterator(response.headerIterator(HTTP.CONN_KEEP_ALIVE));
while (it.hasNext()) {
HeaderElement he = it.nextElement();
String param = he.getName();
String value = he.getValue();
if (value != null && param.equalsIgnoreCase("timeout")) {
return Long.parseLong(value) * 1000;
}
}
// TODO constant
return 30 * 1000;
}
});
HttpParams params = httpClient.getParams();
// TODO currently no xml config for Constants.CONNECT_TIMEOUT_KEY so we directly reuse Constants.TIMEOUT_KEY for now
HttpConnectionParams.setConnectionTimeout(params, url.getParameter(Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT));
HttpConnectionParams.setSoTimeout(params, url.getParameter(Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT));
HttpConnectionParams.setTcpNoDelay(params, true);
HttpConnectionParams.setSoKeepalive(params, true);
ApacheHttpClient4Engine engine = new ApacheHttpClient4Engine(httpClient/* , localContext */);
ResteasyClient client = new ResteasyClientBuilder().httpEngine(engine).build();
clients.add(client);
client.register(RpcContextFilter.class);
for (String clazz : Constants.COMMA_SPLIT_PATTERN.split(url.getParameter(Constants.EXTENSION_KEY, ""))) {
if (!StringUtils.isEmpty(clazz)) {
try {
client.register(Thread.currentThread().getContextClassLoader().loadClass(clazz.trim()));
} catch (ClassNotFoundException e) {
throw new RpcException("Error loading JAX-RS extension class: " + clazz.trim(), e);
}
}
}
// dubbo 服务多版本
String version = url.getParameter(Constants.VERSION_KEY);
String versionPath = "";
if (StringUtils.isNotEmpty(version)) {
versionPath = version + "/";
}
// TODO protocol
ResteasyWebTarget target = client.target("http://" + url.getHost() + ":" + url.getPort() + "/" + versionPath + getContextPath(url));
return target.proxy(serviceType);
}
开发者ID:sdcuike,项目名称:dubbo-rpc-rest,代码行数:68,代码来源:RestProtocol.java
示例16: init
import org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine; //导入依赖的package包/类
@PostConstruct
public void init() {
ApacheHttpClient4Engine engine = new ApacheHttpClient4Engine(httpClient);
this.resteasyClient = new ResteasyClientBuilder().httpEngine(engine).register(new BasicAuthenticationFilter()).build();
this.tasksBuilder = new TasksBuilder();
}
开发者ID:projectomakase,项目名称:omakase,代码行数:7,代码来源:OmakaseClient.java
示例17: doRefer
import org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine; //导入依赖的package包/类
protected <T> T doRefer(Class<T> serviceType, URL url) throws RpcException {
if (connectionMonitor == null) {
connectionMonitor = new ConnectionMonitor();
}
// TODO more configs to add
PoolingClientConnectionManager connectionManager = new PoolingClientConnectionManager();
// 20 is the default maxTotal of current PoolingClientConnectionManager
connectionManager.setMaxTotal(url.getParameter(Constants.CONNECTIONS_KEY, 20));
connectionManager.setDefaultMaxPerRoute(url.getParameter(Constants.CONNECTIONS_KEY, 20));
connectionMonitor.addConnectionManager(connectionManager);
// BasicHttpContext localContext = new BasicHttpContext();
DefaultHttpClient httpClient = new DefaultHttpClient(connectionManager);
httpClient.setKeepAliveStrategy(new ConnectionKeepAliveStrategy() {
public long getKeepAliveDuration(HttpResponse response, HttpContext context) {
HeaderElementIterator it = new BasicHeaderElementIterator(response.headerIterator(HTTP.CONN_KEEP_ALIVE));
while (it.hasNext()) {
HeaderElement he = it.nextElement();
String param = he.getName();
String value = he.getValue();
if (value != null && param.equalsIgnoreCase("timeout")) {
return Long.parseLong(value) * 1000;
}
}
// TODO constant
return 30 * 1000;
}
});
HttpParams params = httpClient.getParams();
// TODO currently no xml config for Constants.CONNECT_TIMEOUT_KEY so we directly reuse Constants.TIMEOUT_KEY for now
HttpConnectionParams.setConnectionTimeout(params, url.getParameter(Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT));
HttpConnectionParams.setSoTimeout(params, url.getParameter(Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT));
HttpConnectionParams.setTcpNoDelay(params, true);
HttpConnectionParams.setSoKeepalive(params, true);
ApacheHttpClient4Engine engine = new ApacheHttpClient4Engine(httpClient/*, localContext*/);
ResteasyClient client = new ResteasyClientBuilder().httpEngine(engine).build();
clients.add(client);
for (String clazz : Constants.COMMA_SPLIT_PATTERN.split(url.getParameter(Constants.EXTENSION_KEY, ""))) {
if (!StringUtils.isEmpty(clazz)) {
try {
client.register(Thread.currentThread().getContextClassLoader().loadClass(clazz.trim()));
} catch (ClassNotFoundException e) {
throw new RpcException("Error loading JAX-RS extension class: " + clazz.trim(), e);
}
}
}
// TODO protocol
ResteasyWebTarget target = client.target("http://" + url.getHost() + ":" + url.getPort() + "/" + getContextPath(url));
return target.proxy(serviceType);
}
开发者ID:lsjiguang,项目名称:dangdangdotcom,代码行数:61,代码来源:RestProtocol.java
示例18: getEngine
import org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine; //导入依赖的package包/类
/**
* Creates new http client for resteasy engine.
*
* @return new instance of http client 4 engine
* @throws NoSuchAlgorithmException
* SSL context cannot be created
*/
public ApacheHttpClient4Engine getEngine() throws NoSuchAlgorithmException {
HttpClient httpClient = getHttpClient();
return new ApacheHttpClient4Engine(httpClient);
}
开发者ID:aracrown,项目名称:ara-commons,代码行数:13,代码来源:HttpClientProducer.java
注:本文中的org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论