当前位置: 首页>>代码示例>>Java>>正文


Java JacksonDecoder类代码示例

本文整理汇总了Java中feign.jackson.JacksonDecoder的典型用法代码示例。如果您正苦于以下问题:Java JacksonDecoder类的具体用法?Java JacksonDecoder怎么用?Java JacksonDecoder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JacksonDecoder类属于feign.jackson包,在下文中一共展示了JacksonDecoder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: apiClient

import feign.jackson.JacksonDecoder; //导入依赖的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());

}
 
开发者ID:xstefank,项目名称:lra-service,代码行数:19,代码来源:BeanConfiguration.java

示例2: connect

import feign.jackson.JacksonDecoder; //导入依赖的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);
}
 
开发者ID:retz,项目名称:retz,代码行数:18,代码来源:Retz.java

示例3: create

import feign.jackson.JacksonDecoder; //导入依赖的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;
    }
 
开发者ID:SevenSpikes,项目名称:nopcommerce-api-java-wrapper,代码行数:24,代码来源:NopCommerceFactory.java

示例4: testRequestOptions

import feign.jackson.JacksonDecoder; //导入依赖的package包/类
/**
 * Test the Feign Request Options version of the Vert.x Feign Client.
 * This proves regression is not broken for existing use-cases.
 * @param context Test Context
 */
@Test
public void testRequestOptions(TestContext context) {
  IcecreamServiceApi client = VertxFeign
          .builder()
          .vertx(vertx)
          .options(new Request.Options(5000,5000) ) // Plain old Feign Request.Options (regression)
          .decoder(new JacksonDecoder(TestUtils.MAPPER))
          .logger(new Slf4jLogger())
          .logLevel(Logger.Level.FULL)
          .target(IcecreamServiceApi.class, "http://localhost:8089");

  stubFor(get(urlEqualTo("/icecream/flavors"))
          .withHeader("Accept", equalTo("application/json"))
          .withHeader("Accept-Encoding", absent()) // Test that Accept-Encoding is missing (since we're using Request.Options)
          .willReturn(aResponse()
                  .withStatus(200)
                  .withHeader("Content-Type", "application/json")
                  .withBody(flavorsStr)));

  testClient(client, context);
}
 
开发者ID:OpenFeign,项目名称:feign-vertx,代码行数:27,代码来源:VertxHttpOptionsTest.java

示例5: alohaService

import feign.jackson.JacksonDecoder; //导入依赖的package包/类
/**
 * This is were the "magic" happens: it creates a Feign, which is a proxy interface for remote calling a REST endpoint with
 * Hystrix fallback support.
 *
 * @return The feign pointing to the service URL and with Hystrix fallback.
 */
@Produces
@Singleton
private AlohaService alohaService(Tracer tracer) {
    // bind current span to Hystrix thread
    TracingConcurrencyStrategy.register();

    return HystrixFeign.builder()
            // Use apache HttpClient which contains the ZipKin Interceptors
            .client(new TracingClient(new ApacheHttpClient(HttpClientBuilder.create().build()), tracer))

            // Bind Zipkin Server Span to Feign Thread
            .logger(new Logger.ErrorLogger()).logLevel(Logger.Level.BASIC)
            .decoder(new JacksonDecoder())
            .target(AlohaService.class,"http://aloha:8080/",
                    () -> Collections.singletonList("Aloha response (fallback)"));
}
 
开发者ID:redhat-helloworld-msa,项目名称:hola,代码行数:23,代码来源:TracingConfiguration.java

示例6: getNextService

import feign.jackson.JacksonDecoder; //导入依赖的package包/类
/**
 * This is were the "magic" happens: it creates a Feign, which is a proxy interface for remote calling a REST endpoint with
 * Hystrix fallback support.
 *
 * @return The feign pointing to the service URL and with Hystrix fallback.
 */
private NamasteService getNextService() {
    final String serviceName = "namaste";
    // This stores the Original/Parent ServerSpan from ZiPkin.
    final ServerSpan serverSpan = brave.serverSpanThreadBinder().getCurrentServerSpan();
    final CloseableHttpClient httpclient =
        HttpClients.custom()
            .addInterceptorFirst(new BraveHttpRequestInterceptor(brave.clientRequestInterceptor(), new DefaultSpanNameProvider()))
            .addInterceptorFirst(new BraveHttpResponseInterceptor(brave.clientResponseInterceptor()))
            .build();
    String url = String.format("http://%s:8080/", serviceName);
    return HystrixFeign.builder()
        // Use apache HttpClient which contains the ZipKin Interceptors
        .client(new ApacheHttpClient(httpclient))
        // Bind Zipkin Server Span to Feign Thread
        .requestInterceptor((t) -> brave.serverSpanThreadBinder().setCurrentSpan(serverSpan))
        .logger(new Logger.ErrorLogger()).logLevel(Level.BASIC)
        .decoder(new JacksonDecoder())
        .target(NamasteService.class, url,
            () -> Collections.singletonList("Namaste response (fallback)"));
}
 
开发者ID:redhat-helloworld-msa,项目名称:hello,代码行数:27,代码来源:HelloResource.java

示例7: BackendServiceFactory

import feign.jackson.JacksonDecoder; //导入依赖的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);
				}
			});
}
 
开发者ID:bbilger,项目名称:jrestless-examples,代码行数:24,代码来源:BackendServiceFactory.java

示例8: publish

import feign.jackson.JacksonDecoder; //导入依赖的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);
}
 
开发者ID:hawkular,项目名称:hawkular-apm,代码行数:26,代码来源:AlertsPublisher.java

示例9: createClient

import feign.jackson.JacksonDecoder; //导入依赖的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);

}
 
开发者ID:bolcom,项目名称:fleet-java-api,代码行数:17,代码来源:FleetClient.java

示例10: simpleFeignBuilder

import feign.jackson.JacksonDecoder; //导入依赖的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

示例11: connect

import feign.jackson.JacksonDecoder; //导入依赖的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);
}
 
开发者ID:lanwen,项目名称:wiremock-junit5,代码行数:18,代码来源:TicketApi.java

示例12: apiSetup

import feign.jackson.JacksonDecoder; //导入依赖的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);
}
 
开发者ID:roybailey,项目名称:research-graphql,代码行数:9,代码来源:OrderControllerTest.java

示例13: apiSetup

import feign.jackson.JacksonDecoder; //导入依赖的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);
}
 
开发者ID:roybailey,项目名称:research-graphql,代码行数:9,代码来源:UserControllerTest.java

示例14: apiSetup

import feign.jackson.JacksonDecoder; //导入依赖的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);
}
 
开发者ID:roybailey,项目名称:research-graphql,代码行数:9,代码来源:ProductControllerTest.java

示例15: apiSetup

import feign.jackson.JacksonDecoder; //导入依赖的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());
}
 
开发者ID:roybailey,项目名称:research-graphql,代码行数:10,代码来源:OrderAdaptor.java


注:本文中的feign.jackson.JacksonDecoder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。