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

Java Decoder类代码示例

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

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



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

示例1: readAnnotation

import feign.codec.Decoder; //导入依赖的package包/类
static ErrorHandlingDefinition readAnnotation(ErrorHandling errorHandling, Decoder responseBodyDecoder) {
    ExceptionGenerator defaultException = new ExceptionGenerator.Builder()
        .withResponseBodyDecoder(responseBodyDecoder)
        .withExceptionType(errorHandling.defaultException())
        .build();
    Map<Integer, ExceptionGenerator> statusCodesDefinition = new HashMap<Integer, ExceptionGenerator>();

    for(ErrorCodes statusCodeDefinition : errorHandling.codeSpecific()) {
        for(int statusCode : statusCodeDefinition.codes()) {
            if(statusCodesDefinition.containsKey(statusCode)) {
                throw new IllegalStateException(
                    "Status Code [" + statusCode + "] " +
                        "has already been declared to throw [" + statusCodesDefinition.get(statusCode).getExceptionType().getName() + "] " +
                        "and [" + statusCodeDefinition.generate() + "] - dupe definition");
            }
            statusCodesDefinition.put(statusCode,
                new ExceptionGenerator.Builder()
                    .withResponseBodyDecoder(responseBodyDecoder)
                    .withExceptionType(statusCodeDefinition.generate())
                    .build());
        }
    }

    return new ErrorHandlingDefinition(defaultException, statusCodesDefinition);
}
 
开发者ID:OpenFeign,项目名称:feign-annotation-error-decoder,代码行数:26,代码来源:AnnotationErrorDecoder.java


示例2: SynchronousMethodHandler

import feign.codec.Decoder; //导入依赖的package包/类
private SynchronousMethodHandler(Target<?> target, Client client, Retryer retryer,
                                 List<RequestInterceptor> requestInterceptors, Logger logger,
                                 Logger.Level logLevel, MethodMetadata metadata,
                                 RequestTemplate.Factory buildTemplateFromArgs, Options options,
                                 Decoder decoder, ErrorDecoder errorDecoder, boolean decode404) {
  this.target = checkNotNull(target, "target");
  this.client = checkNotNull(client, "client for %s", target);
  this.retryer = checkNotNull(retryer, "retryer for %s", target);
  this.requestInterceptors =
      checkNotNull(requestInterceptors, "requestInterceptors for %s", target);
  this.logger = checkNotNull(logger, "logger for %s", target);
  this.logLevel = checkNotNull(logLevel, "logLevel for %s", target);
  this.metadata = checkNotNull(metadata, "metadata for %s", target);
  this.buildTemplateFromArgs = checkNotNull(buildTemplateFromArgs, "metadata for %s", target);
  this.options = checkNotNull(options, "options for %s", target);
  this.errorDecoder = checkNotNull(errorDecoder, "errorDecoder for %s", target);
  this.decoder = checkNotNull(decoder, "decoder for %s", target);
  this.decode404 = decode404;
}
 
开发者ID:wenwu315,项目名称:XXXX,代码行数:20,代码来源:SynchronousMethodHandler.java


示例3: testOverrideDecoder

import feign.codec.Decoder; //导入依赖的package包/类
@Test
public void testOverrideDecoder() throws Exception {
  server.enqueue(new MockResponse().setBody("success!"));

  String url = "http://localhost:" + server.getPort();
  Decoder decoder = new Decoder() {
    @Override
    public Object decode(Response response, Type type) {
      return "fail";
    }
  };

  TestInterface api = Feign.builder().decoder(decoder).target(TestInterface.class, url);
  assertEquals("fail", api.decodedPost());

  assertEquals(1, server.getRequestCount());
}
 
开发者ID:wenwu315,项目名称:XXXX,代码行数:18,代码来源:FeignBuilderTest.java


示例4: resolvesParameterizedResult

import feign.codec.Decoder; //导入依赖的package包/类
@Test
public void resolvesParameterizedResult() throws InterruptedException {
  server.enqueue(new MockResponse().setBody("foo"));

  String baseUrl = server.url("/default").toString();

  Feign.builder()
      .decoder(new Decoder() {
        @Override
        public Object decode(Response response, Type type) {
          assertThat(type)
              .isEqualTo(new TypeToken<Entity<String, Long>>() {
              }.getType());
          return null;
        }
      })
      .target(MyApi.class, baseUrl).get("foo");

  assertThat(server.takeRequest()).hasPath("/default/api/foo");
}
 
开发者ID:wenwu315,项目名称:XXXX,代码行数:21,代码来源:BaseApiTest.java


示例5: resolvesBodyParameter

import feign.codec.Decoder; //导入依赖的package包/类
@Test
public void resolvesBodyParameter() throws InterruptedException {
  server.enqueue(new MockResponse().setBody("foo"));

  String baseUrl = server.url("/default").toString();

  Feign.builder()
      .encoder(new Encoder() {
        @Override
        public void encode(Object object, Type bodyType, RequestTemplate template) {
          assertThat(bodyType)
              .isEqualTo(new TypeToken<Keys<String>>() {
              }.getType());
        }
      })
      .decoder(new Decoder() {
        @Override
        public Object decode(Response response, Type type) {
          assertThat(type)
              .isEqualTo(new TypeToken<Entities<String, Long>>() {
              }.getType());
          return null;
        }
      })
      .target(MyApi.class, baseUrl).getAll(new Keys<String>());
}
 
开发者ID:wenwu315,项目名称:XXXX,代码行数:27,代码来源:BaseApiTest.java


示例6: doesntRetryAfterResponseIsSent

import feign.codec.Decoder; //导入依赖的package包/类
@Test
public void doesntRetryAfterResponseIsSent() throws Exception {
  server.enqueue(new MockResponse().setBody("success!"));
  thrown.expect(FeignException.class);
  thrown.expectMessage("timeout reading POST http://");

  TestInterface api = new TestInterfaceBuilder()
      .decoder(new Decoder() {
        @Override
        public Object decode(Response response, Type type) throws IOException {
          throw new IOException("timeout");
        }
      }).target("http://localhost:" + server.getPort());

  api.post();
}
 
开发者ID:wenwu315,项目名称:XXXX,代码行数:17,代码来源:FeignTest.java


示例7: decodingExceptionGetWrappedInDecode404Mode

import feign.codec.Decoder; //导入依赖的package包/类
@Test
public void decodingExceptionGetWrappedInDecode404Mode() throws Exception {
  server.enqueue(new MockResponse().setResponseCode(404));
  thrown.expect(DecodeException.class);
  thrown.expectCause(isA(NoSuchElementException.class));;

  TestInterface api = new TestInterfaceBuilder()
      .decode404()
      .decoder(new Decoder() {
        @Override
        public Object decode(Response response, Type type) throws IOException {
          assertEquals(404, response.status());
          throw new NoSuchElementException();
        }
      }).target("http://localhost:" + server.getPort());
  api.post();
}
 
开发者ID:wenwu315,项目名称:XXXX,代码行数:18,代码来源:FeignTest.java


示例8: testDelegates

import feign.codec.Decoder; //导入依赖的package包/类
@Test
public void testDelegates() throws Exception {
  final TestInterface api = CompletableFeign.builder()
      .logLevel(Logger.Level.BASIC)
      .logger(new Logger.ErrorLogger())
      .client(new Client.Default(null, null))
      .retryer(new Retryer.Default())
      .encoder(new Encoder.Default())
      .decoder(new Decoder.Default())
      .decode404()
      .errorDecoder(new ErrorDecoder.Default())
      .options(new Request.Options())
      .requestInterceptor(new BasicAuthRequestInterceptor("user", "pass"))
      .requestInterceptors(Collections.emptyList())
      .target(TestInterface.class, url);
  final Response response = api.post("request data");
  assertEquals("response data", Util.toString(response.body().asReader()));
  assertEquals("request data", server.takeRequest().getBody().readString(UTF_8));
}
 
开发者ID:client-side,项目名称:completable-feign,代码行数:20,代码来源:CompletableFeignBuilderTest.java


示例9: feignDecoder

import feign.codec.Decoder; //导入依赖的package包/类
@Bean
public Decoder feignDecoder () {
    val springConverters = messageConverters.getObject().getConverters();
    val decoderConverters = new ArrayList<HttpMessageConverter<?>>(springConverters.size() + 1);

    decoderConverters.addAll(springConverters);
    decoderConverters.add(new SpringManyMultipartFilesReader(4096));

    val httpMessageConverters = new HttpMessageConverters(decoderConverters);

    return new SpringDecoder(new ObjectFactory<HttpMessageConverters>() {

        @Override
        public HttpMessageConverters getObject () {
            return httpMessageConverters;
        }
    });
}
 
开发者ID:OpenFeign,项目名称:feign-form,代码行数:19,代码来源:DownloadClient.java


示例10: create

import feign.codec.Decoder; //导入依赖的package包/类
MethodHandler create(
    final Target<?> target,
    final MethodMetadata metadata,
    final RequestTemplate.Factory buildTemplateFromArgs,
    final HttpClientOptions options,
    final Decoder decoder,
    final ErrorDecoder errorDecoder) {
  return new AsynchronousMethodHandler(
      target,
      client,
      retryer,
      requestInterceptors,
      logger,
      logLevel,
      metadata,
      buildTemplateFromArgs,
      options,
      decoder,
      errorDecoder,
      decode404);
}
 
开发者ID:OpenFeign,项目名称:feign-vertx,代码行数:22,代码来源:AsynchronousMethodHandler.java


示例11: feignDecoder

import feign.codec.Decoder; //导入依赖的package包/类
@Bean
@Primary
Decoder feignDecoder(BeanFactory beanFactory) {
	return new TraceFeignDecoder(beanFactory,
			new ResponseEntityDecoder(new SpringDecoder(this.messageConverters)) {
				@Override
				public Object decode(Response response, Type type)
						throws IOException, FeignException {
					FeignRequestContext feignRequestContext = FeignRequestContext
							.getInstance();
					FeignResponseHeadersHolder feignResponseHeadersHolder = new FeignResponseHeadersHolder(
							response.headers());
					feignResponseHeadersInjector().inject(
							feignRequestContext.getCurrentSpan(),
							feignResponseHeadersHolder);
					return super.decode(
							Response.create(response.status(), response.reason(),
									feignResponseHeadersHolder.responseHeaders,
									response.body()),
							type);
				}
			});
}
 
开发者ID:reshmik,项目名称:Zipkin,代码行数:24,代码来源:TraceFeignClientAutoConfiguration.java


示例12: feign

import feign.codec.Decoder; //导入依赖的package包/类
protected Feign.Builder feign(FeignContext context) {
	FeignLoggerFactory loggerFactory = get(context, FeignLoggerFactory.class);
	Logger logger = loggerFactory.create(this.type);

	// @formatter:off
	Feign.Builder builder = get(context, Feign.Builder.class)
			// required values
			.logger(logger)
			.encoder(get(context, Encoder.class))
			.decoder(get(context, Decoder.class))
			.contract(get(context, Contract.class));
	// @formatter:on

	configureFeign(context, builder);

	return builder;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:18,代码来源:FeignClientFactoryBean.java


示例13: progressDecoder

import feign.codec.Decoder; //导入依赖的package包/类
@Provides(type = SET)
Decoder progressDecoder() {
    return new UpdateableDecoder<Progress>() {
        @Override
        protected Progress build(JsonReader reader) throws IOException {
            Progress.Builder builder = Progress.builder();
            while (reader.hasNext()) {
                String key = reader.nextName();
                if (key.equals("id")) {
                    builder.id(reader.nextString());
                } else if (key.equals("status")) {
                    builder.status(reader.nextString());
                } else if (key.equals("progress")) {
                    builder.progress(reader.nextString());
                } else if (key.equals("error")) {
                    builder.error(reader.nextString());
                } else {
                    reader.skipValue();
                }
            }
            return builder.build();
        }
    };
}
 
开发者ID:jboss-fuse,项目名称:fuse-docker,代码行数:25,代码来源:DockerDecoder.java


示例14: feign

import feign.codec.Decoder; //导入依赖的package包/类
@Provides
@Singleton
Feign feign(Logger logger, Logger.Level logLevel) {

  /**
   * {@link UltraDNS#updateDirectionalPoolRecord(DirectionalRecord, DirectionalGroup)} and {@link
   * UltraDNS#addDirectionalPoolRecord(DirectionalRecord, DirectionalGroup, String)} can take up
   * to 10 minutes to complete.
   */
  Options options = new Options(10 * 1000, 10 * 60 * 1000);
  Decoder decoder = decoder();
  return Feign.builder()
      .logger(logger)
      .logLevel(logLevel)
      .options(options)
      .encoder(new UltraDNSFormEncoder())
      .decoder(decoder)
      .errorDecoder(new UltraDNSErrorDecoder(decoder))
      .build();
}
 
开发者ID:Netflix,项目名称:denominator,代码行数:21,代码来源:UltraDNSProvider.java


示例15: ExceptionGenerator

import feign.codec.Decoder; //导入依赖的package包/类
ExceptionGenerator(Integer bodyIndex, Integer headerMapIndex, Integer numOfParams, Class bodyType, Class<? extends Exception> exceptionType, Decoder bodyDecoder) {
    this.bodyIndex = bodyIndex;
    this.headerMapIndex = headerMapIndex;
    this.numOfParams = numOfParams;
    this.bodyType = bodyType;
    this.exceptionType = exceptionType;
    this.bodyDecoder = bodyDecoder;
}
 
开发者ID:OpenFeign,项目名称:feign-annotation-error-decoder,代码行数:9,代码来源:ExceptionGenerator.java


示例16: connect

import feign.codec.Decoder; //导入依赖的package包/类
static GitHub connect() {
  Decoder decoder = new GsonDecoder();
  return Feign.builder()
      .decoder(decoder)
      .errorDecoder(new GitHubErrorDecoder(decoder))
      .logger(new Logger.ErrorLogger())
      .logLevel(Logger.Level.BASIC)
      .target(GitHub.class, "https://api.github.com");
}
 
开发者ID:wenwu315,项目名称:XXXX,代码行数:10,代码来源:GitHubExample.java


示例17: create

import feign.codec.Decoder; //导入依赖的package包/类
public MethodHandler create(Target<?> target, MethodMetadata md,
                            RequestTemplate.Factory buildTemplateFromArgs,
                            Options options, Decoder decoder, ErrorDecoder errorDecoder) {
  return new SynchronousMethodHandler(target, client, retryer, requestInterceptors, logger,
                                      logLevel, md, buildTemplateFromArgs, options, decoder,
                                      errorDecoder, decode404);
}
 
开发者ID:wenwu315,项目名称:XXXX,代码行数:8,代码来源:SynchronousMethodHandler.java


示例18: ParseHandlersByName

import feign.codec.Decoder; //导入依赖的package包/类
ParseHandlersByName(Contract contract, Options options, Encoder encoder, Decoder decoder,
                    ErrorDecoder errorDecoder, SynchronousMethodHandler.Factory factory) {
  this.contract = contract;
  this.options = options;
  this.factory = factory;
  this.errorDecoder = errorDecoder;
  this.encoder = checkNotNull(encoder, "encoder");
  this.decoder = checkNotNull(decoder, "decoder");
}
 
开发者ID:wenwu315,项目名称:XXXX,代码行数:10,代码来源:ReflectiveFeign.java


示例19: overrideTypeSpecificDecoder

import feign.codec.Decoder; //导入依赖的package包/类
@Test
public void overrideTypeSpecificDecoder() throws Exception {
  server.enqueue(new MockResponse().setBody("success!"));

  TestInterface api = new TestInterfaceBuilder()
      .decoder(new Decoder() {
        @Override
        public Object decode(Response response, Type type) {
          return "fail";
        }
      }).target("http://localhost:" + server.getPort());

  assertEquals(api.post(), "fail");
}
 
开发者ID:wenwu315,项目名称:XXXX,代码行数:15,代码来源:FeignTest.java


示例20: okIfDecodeRootCauseHasNoMessage

import feign.codec.Decoder; //导入依赖的package包/类
@Test
public void okIfDecodeRootCauseHasNoMessage() throws Exception {
  server.enqueue(new MockResponse().setBody("success!"));
  thrown.expect(DecodeException.class);

  TestInterface api = new TestInterfaceBuilder()
      .decoder(new Decoder() {
        @Override
        public Object decode(Response response, Type type) throws IOException {
          throw new RuntimeException();
        }
      }).target("http://localhost:" + server.getPort());

  api.post();
}
 
开发者ID:wenwu315,项目名称:XXXX,代码行数:16,代码来源:FeignTest.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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