下面列出了com.fasterxml.jackson.annotation.JsonAlias#io.dropwizard.client.JerseyClientConfiguration 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@JsonCreator
public HubMetadataConfiguration(
@JsonProperty("uri") @JsonAlias({"url"}) URI uri,
@JsonProperty("minRefreshDelay") Long minRefreshDelay,
@JsonProperty("maxRefreshDelay") Long maxRefreshDelay,
@JsonProperty("expectedEntityId") String expectedEntityId,
@JsonProperty("client") JerseyClientConfiguration client,
@JsonProperty("jerseyClientName") String jerseyClientName,
@JsonProperty("hubFederationId") String hubFederationId,
@JsonProperty("trustStore") TrustStoreConfiguration trustStoreConfiguration,
@JsonProperty("hubTrustStore") TrustStoreConfiguration hubTrustStoreConfiguration,
@JsonProperty("idpTrustStore") TrustStoreConfiguration idpTrustStoreConfiguration) {
super(uri, minRefreshDelay, maxRefreshDelay, expectedEntityId, client,
ofNullable(jerseyClientName).orElse(HUB_JERSEY_CLIENT_NAME), hubFederationId);
this.trustStoreConfiguration = trustStoreConfiguration;
this.hubTrustStoreConfiguration = hubTrustStoreConfiguration;
this.idpTrustStoreConfiguration = idpTrustStoreConfiguration;
}
@JsonCreator
public EuropeanIdentityConfiguration(@JsonProperty("hubConnectorEntityId") String hubConnectorEntityId,
@JsonProperty("acceptableHubConnectorEntityIds") List<String> acceptableHubConnectorEntityIds,
@NotNull @Valid @JsonProperty("enabled") boolean enabled,
@JsonProperty("trustAnchorUri") URI trustAnchorUri,
@JsonProperty("minRefreshDelay") Long minRefreshDelay,
@JsonProperty("maxRefreshDelay") Long maxRefreshDelay,
@JsonProperty("trustAnchorMaxRefreshDelay") Long trustAnchorMaxRefreshDelay,
@JsonProperty("trustAnchorMinRefreshDelay") Long trustAnchorMinRefreshDelay,
@JsonProperty("client") JerseyClientConfiguration client,
@JsonProperty("jerseyClientName") String jerseyClientName,
@JsonProperty("trustStore") TrustStoreConfiguration trustStore,
@JsonProperty("metadataSourceUri") URI metadataSourceUri
){
super(trustAnchorUri, minRefreshDelay, maxRefreshDelay, trustAnchorMaxRefreshDelay, trustAnchorMinRefreshDelay, client, jerseyClientName, trustStore, metadataSourceUri);
this.enabled = enabled;
this.trustStoreConfiguration = trustStore;
this.hubConnectorEntityId = hubConnectorEntityId;
this.acceptableHubConnectorEntityIds = acceptableHubConnectorEntityIds;
}
@Override
public void run(TestConfiguration configuration, Environment environment) throws Exception
{
AbstractBinder binder = new AbstractBinder()
{
@Override
protected void configure()
{
bind(throwInternalError).to(AtomicBoolean.class);
bind(counter).to(AtomicInteger.class);
}
};
environment.jersey().register(binder);
environment.jersey().register(MockResource.class);
JerseyClientConfiguration clientConfiguration = new JerseyClientConfiguration();
clientConfiguration.setMaxConnectionsPerRoute(Integer.MAX_VALUE);
clientConfiguration.setMaxConnections(Integer.MAX_VALUE);
client = new ClientBuilder(environment).buildJerseyClient(clientConfiguration, "test");
startedLatch.countDown();
}
public ComplianceToolClient createComplianceToolService(Environment environment, String url, Integer timeout) {
JerseyClientConfiguration configuration = new JerseyClientConfiguration();
configuration.setConnectionRequestTimeout(Duration.seconds(timeout));
configuration.setTimeout(Duration.seconds(timeout));
configuration.setConnectionTimeout(Duration.seconds(timeout));
Client client = new JerseyClientBuilder(environment).using(configuration).build("Compliance Tool Initiation Client");
return new ComplianceToolClient(client, url, serviceEntityId, getSigningCertificate(), getEncryptionCertificate());
}
@JsonCreator
public MsaMetadataConfiguration(
@JsonProperty("uri") @JsonAlias({ "url" }) URI uri,
@JsonProperty("minRefreshDelay") Long minRefreshDelay,
@JsonProperty("maxRefreshDelay") Long maxRefreshDelay,
@JsonProperty(value = "expectedEntityId", required = true) String expectedEntityId,
@JsonProperty("client") JerseyClientConfiguration client,
@JsonProperty("jerseyClientName") String jerseyClientName,
@JsonProperty("hubFederationId") String hubFederationId
) {
super(uri, minRefreshDelay, maxRefreshDelay, expectedEntityId, client, ofNullable(jerseyClientName).orElse(MSA_JERSEY_CLIENT_NAME), hubFederationId);
}
@Before
public void setUpBefore() {
JerseyClientConfiguration configuration = new JerseyClientConfiguration();
configuration.setTimeout(Duration.seconds(10));
configuration.setConnectionTimeout(Duration.seconds(10));
configuration.setConnectionRequestTimeout(Duration.seconds(10));
client = new JerseyClientBuilder(appRule.getEnvironment()).using(configuration).build(ComplianceToolModeAcceptanceTest.class.getName());
complianceTool = new ComplianceToolService(client);
}
@Override
protected void configure() {
bind(TaskRegistry.class).to(getTaskRegistryClass()).asEagerSingleton();
bind(ResourceRegistry.class).to(DropwizardResourceRegistry.class).asEagerSingleton();
bind(String.class).annotatedWith(ServerCluster.class).toInstance(_configuration.getCluster());
bind(JerseyClientConfiguration.class).toInstance(_configuration.getHttpClientConfiguration());
install(new SelfHostAndPortModule());
}
public RxJerseyBundle() {
setClientConfigurationProvider(configuration -> {
int cores = Runtime.getRuntime().availableProcessors();
JerseyClientConfiguration clientConfiguration = new JerseyClientConfiguration();
clientConfiguration.setMaxThreads(cores);
return clientConfiguration;
});
}
@Override
public void run(T configuration, Environment environment) throws Exception {
JerseyEnvironment jersey = environment.jersey();
JerseyClientConfiguration clientConfiguration = clientConfigurationProvider.apply(configuration);
Client client = getClient(environment, clientConfiguration);
rxJerseyClientFeature.setClient(client);
jersey.register(rxJerseyServerFeature);
jersey.register(rxJerseyClientFeature);
}
public Client buildJerseyClient(JerseyClientConfiguration configuration, String clientName)
{
ConnectorProvider localConnectorProvider;
if ( connectorProvider != null )
{
localConnectorProvider = connectorProvider;
}
else
{
HttpClientBuilder apacheHttpClientBuilder = new HttpClientBuilder(environment).using(configuration);
CloseableHttpClient closeableHttpClient = apacheHttpClientBuilder.build(clientName);
localConnectorProvider = new JerseyRetryConnectorProvider(retryComponents, closeableHttpClient, configuration.isChunkedEncodingEnabled());
}
JerseyClientBuilder builder = new JerseyClientBuilder(environment)
.using(configuration)
.using(localConnectorProvider);
for ( Class<?> klass : providerClasses )
{
builder = builder.withProvider(klass);
}
for ( Object provider : providers )
{
builder = builder.withProvider(provider);
}
Client client = builder
.build(clientName);
SoaBundle.getFeatures(environment).putNamed(client, Client.class, clientName);
return client;
}
@Override
protected void internalRun(Configuration configuration, Environment environment)
{
ClientBuilder builder = new ClientBuilder(environment);
builder.buildJerseyClient(new JerseyClientConfiguration(), "jersey");
builder.buildHttpClient(new HttpClientConfiguration(), "apache");
environment.jersey().register(HelloResourceJersey.class);
environment.jersey().register(HelloResourceApache.class);
}
@JsonCreator
public BreakerboxServiceConfiguration(@JsonProperty("azure") AzureTableConfiguration azure,
@JsonProperty("tenacityClient") JerseyClientConfiguration tenacityClientConfiguration,
@JsonProperty("breakerboxServicesPropertyKeys") TenacityConfiguration breakerboxServicesPropertyKeys,
@JsonProperty("breakerboxServicesConfiguration") TenacityConfiguration breakerboxServicesConfiguration,
@JsonProperty("breakerbox") BreakerboxConfiguration breakerboxConfiguration,
@JsonProperty("ldap") LdapConfiguration ldapConfiguration,
@JsonProperty("archaiusOverride") ArchaiusOverrideConfiguration archaiusOverride,
@JsonProperty("database") JdbiConfiguration jdbiConfiguration,
@JsonProperty("breakerboxHostAndPort") HostAndPort breakerboxHostAndPort,
@JsonProperty("defaultDashboard") String defaultDashboard,
@JsonProperty("turbine") Path turbine,
@JsonProperty("instanceDiscoveryClass") String instanceDiscoveryClass,
@JsonProperty("hystrixStreamSuffix") String hystrixStreamSuffix,
@JsonProperty("rancherDiscovery") RancherInstanceConfiguration rancherInstanceConfiguration,
@JsonProperty("marathonDiscovery")List<MarathonClientConfiguration> marathonClientConfiguration) {
this.azure = Optional.ofNullable(azure);
this.tenacityClient = tenacityClientConfiguration;
this.breakerboxServicesPropertyKeys = Optional.ofNullable(breakerboxServicesPropertyKeys).orElse(new TenacityConfiguration());
this.breakerboxServicesConfiguration = Optional.ofNullable(breakerboxServicesConfiguration).orElse(new TenacityConfiguration());
this.breakerboxConfiguration = breakerboxConfiguration;
this.ldapConfiguration = Optional.ofNullable(ldapConfiguration);
this.archaiusOverride = Optional.ofNullable(archaiusOverride).orElse(new ArchaiusOverrideConfiguration());
this.jdbiConfiguration = Optional.ofNullable(jdbiConfiguration);
this.breakerboxHostAndPort = Optional.ofNullable(breakerboxHostAndPort).orElse(HostAndPort.fromParts("localhost", 8080));
this.defaultDashboard = Optional.ofNullable(defaultDashboard).orElse("production");
this.turbine = Optional.ofNullable(turbine).orElse(Paths.get("breakerbox-instances.yml"));
this.instanceDiscoveryClass = Objects.isNull(instanceDiscoveryClass) ? Optional.ofNullable(System.getProperty("InstanceDiscovery.impl")) : Optional.of(instanceDiscoveryClass);
this.hystrixStreamSuffix = Optional.ofNullable(hystrixStreamSuffix);
this.rancherInstanceConfiguration = Optional.ofNullable(rancherInstanceConfiguration);
this.marathonClientConfiguration = Optional.ofNullable(marathonClientConfiguration);
}
@Before
public void setup() {
clientConfiguration = new JerseyClientConfiguration();
clientConfiguration.setConnectionTimeout(Duration.milliseconds(100));
tenacityConfiguration = new TenacityConfiguration();
metricRegistry = new MetricRegistry();
executorService = Executors.newSingleThreadExecutor();
}
public JerseyClientConfiguration getHttpClientConfiguration() {
return _httpClientConfiguration;
}
public EmoConfiguration setHttpClientConfiguration(JerseyClientConfiguration httpClientConfiguration) {
_httpClientConfiguration = httpClientConfiguration;
return this;
}
/** Configure the HTTP client for out-bound HTTP calls. */
@Provides @Singleton
Client provideJerseyClient(JerseyClientConfiguration configuration, Environment environment) {
return new JerseyClientBuilder(environment).using(configuration).using(environment).build("emodb");
}
@JsonProperty("jerseyClient")
public void setHttpClientConfiguration(JerseyClientConfiguration jerseyClient) {
this.jerseyClient = jerseyClient;
}
@JsonProperty("jerseyClient")
public JerseyClientConfiguration getJerseyClientConfiguration() {
return jerseyClient;
}
public RxJerseyBundle<T> setClientConfigurationProvider(Function<T, JerseyClientConfiguration> provider) {
clientConfigurationProvider = provider;
return this;
}
private Client getClient(Environment environment, JerseyClientConfiguration jerseyClientConfiguration) {
return new JerseyClientBuilder(environment)
.using(jerseyClientConfiguration)
.using(new GrizzlyConnectorProvider())
.buildRx("rxJerseyClient", RxFlowableInvokerProvider.class);
}
@JsonProperty("httpClient")
public JerseyClientConfiguration getJerseyClientConfiguration() {
return httpClient;
}
public JerseyClientConfiguration getTenacityClient() {
return tenacityClient;
}
@JsonProperty("jerseyClient")
public JerseyClientConfiguration getJerseyClientConfiguration() {
return jerseyClient;
}
public JerseyClientConfiguration getJerseyClientConfiguration() {
return jerseyClient;
}
public TenacityClientBuilder using(JerseyClientConfiguration jerseyConfiguration) {
this.jerseyConfiguration = jerseyConfiguration;
return this;
}