本文整理汇总了Java中feign.jackson.JacksonEncoder类的典型用法代码示例。如果您正苦于以下问题:Java JacksonEncoder类的具体用法?Java JacksonEncoder怎么用?Java JacksonEncoder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JacksonEncoder类属于feign.jackson包,在下文中一共展示了JacksonEncoder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: apiClient
import feign.jackson.JacksonEncoder; //导入依赖的package包/类
@Produces
@Singleton
private ApiClient apiClient(Tracer tracer) {
String host = config.getValue(APIGATEWAY_URL, String.class);
String port = config.getValue(APIGATEWAY_PORT, String.class);
log.infof("API gateway expected at %s:%s", host, port);
return HystrixFeign.builder()
.client(new TracingClient(new ApacheHttpClient(HttpClientBuilder.create().build()), tracer))
.logger(new feign.Logger.ErrorLogger()).logLevel(feign.Logger.Level.BASIC)
.encoder(new JacksonEncoder())
.decoder(new JacksonDecoder())
.target(ApiClient.class, String.format("http://%s:%s", host, port),
(LRA lra) -> rx.Observable.empty());
}
示例2: connect
import feign.jackson.JacksonEncoder; //导入依赖的package包/类
static Retz connect(
URI uri,
Authenticator authenticator,
SSLSocketFactory socketFactory,
HostnameVerifier hostnameVerifier) {
String url = Objects.requireNonNull(uri, "uri cannot be null").toString();
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new Jdk8Module());
return Feign.builder()
.client(new Client.Default(socketFactory, hostnameVerifier))
.logger(new Slf4jLogger())
.encoder(new JacksonEncoder(mapper))
.decoder(new JacksonDecoder(mapper))
.errorDecoder(new ErrorResponseDecoder(mapper))
.requestInterceptor(new AuthHeaderInterceptor(authenticator))
.target(Retz.class, url);
}
示例3: create
import feign.jackson.JacksonEncoder; //导入依赖的package包/类
public static NopCommerceClient create(String accessToken, String storeUrl)
{
// Prepare the request interceptors
ArrayList<RequestInterceptor> requestInterceptors = new ArrayList<>();
requestInterceptors.add(new OAuthRequestInterceptor(accessToken));
requestInterceptors.add(new ContentTypeRequestInterceptor());
// Set the connection and read timeouts to 2 minutes. In some nopCommerce websites
// with a lot of data a request may take 1+ minute.
Request.Options feignOptions = new Request.Options(120000, 120000);
NopCommerceClient nopCommerceClient = Feign.builder()
.decoder(new JacksonDecoder())
.encoder(new JacksonEncoder())
// .logger(new Logger.JavaLogger().appendToFile("http.log"))
// .logLevel(Logger.Level.FULL)
.requestInterceptors(requestInterceptors)
.options(feignOptions)
.target(NopCommerceClient.class, storeUrl);
return nopCommerceClient;
}
示例4: create
import feign.jackson.JacksonEncoder; //导入依赖的package包/类
public static ShopifyApiClient create(String accessToken, String myShopifyUrl, String nodeAddress)
{
ShopifyRedissonManager shopifyRedissonManager = new ShopifyRedissonManager(nodeAddress, myShopifyUrl);
// Prepare the request interceptors
ArrayList<RequestInterceptor> requestInterceptors = new ArrayList<>();
requestInterceptors.add(new OAuthRequestInterceptor(accessToken));
requestInterceptors.add(new ContentTypeRequestInterceptor());
requestInterceptors.add(new RequestLimitInterceptor(shopifyRedissonManager));
return Feign.builder()
.decoder(new ShopifyJacksonDecoder(shopifyRedissonManager))
.encoder(new JacksonEncoder())
.requestInterceptors(requestInterceptors)
// .logger(new Logger.JavaLogger().appendToFile("http.log"))
// .logLevel(Logger.Level.FULL)
.target(ShopifyApiClient.class, myShopifyUrl);
}
示例5: BackendServiceFactory
import feign.jackson.JacksonEncoder; //导入依赖的package包/类
@Inject
public BackendServiceFactory(InjectionManager serviceLocator) {
awsLambdaClient = new AWSLambdaClient();
awsLambdaClient.configureRegion(BACKEND_SERVICE_REGION);
backendService = Feign.builder()
.client(FeignLambdaServiceInvokerClient.builder()
.setRegion(BACKEND_SERVICE_REGION)
.setFunctionName(BACKEND_SERVICE_FUNCTION_NAME)
.build())
.decoder(new JacksonDecoder())
.encoder(new JacksonEncoder())
.logger(new Slf4jLogger())
.target(new LambdaServiceFunctionTarget<BackendService>(BackendService.class) {
@Override
public Request apply(RequestTemplate input) {
// TODO inject the context directly => requires the context to be bound as proxy
Context lambdaContext = serviceLocator.getInstance(Context.class);
// propagate the AWS request ID => the called service can log the original AWS request ID
input.header("X-Base-Aws-Request-Id", lambdaContext.getAwsRequestId());
return super.apply(input);
}
});
}
示例6: publish
import feign.jackson.JacksonEncoder; //导入依赖的package包/类
@Asynchronous
public void publish(final Event event) {
if (BASE_URL == null || BASE_URL.isEmpty()) {
logger.hawkularServerNotConfigured();
return;
}
if (USERNAME == null || USERNAME.isEmpty()) {
logger.hawkularServerUsernameNotConfigured();
return;
}
if (PASSWORD == null || PASSWORD.isEmpty()) {
logger.hawkularServerPasswordNotConfigured();
return;
}
HystrixFeign.builder()
.requestInterceptor(new BasicAuthRequestInterceptor(USERNAME, PASSWORD))
.encoder(new JacksonEncoder())
.decoder(new JacksonDecoder())
.retryer(new Retryer.Default())
.target(AlertsService.class, TARGET)
.addEvent(event);
}
示例7: createClient
import feign.jackson.JacksonEncoder; //导入依赖的package包/类
private FleetApi createClient() {
Feign.Builder builder = Feign.builder();
if (client != null) {
builder.client(client);
}
//@formatter:off
builder.contract(new JAXRSModule.JAXRSContract())
.decoder(new JacksonDecoder())
.encoder(new JacksonEncoder())
.errorDecoder(new FleetErrorDecoder())
.requestInterceptors(getRequestInterceptors())
.target(FleetApi.class, url);
//@formatter:on
return builder.target(FleetApi.class, url);
}
示例8: simpleFeignBuilder
import feign.jackson.JacksonEncoder; //导入依赖的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));
}
示例9: connect
import feign.jackson.JacksonEncoder; //导入依赖的package包/类
/**
* Constructs ready-to use client
*
* @param uri base uri
* @return instance of api class
*/
static TicketApi connect(String uri) {
ObjectMapper mapper = new ObjectMapper()
.disable(FAIL_ON_UNKNOWN_PROPERTIES);
return Feign.builder()
.decoder(new JacksonDecoder(mapper))
.encoder(new JacksonEncoder(mapper))
.logger(new Slf4jLogger(TicketApi.class))
.logLevel(Logger.Level.FULL)
.target(TicketApi.class, uri);
}
示例10: apiSetup
import feign.jackson.JacksonEncoder; //导入依赖的package包/类
@Before
public void apiSetup() {
this.api = Feign.builder()
.encoder(new JacksonEncoder())
.decoder(new JacksonDecoder())
.logLevel(Logger.Level.BASIC)
.target(OrderApi.class, "http://localhost:" + port);
}
示例11: apiSetup
import feign.jackson.JacksonEncoder; //导入依赖的package包/类
@Before
public void apiSetup() {
this.api = Feign.builder()
.encoder(new JacksonEncoder(jacksonMapper))
.decoder(new JacksonDecoder(jacksonMapper))
.logLevel(Logger.Level.BASIC)
.target(UserApi.class, "http://localhost:"+port);
}
示例12: apiSetup
import feign.jackson.JacksonEncoder; //导入依赖的package包/类
@Before
public void apiSetup() {
this.api = Feign.builder()
.encoder(new JacksonEncoder())
.decoder(new JacksonDecoder())
.logLevel(Logger.Level.BASIC)
.target(ProductApi.class, "http://localhost:" + port);
}
示例13: apiSetup
import feign.jackson.JacksonEncoder; //导入依赖的package包/类
@PostConstruct
public void apiSetup() {
log.info("Connecting {} to {}", OrderApi.class.getSimpleName(), properties.getUrlOrderService());
this.api = Feign.builder()
.encoder(new JacksonEncoder())
.decoder(new JacksonDecoder())
.logLevel(Logger.Level.BASIC)
.target(OrderApi.class, properties.getUrlOrderService());
}
示例14: apiSetup
import feign.jackson.JacksonEncoder; //导入依赖的package包/类
@PostConstruct
public void apiSetup() {
log.info("Connecting {} to {}", UserApi.class.getSimpleName(), properties.getUrlUserService());
this.api = Feign.builder()
.encoder(new JacksonEncoder(jacksonMapper))
.decoder(new JacksonDecoder(jacksonMapper))
.logLevel(Logger.Level.BASIC)
.target(UserApi.class, properties.getUrlUserService());
}
示例15: apiSetup
import feign.jackson.JacksonEncoder; //导入依赖的package包/类
@PostConstruct
public void apiSetup() {
log.info("Connecting {} to {}", ProductApi.class.getSimpleName(), properties.getUrlProductService());
this.api = Feign.builder()
.encoder(new JacksonEncoder())
.decoder(new JacksonDecoder())
.logLevel(Logger.Level.BASIC)
.target(ProductApi.class, properties.getUrlProductService());
}