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


Java GsonDecoder类代码示例

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


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

示例1: getInstance

import feign.gson.GsonDecoder; //导入依赖的package包/类
/**
 * The generalized version of the method that allows more in-depth customizations via
 * {@link RequestInterceptor}s.
 *
 * @param endpoint
 * 		URL of Marathon
 * @param interceptors optional request interceptors
 * @return Marathon client
 */
public static Marathon getInstance(String endpoint, RequestInterceptor... interceptors) {

	Builder b = Feign.builder()
			.encoder(new GsonEncoder(ModelUtils.GSON))
			.decoder(new GsonDecoder(ModelUtils.GSON))
			.errorDecoder(new MarathonErrorDecoder());
	if (interceptors != null)
		b.requestInterceptors(asList(interceptors));
	String debugOutput = System.getenv(DEBUG_JSON_OUTPUT);
	if ("System.out".equals(debugOutput)) {
		System.setProperty("org.slf4j.simpleLogger.logFile", "System.out");
		System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "debug");
		b.logger(new Slf4jLogger()).logLevel(Logger.Level.FULL);
	} else if (debugOutput != null) {
		b.logger(new Logger.JavaLogger().appendToFile(debugOutput)).logLevel(Logger.Level.FULL);
	}
	b.requestInterceptor(new MarathonHeadersInterceptor());
	return b.target(Marathon.class, endpoint);
}
 
开发者ID:mesosphere,项目名称:marathon-client,代码行数:29,代码来源:MarathonClient.java

示例2: main

import feign.gson.GsonDecoder; //导入依赖的package包/类
public static void main(String... args) {

        MetricRegistry metricRegistry = new MetricRegistry();

        final ConsoleReporter reporter = ConsoleReporter.forRegistry(metricRegistry).convertRatesTo(TimeUnit.SECONDS)
                .convertDurationsTo(TimeUnit.MILLISECONDS).build();

        GitHub github = Feign.builder().invocationHandlerFactory(
                new FeignOutboundMetricsDecorator(new InvocationHandlerFactory.Default(), metricRegistry))
                .decoder(new GsonDecoder()).target(GitHub.class, "https://api.github.com");

        // Fetch and print a list of the contributors to this library.
        List<Contributor> contributors = github.contributors("mwiede", "metrics-feign");
        for (Contributor contributor : contributors) {
            System.out.println(contributor.login + " (" + contributor.contributions + ")");
        }

        reporter.report();
    }
 
开发者ID:mwiede,项目名称:metrics-feign,代码行数:20,代码来源:Example.java

示例3: main

import feign.gson.GsonDecoder; //导入依赖的package包/类
public static void main(String... args) throws InterruptedException {
  Gson gson = new GsonBuilder()
      .registerTypeAdapter(new TypeToken<Response<Page>>() {
      }.getType(), pagesAdapter)
      .create();

  Wikipedia wikipedia = Feign.builder()
      .decoder(new GsonDecoder(gson))
      .logger(new Logger.ErrorLogger())
      .logLevel(Logger.Level.BASIC)
      .target(Wikipedia.class, "https://en.wikipedia.org");

  System.out.println("Let's search for PTAL!");
  Iterator<Page> pages = lazySearch(wikipedia, "PTAL");
  while (pages.hasNext()) {
    System.out.println(pages.next().title);
  }
}
 
开发者ID:wenwu315,项目名称:XXXX,代码行数:19,代码来源:WikipediaExample.java

示例4: StoreClient

import feign.gson.GsonDecoder; //导入依赖的package包/类
public StoreClient(RequestInterceptor requestInterceptor) {

        Feign.Builder builder = Feign.builder().client(
                org.wso2.carbon.apimgt.integration.client.util.Utils.getSSLClient()).logger(new Slf4jLogger())
                .logLevel(Logger.Level.FULL)
                .requestInterceptor(requestInterceptor).encoder(new GsonEncoder()).decoder(new GsonDecoder());
        String basePath = Utils.replaceSystemProperty(APIMConfigReader.getInstance().getConfig().getStoreEndpoint());

        apis = builder.target(APICollectionApi.class, basePath);
        individualApi = builder.target(APIIndividualApi.class, basePath);
        applications = builder.target(ApplicationCollectionApi.class, basePath);
        individualApplication = builder.target(ApplicationIndividualApi.class, basePath);
        subscriptions = builder.target(SubscriptionCollectionApi.class, basePath);
        individualSubscription = builder.target(SubscriptionIndividualApi.class, basePath);
        subscriptionMultitpleApi = builder.target(SubscriptionMultitpleApi.class, basePath);
        tags = builder.target(TagCollectionApi.class, basePath);
        individualTier = builder.target(ThrottlingTierIndividualApi.class, basePath);
        tiers = builder.retryer(new Retryer.Default(100L, TimeUnit.SECONDS.toMillis(1L), 1))
                .options(new Request.Options(10000, 5000))
                .target(ThrottlingTierCollectionApi.class, basePath);

    }
 
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:23,代码来源:StoreClient.java

示例5: HubspotRestFormClient

import feign.gson.GsonDecoder; //导入依赖的package包/类
public HubspotRestFormClient(final Configuration configuration, final TokenProvider tokenProvider)
{
    super(tokenProvider);

    Options connectionConfig = new Options(
            configuration.getConnectTimeoutMillis(), configuration.getReadTimeoutMillis());

    formsRawApi = Feign.builder()
            .requestInterceptor(getAuthenticationInterceptor())
            .options(connectionConfig)
            .target(FormsRawApi.class, configuration.getApiUrl());

    formsEntityApi = Feign.builder()
                          .requestInterceptor(getAuthenticationInterceptor())
                          .options(connectionConfig)
                          .decoder(new GsonDecoder(configuredGson()))
                          .target(FormsEntityApi.class, configuration.getApiUrl());
}
 
开发者ID:Smartling,项目名称:hubspot-rest-sdk-java,代码行数:19,代码来源:HubspotRestFormClient.java

示例6: build

import feign.gson.GsonDecoder; //导入依赖的package包/类
/**
 * Generate a new Marathon client.
 * 
 * @param marathonProperties
 *          the properties containing the client information
 * @return the new client
 */
@Override
public Marathon build(MarathonProperties marathonProperties) {
  LOG.info("Generating Marathon client with parameters: {}", marathonProperties);

  return Feign
      .builder()
      .encoder(new GsonEncoder(ModelUtils.GSON))
      .decoder(new GsonDecoder(ModelUtils.GSON))
      .logger(new Slf4jLogger(Marathon.class))
      .logLevel(Level.FULL)
      .errorDecoder(new DeserializingMarathonErrorDecoder())
      .requestInterceptor(new BasicAuthRequestInterceptor(
          marathonProperties.getUsername(), marathonProperties.getPassword()))
      .requestInterceptor(template -> {
        template.header(HttpHeaders.ACCEPT, "application/json");
        template.header(HttpHeaders.CONTENT_TYPE, "application/json");
      })
      .target(Marathon.class, marathonProperties.getUrl().toString());
}
 
开发者ID:indigo-dc,项目名称:orchestrator,代码行数:27,代码来源:MarathonClientFactory.java

示例7: feign

import feign.gson.GsonDecoder; //导入依赖的package包/类
@Provides
@Singleton
Feign feign(Logger logger, Logger.Level logLevel, DynECTErrorDecoder errorDecoder) {
  return Feign.builder()
      .logger(logger)
      .logLevel(logLevel)
      .encoder(new GsonEncoder())
      .decoder(new GsonDecoder(Arrays.<TypeAdapter<?>>asList(
                   new TokenAdapter(),
                   new NothingForbiddenAdapter(),
                   new ResourceRecordSetsAdapter(),
                   new ZoneNamesAdapter(),
                   new RecordsByNameAndTypeAdapter()))
      )
      .errorDecoder(errorDecoder)
      .build();
}
 
开发者ID:Netflix,项目名称:denominator,代码行数:18,代码来源:DynECTProvider.java

示例8: feign

import feign.gson.GsonDecoder; //导入依赖的package包/类
@Provides
@Singleton
Feign feign(Logger logger, Logger.Level logLevel) {
  RecordAdapter recordAdapter = new RecordAdapter();
  return Feign.builder()
      .logger(logger)
      .logLevel(logLevel)
      .encoder(new GsonEncoder(Collections.<TypeAdapter<?>>singleton(recordAdapter)))
      .decoder(new GsonDecoder(Arrays.asList(
                   new KeystoneV2AccessAdapter(),
                   recordAdapter,
                   new DomainListAdapter(),
                   new RecordListAdapter()))
      )
      .build();
}
 
开发者ID:Netflix,项目名称:denominator,代码行数:17,代码来源:DesignateProvider.java

示例9: build

import feign.gson.GsonDecoder; //导入依赖的package包/类
@Override
public TargetProcess build() {
    return Feign.builder()
            .decoder(new GsonDecoder())
            .encoder(new GsonEncoder())
            .requestInterceptor(requestInterceptor)
            .target(TargetProcess.class, url);
}
 
开发者ID:drsoares,项目名称:targetprocess-testng,代码行数:9,代码来源:TargetProcessBuilder.java

示例10: buildInstance

import feign.gson.GsonDecoder; //导入依赖的package包/类
private static DCOS buildInstance(String endpoint, Consumer<Feign.Builder> customize) {
    GsonDecoder decoder = new GsonDecoder(ModelUtils.GSON);
    GsonEncoder encoder = new GsonEncoder(ModelUtils.GSON);

    Feign.Builder builder = Feign.builder()
                                 .encoder(encoder)
                                 .decoder(decoder)
                                 .errorDecoder(new DCOSErrorDecoder());
    customize.accept(builder);
    builder.requestInterceptor(new DCOSAPIInterceptor());

    return builder.target(DCOS.class, endpoint);
}
 
开发者ID:mesosphere,项目名称:marathon-client,代码行数:14,代码来源:DCOSClient.java

示例11: main

import feign.gson.GsonDecoder; //导入依赖的package包/类
public static void main(String... args) {
  GitHub github = Feign.builder()
      .decoder(new GsonDecoder())
      .target(GitHub.class, "https://api.github.com");

  System.out.println("Let's fetch and print a list of the contributors to this library.");
  List<Contributor> contributors = github.contributors("netflix", "feign");
  for (Contributor contributor : contributors) {
    System.out.println(contributor.login + " (" + contributor.contributions + ")");
  }
}
 
开发者ID:wenwu315,项目名称:XXXX,代码行数:12,代码来源:GitHubExample.java

示例12: connect

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

示例13: getInstance

import feign.gson.GsonDecoder; //导入依赖的package包/类
/**
 * The generalized version of the method that allows more in-depth customizations via
 * {@link RequestInterceptor}s.
 *
 * @param endpoint
 * 		URL of Marathon
 */
private static Marathon getInstance(String endpoint, RequestInterceptor... interceptors) {
	Builder b = Feign.builder()
			.encoder(new GsonEncoder(ModelUtils.GSON))
			.decoder(new GsonDecoder(ModelUtils.GSON))
			.errorDecoder(new MarathonErrorDecoder());

	if (interceptors!=null)
		b.requestInterceptors(asList(interceptors));

	b.requestInterceptor(new MarathonHeadersInterceptor());

	return b.target(Marathon.class, endpoint);
}
 
开发者ID:pikselpalette,项目名称:gocd-elastic-agent-marathon,代码行数:21,代码来源:MarathonClient.java

示例14: getInstance

import feign.gson.GsonDecoder; //导入依赖的package包/类
/**
 * The generalized version of the method that allows more in-depth customizations via
 * {@link RequestInterceptor}s.
 *
 * @param endpoint URL of Marathon
 */
public static Marathon getInstance(String endpoint, RequestInterceptor... interceptors) {
    Feign.Builder b = Feign.builder()
            .encoder(new GsonEncoder(ModelUtils.GSON))
            .logger(new Slf4jLogger())
            .decoder(new GsonDecoder(ModelUtils.GSON))
            .errorDecoder(new MarathonErrorDecoder());
    if (interceptors != null) {
        b.requestInterceptors(asList(interceptors));
    }
    b.requestInterceptor(new MarathonHeadersInterceptor());
    return b.target(Marathon.class, endpoint);
}
 
开发者ID:wso2,项目名称:mesos-artifacts,代码行数:19,代码来源:MesosMarathonClient.java

示例15: getInstance

import feign.gson.GsonDecoder; //导入依赖的package包/类
/**
 * The generalized version of the method that allows more in-depth customizations via
 * {@link RequestInterceptor}s.
 *
 * @param endpoint URL of Mesos DNS
 */
public static MesosDNS getInstance(String endpoint, RequestInterceptor... interceptors) {
    Feign.Builder b = Feign.builder()
            .encoder(new GsonEncoder(ModelUtils.GSON))
            .logger(new Slf4jLogger())
            .decoder(new GsonDecoder(ModelUtils.GSON))
            .errorDecoder(new MesosDNSErrorDecoder());
    if (interceptors != null) {
        b.requestInterceptors(asList(interceptors));
    }
    b.requestInterceptor(new MesosDNSHeadersInterceptor());
    return b.target(MesosDNS.class, endpoint);
}
 
开发者ID:wso2,项目名称:mesos-artifacts,代码行数:19,代码来源:MesosDNSClient.java


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