本文整理汇总了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);
}
示例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);
}
}
示例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);
}
示例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());
}
示例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();
}
示例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();
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
}
示例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);
}
示例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");
}
示例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");
}