本文整理了Java中com.sun.jersey.api.client.Client.setExecutorService()
方法的一些代码示例,展示了Client.setExecutorService()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Client.setExecutorService()
方法的具体详情如下:
包路径:com.sun.jersey.api.client.Client
类名称:Client
方法名:setExecutorService
[英]Set the ExecutorService for sending asynchronous HTTP requests when no underlying asynchronous HTTP implementation is utilized.
[中]设置ExecutorService,以便在未使用基础异步HTTP实现时发送异步HTTP请求。
代码示例来源:origin: io.snamp.instrumentation/http-reporter
public HttpReporter(final URI snampLocation, final Map<String, ?> properties) {
final DefaultClientConfig clientConfig = new SnampClientConfig(properties);
clientConfig.getSingletons().add(new JacksonJsonProvider());
httpClient = Client.create(clientConfig);
if (clientConfig.getPropertyAsFeature(GZIP_COMPRESSION_FEATURE))
httpClient.addFilter(new GZIPContentEncodingFilter());
final ExecutorService customExecutorService = (ExecutorService) clientConfig.getProperty(EXECUTOR_SERVICE_PROPERTY);
if(customExecutorService != null)
httpClient.setExecutorService(customExecutorService);
batchResource = httpClient.resource(UriBuilder.fromUri(snampLocation).path(BATCH_PATH).build());
nonBatchResource = httpClient.resource(UriBuilder.fromUri(snampLocation).path(NON_BATCH_PATH).build());
final MeasurementBuffer buffer = (MeasurementBuffer) clientConfig.getProperty(BUFFER_PROPERTY);
this.buffer = buffer == null ? new SoftMeasurementBuffer() : buffer;
resending = new AtomicBoolean(false);
asynchronous = true;
}
代码示例来源:origin: com.atlassian.plugins/base-hipchat-integration-plugin-api
@Override
protected Client create() throws Exception {
ClientConfig clientConfig = new DefaultClientConfig();
clientConfig.getClasses().add(JacksonJsonProvider.class);
final Map<String, Object> clientProperties = clientConfig.getProperties();
clientProperties.put(ClientConfig.PROPERTY_THREADPOOL_SIZE, threadPoolSize);
clientProperties.put(ClientConfig.PROPERTY_CONNECT_TIMEOUT, connectionTimeout);
clientProperties.put(ClientConfig.PROPERTY_READ_TIMEOUT, readTimeout);
if (disregardSslVerification) {
try {
clientProperties
.put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES,
new HTTPSProperties(new HostnameVerifier() {
@Override
public boolean verify(String hostname, SSLSession sslSession) {
return true;
}
}, getIgnoreCertSSLContext()));
} catch (NoSuchAlgorithmException e) {
Throwables.propagate(e);
} catch (KeyManagementException e) {
Throwables.propagate(e);
}
}
final Client client = new Client(new URLConnectionClientHandler(new ProxyingHttpURLConnectionFactory()), clientConfig);
client.setExecutorService(createBoundedExecutorService());
client.addFilter(rateLimitMonitoringFilter);
return client;
}
};
代码示例来源:origin: com.yammer.dropwizard/dropwizard-client
private Client build(ExecutorService threadPool,
ObjectMapper objectMapper) {
final Client client = new ApacheHttpClient4(buildHandler(), buildConfig(objectMapper));
client.setExecutorService(threadPool);
if (configuration.isGzipEnabled()) {
client.addFilter(new GZIPContentEncodingFilter(configuration.isGzipEnabledForRequests()));
}
return client;
}
内容来源于网络,如有侵权,请联系作者删除!