本文整理汇总了Java中feign.hystrix.HystrixFeign.Builder方法的典型用法代码示例。如果您正苦于以下问题:Java HystrixFeign.Builder方法的具体用法?Java HystrixFeign.Builder怎么用?Java HystrixFeign.Builder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类feign.hystrix.HystrixFeign
的用法示例。
在下文中一共展示了HystrixFeign.Builder方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: targetWithFallbackFactory
import feign.hystrix.HystrixFeign; //导入方法依赖的package包/类
private <T> T targetWithFallbackFactory(String feignClientName, FeignContext context,
Target.HardCodedTarget<T> target,
HystrixFeign.Builder builder,
Class<?> fallbackFactoryClass) {
FallbackFactory<? extends T> fallbackFactory = (FallbackFactory<? extends T>)
getFromContext("fallbackFactory", feignClientName, context, fallbackFactoryClass, FallbackFactory.class);
/* We take a sample fallback from the fallback factory to check if it returns a fallback
that is compatible with the annotated feign interface. */
Object exampleFallback = fallbackFactory.create(new RuntimeException());
Assert.notNull(exampleFallback,
String.format(
"Incompatible fallbackFactory instance for feign client %s. Factory may not produce null!",
feignClientName));
/*if (!target.type().isAssignableFrom(exampleFallback.getClass())) {
throw new IllegalStateException(
String.format(
"Incompatible fallbackFactory instance for feign client %s. Factory produces instances of '%s', but should produce instances of '%s'",
feignClientName, exampleFallback.getClass(), target.type()));
}*/
return builder.target(target, fallbackFactory);
}
示例2: targetWithFallbackFactory
import feign.hystrix.HystrixFeign; //导入方法依赖的package包/类
private <T> T targetWithFallbackFactory(String feignClientName, FeignContext context,
Target.HardCodedTarget<T> target,
HystrixFeign.Builder builder,
Class<?> fallbackFactoryClass) {
FallbackFactory<? extends T> fallbackFactory = (FallbackFactory<? extends T>)
getFromContext("fallbackFactory", feignClientName, context, fallbackFactoryClass, FallbackFactory.class);
/* We take a sample fallback from the fallback factory to check if it returns a fallback
that is compatible with the annotated feign interface. */
Object exampleFallback = fallbackFactory.create(new RuntimeException());
Assert.notNull(exampleFallback,
String.format(
"Incompatible fallbackFactory instance for feign client %s. Factory may not produce null!",
feignClientName));
if (!target.type().isAssignableFrom(exampleFallback.getClass())) {
throw new IllegalStateException(
String.format(
"Incompatible fallbackFactory instance for feign client %s. Factory produces instances of '%s', but should produce instances of '%s'",
feignClientName, exampleFallback.getClass(), target.type()));
}
return builder.target(target, fallbackFactory);
}
示例3: simpleFeignBuilder
import feign.hystrix.HystrixFeign; //导入方法依赖的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));
}
示例4: client
import feign.hystrix.HystrixFeign; //导入方法依赖的package包/类
protected HystrixFeign.Builder client() {
return HystrixFeign.builder().logger(new Slf4jLogger()).retryer(new Retryer.Default())
.logLevel(Logger.Level.FULL);
}
示例5: jaxbclient
import feign.hystrix.HystrixFeign; //导入方法依赖的package包/类
protected HystrixFeign.Builder jaxbclient() {
return HystrixFeign.builder().encoder(new JAXBEncoder(new JAXBContextFactory.Builder().build()))
.decoder(new JAXBDecoder(new JAXBContextFactory.Builder().build()))
.logger(new Slf4jLogger()).retryer(new Retryer.Default()).logLevel(Logger.Level.FULL);
}
示例6: jsonclient
import feign.hystrix.HystrixFeign; //导入方法依赖的package包/类
protected HystrixFeign.Builder jsonclient() {
return HystrixFeign.builder().encoder(new JacksonEncoder()).decoder(new JacksonDecoder())
.logger(new Slf4jLogger()).retryer(new Retryer.Default()).logLevel(Logger.Level.FULL);
}
示例7: targetWithFallback
import feign.hystrix.HystrixFeign; //导入方法依赖的package包/类
private <T> T targetWithFallback(String feignClientName, FeignContext context,
Target.HardCodedTarget<T> target,
HystrixFeign.Builder builder, Class<?> fallback) {
T fallbackInstance = getFromContext("fallback", feignClientName, context, fallback, target.type());
return builder.target(target, fallbackInstance);
}
示例8: newHystrixFeignClientBuilder
import feign.hystrix.HystrixFeign; //导入方法依赖的package包/类
public HystrixFeign.Builder newHystrixFeignClientBuilder() {
return HystrixFeign.builder()
.encoder(encoder)
.decoder(decoder);
}