本文整理汇总了Java中feign.okhttp.OkHttpClient类的典型用法代码示例。如果您正苦于以下问题:Java OkHttpClient类的具体用法?Java OkHttpClient怎么用?Java OkHttpClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OkHttpClient类属于feign.okhttp包,在下文中一共展示了OkHttpClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: feignClient
import feign.okhttp.OkHttpClient; //导入依赖的package包/类
@Bean
public Client feignClient() {
RibbonClient.Builder builder = RibbonClient.builder();
if (httpClient != null) {
builder.delegate(new OkHttpClient(httpClient));
} else {
builder.delegate(new OkHttpClient());
}
if (lbClientFactory != null) {
builder.lbClientFactory(lbClientFactory);
}
return builder.build();
}
开发者ID:jmnarloch,项目名称:feign-okhttp-spring-cloud-starter,代码行数:17,代码来源:OkHttpClientAutoConfiguration.java
示例2: simpleFeignBuilder
import feign.okhttp.OkHttpClient; //导入依赖的package包/类
public static HystrixFeign.Builder simpleFeignBuilder() {
JacksonDecoder decoder = new JacksonDecoder(defaultObjectMapper);
return HystrixFeign.builder()
.setterFactory(new DefaultSetterFactory())
.logger(new Slf4jLogger())
.logLevel(Logger.Level.FULL)
.retryer(new Retryer.Default())
.contract(new Contract.Default())
.client(new OkHttpClient())
.options(new Request.Options())
.encoder(new JacksonEncoder(defaultObjectMapper))
.decoder(decoder)
.errorDecoder(new AccessApiErrorDecoder(decoder));
}
开发者ID:amvnetworks,项目名称:amv-access-api-poc,代码行数:15,代码来源:Clients.java
示例3: buildClient
import feign.okhttp.OkHttpClient; //导入依赖的package包/类
@Test
public void buildClient() throws Exception {
clientBuilder = new HttpClientBuilder(config);
OkHttpClient client = (OkHttpClient) clientBuilder.buildClient();
// Not much we can assert besides not null
assertNotNull(client);
}
开发者ID:symphonyoss,项目名称:app-auth-example,代码行数:10,代码来源:HttpClientBuilderTest.java
示例4: getClient
import feign.okhttp.OkHttpClient; //导入依赖的package包/类
protected Feign getClient() {
return Feign.builder()
.client(new TracingClient(new OkHttpClient(), mockTracer,
Collections.<FeignSpanDecorator>singletonList(new FeignSpanDecorator.StandardTags())))
.retryer(new Retryer.Default(100, SECONDS.toMillis(1), NUMBER_OF_RETRIES))
.build();
}
开发者ID:OpenFeign,项目名称:feign-opentracing,代码行数:8,代码来源:FeignTracingTest.java
示例5: start
import feign.okhttp.OkHttpClient; //导入依赖的package包/类
/**
* Startup weed manager.
*/
public void start() {
leaderMasterUrl = assembleUrl(host, port);
leaderMaster = Feign.builder()
.client(new OkHttpClient())
.decoder(new JacksonDecoder())
.target(WeedMasterClient.class, String.format("http://%s", leaderMasterUrl));
fetchMasters(leaderMaster.cluster());
masterHealthCheckThread.start();
volumeHealthCheckThread.start();
}
开发者ID:ChihoSin,项目名称:weed-client,代码行数:16,代码来源:WeedManager.java
示例6: fetchVolume
import feign.okhttp.OkHttpClient; //导入依赖的package包/类
/**
* Fetch volume server.
*
* @param volumeId Volume id.
* @param collection Collection.
* @return ids.
*/
private Set<String> fetchVolume(int volumeId, String collection) {
Locations locations = getMasterClient().lookup(volumeId, collection);
Set<String> ids = new HashSet<>();
locations.getLocations().forEach(location -> {
final String id = String.format("%s#%s", location.getUrl(), location.getUrl());
ids.add(id);
volumeClients.putIfAbsent(id, Feign.builder()
.client(new OkHttpClient())
.decoder(new JacksonDecoder())
.target(WeedVolumeClient.class, String.format("http://%s", location.getPublicUrl())));
});
return ids;
}
开发者ID:ChihoSin,项目名称:weed-client,代码行数:21,代码来源:WeedManager.java
示例7: fetchMasters
import feign.okhttp.OkHttpClient; //导入依赖的package包/类
/**
* Fetch master cluster information.
*
* @param cluster Master cluster information.
*/
private void fetchMasters(Cluster cluster) {
if (!leaderMasterUrl.equals(cluster.getLeader())) {
leaderMasterUrl = cluster.getLeader();
log.info("Weed leader master server is change to [{}]", leaderMasterUrl);
leaderMaster = Feign.builder()
.client(new OkHttpClient())
.decoder(new JacksonDecoder())
.target(WeedMasterClient.class, String.format("http://%s", leaderMaster));
}
// Cleanup peer master
Set<String> removeSet = peerMasters.keySet().stream().filter(
key -> !cluster.getPeers().contains(key) && !cluster.getLeader().equals(key))
.collect(Collectors.toSet());
peerMasters.remove(leaderMasterUrl);
removeSet.forEach(key -> peerMasters.remove(key));
cluster.getPeers().forEach(url -> {
if (!peerMasters.containsKey(url)) {
peerMasters.put(url,
Feign.builder()
.client(new OkHttpClient())
.decoder(new JacksonDecoder())
.target(WeedMasterClient.class, String.format("http://%s", url)));
}
});
}
开发者ID:ChihoSin,项目名称:weed-client,代码行数:34,代码来源:WeedManager.java
示例8: setup
import feign.okhttp.OkHttpClient; //导入依赖的package包/类
@Before
public void setup(){
ObjectMapper esClientMapper = new ObjectMapper()
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
esClient = Feign.builder()
.client(new OkHttpClient())
.decoder(new JacksonDecoder(esClientMapper))
.encoder(new BodyStringEncoder(esClientMapper))
.target(ESClient.class, "http://localhost:9222");
}
开发者ID:hcapitaine,项目名称:french-phonetic-analyser,代码行数:14,代码来源:FrenchPhoneticTest.java
示例9: postProcessBeforeInitialization
import feign.okhttp.OkHttpClient; //导入依赖的package包/类
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName)
throws BeansException {
if (bean instanceof OkHttpClient) {
return getTraceFeignObjectWrapper().wrap(bean);
}
return bean;
}
开发者ID:spring-cloud,项目名称:spring-cloud-sleuth,代码行数:9,代码来源:OkHttpFeignClientBeanPostProcessor.java
示例10: client
import feign.okhttp.OkHttpClient; //导入依赖的package包/类
@Bean
public okhttp3.OkHttpClient client(OkHttpClientFactory httpClientFactory,
ConnectionPool connectionPool, FeignHttpClientProperties httpClientProperties) {
Boolean followRedirects = httpClientProperties.isFollowRedirects();
Integer connectTimeout = httpClientProperties.getConnectionTimeout();
this.okHttpClient = httpClientFactory.createBuilder(false).
connectTimeout(connectTimeout, TimeUnit.MILLISECONDS).
followRedirects(followRedirects).
connectionPool(connectionPool).build();
return this.okHttpClient;
}
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:12,代码来源:OkHttpFeignLoadBalancedConfiguration.java
示例11: feignClient
import feign.okhttp.OkHttpClient; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean(Client.class)
public Client feignClient(CachingSpringLoadBalancerFactory cachingFactory,
SpringClientFactory clientFactory, okhttp3.OkHttpClient okHttpClient) {
OkHttpClient delegate = new OkHttpClient(okHttpClient);
return new LoadBalancerFeignClient(delegate, cachingFactory, clientFactory);
}
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:8,代码来源:OkHttpFeignLoadBalancedConfiguration.java
示例12: client
import feign.okhttp.OkHttpClient; //导入依赖的package包/类
@Bean
public okhttp3.OkHttpClient client(OkHttpClientFactory httpClientFactory,
ConnectionPool connectionPool, FeignHttpClientProperties httpClientProperties) {
Boolean followRedirects = httpClientProperties.isFollowRedirects();
Integer connectTimeout = httpClientProperties.getConnectionTimeout();
Boolean disableSslValidation = httpClientProperties.isDisableSslValidation();
this.okHttpClient = httpClientFactory.createBuilder(disableSslValidation).
connectTimeout(connectTimeout, TimeUnit.MILLISECONDS).
followRedirects(followRedirects).
connectionPool(connectionPool).build();
return this.okHttpClient;
}
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:13,代码来源:FeignAutoConfiguration.java
示例13: customFeignBuilder
import feign.okhttp.OkHttpClient; //导入依赖的package包/类
@Bean
Feign.Builder customFeignBuilder() {
return Feign.builder().client(new OkHttpClient(customOkHttpClient));
}
开发者ID:orange-cloudfoundry,项目名称:sec-group-broker-filter,代码行数:5,代码来源:FilteredBrokerFeignConfig.java
示例14: myOkHttpClient
import feign.okhttp.OkHttpClient; //导入依赖的package包/类
@Bean
public OkHttpClient myOkHttpClient() {
return new OkHttpClient();
}
开发者ID:spring-cloud,项目名称:spring-cloud-sleuth,代码行数:5,代码来源:Issue393Tests.java
示例15: feignClient
import feign.okhttp.OkHttpClient; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean(Client.class)
public Client feignClient() {
return new OkHttpClient(this.okHttpClient);
}
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:6,代码来源:FeignAutoConfiguration.java
注:本文中的feign.okhttp.OkHttpClient类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论