• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java OkHttpClient类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ReadWrite类代码示例发布时间:2022-05-22
下一篇:
Java LevelProviderManager类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap