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