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


Java GsonEncoder类代码示例

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


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

示例1: getInstance

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

import feign.gson.GsonEncoder; //导入依赖的package包/类
/**
 * Fetch the token from the authentication service.
 *
 *  @param loginURL           Login Url.
 *  @return Auth token.
 */
public static String getAuthToken(final String loginURL) {

    Login client = Feign.builder().client(getClientHostVerificationDisabled())
            .encoder(new GsonEncoder(ModelUtils.GSON))
            .target(Login.class, loginURL);

    Response response = client.login(new AuthRequest(getUsername(), getPassword(), "LOCAL"));

    if (response.status() == OK.code()) {
        Collection<String> headers = response.headers().get(TOKEN_HEADER_NAME);
        return headers.toArray(new String[headers.size()])[0];
    } else {
        throw new TestFrameworkException(TestFrameworkException.Type.LoginFailed, "Exception while " +
                "logging into the cluster. Authentication service returned the following error: "
                + response);
    }
}
 
开发者ID:pravega,项目名称:pravega,代码行数:24,代码来源:LoginClient.java

示例3: StoreClient

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

示例4: build

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

示例5: feign

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

示例6: feign

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

示例7: build

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

示例8: buildInstance

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

示例9: getInstance

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

示例10: getInstance

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

示例11: getInstance

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

示例12: build

import feign.gson.GsonEncoder; //导入依赖的package包/类
public Marathon build() {
    if (null == listOfServers) {
        if (!StringUtils.isEmpty(token)) {
            return getInstanceWithTokenAuth(baseEndpoint, token);
        } else if (!StringUtils.isEmpty(username)) {
            return getInstanceWithBasicAuth(baseEndpoint, username, password);
        } else {
            return getInstance(baseEndpoint);
        }
    } else {
        setMarathonRibbonProperty("listOfServers", listOfServers);
        setMarathonRibbonProperty("OkToRetryOnAllOperations", Boolean.TRUE.toString());
        setMarathonRibbonProperty("MaxAutoRetriesNextServer", maxRetryCount);
        setMarathonRibbonProperty("ConnectTimeout", connectionTimeout);
        setMarathonRibbonProperty("ReadTimeout", readTimeout);

        Feign.Builder builder = Feign.builder()
                .client(RibbonClient.builder().lbClientFactory(new MarathonLBClientFactory()).build())
                .encoder(new GsonEncoder(ModelUtils.GSON))
                .decoder(new GsonDecoder(ModelUtils.GSON))
                .errorDecoder(new MarathonErrorDecoder());

        if (!StringUtils.isEmpty(token)) {
            builder.requestInterceptor(new TokenAuthRequestInterceptor(token));
        }
        else if (!StringUtils.isEmpty(username)) {
            builder.requestInterceptor(new BasicAuthRequestInterceptor(username,password));
        }

        builder.requestInterceptor(new MarathonHeadersInterceptor());

        return builder.target(Marathon.class, DEFAULT_MARATHON_ENDPOINT);
    }
}
 
开发者ID:aatarasoff,项目名称:spring-cloud-marathon,代码行数:35,代码来源:RibbonMarathonClient.java

示例13: getInstance

import feign.gson.GsonEncoder; //导入依赖的package包/类
/**
 * The generalized version of the method that allows more in-depth customizations via
 * {@link RequestInterceptor}s.
 *
 * @param endpoint URL for Chronos API
 */
public static Chronos getInstance(String endpoint, RequestInterceptor... interceptors) {
	Builder b = Feign.builder()
			.encoder(new GsonEncoder(AbstractModel.GSON))
			.decoder(new MultiDecoder())
			.errorDecoder(new ChronosErrorDecoder());
	if (interceptors != null) {
		b.requestInterceptors(asList(interceptors));
	}
	b.requestInterceptor(new ChronosHeadersInterceptor());
	return b.target(Chronos.class, endpoint);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer-mesos,代码行数:18,代码来源:ChronosClient.java

示例14: buildClient

import feign.gson.GsonEncoder; //导入依赖的package包/类
private <T> T buildClient(Class<T> clientClazz, RequestInterceptor authenticationInterceptor) {
    return Feign.builder()
            .logger(new Slf4jLogger(this.getClass()))
            .logLevel(Logger.Level.FULL)
            .encoder(new GsonEncoder())
            .decoder(new GsonDecoder())
            .requestInterceptor(authenticationInterceptor)
            .target(clientClazz, "https://api.meetup.com");
}
 
开发者ID:BordeauxJUG,项目名称:bdxjug-api,代码行数:10,代码来源:MeetupFeignConfiguration.java

示例15: googleSheetsClient

import feign.gson.GsonEncoder; //导入依赖的package包/类
@Bean
public GoogleSheetClient googleSheetsClient() {
    return Feign.builder()
            .logger(new Slf4jLogger(this.getClass()))
            .logLevel(Logger.Level.FULL)
            .encoder(new GsonEncoder())
            .decoder(new GsonDecoder())
            .requestInterceptor(r -> r.query("key", gsKey))
            .target(GoogleSheetClient.class, "https://sheets.googleapis.com/v4");
}
 
开发者ID:BordeauxJUG,项目名称:bdxjug-api,代码行数:11,代码来源:GoogleSheetConfiguration.java


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