io.dropwizard.client.JerseyClientConfiguration Java Examples

The following examples show how to use io.dropwizard.client.JerseyClientConfiguration. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HubMetadataConfiguration.java    From verify-service-provider with MIT License 6 votes vote down vote up
@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;
}
 
Example #2
Source File: EuropeanIdentityConfiguration.java    From verify-service-provider with MIT License 6 votes vote down vote up
@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;
}
 
Example #3
Source File: MockApplication.java    From soabase with Apache License 2.0 6 votes vote down vote up
@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();
}
 
Example #4
Source File: ClientTimeoutTest.java    From tenacity with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() {
    clientConfiguration = new JerseyClientConfiguration();
    clientConfiguration.setConnectionTimeout(Duration.milliseconds(100));
    tenacityConfiguration = new TenacityConfiguration();
    metricRegistry = new MetricRegistry();
    executorService = Executors.newSingleThreadExecutor();
}
 
Example #5
Source File: ComplianceToolModeConfiguration.java    From verify-service-provider with MIT License 5 votes vote down vote up
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());
}
 
Example #6
Source File: BreakerboxServiceConfiguration.java    From breakerbox with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #7
Source File: HelloApp.java    From soabase with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #8
Source File: ClientBuilder.java    From soabase with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #9
Source File: RxJerseyBundle.java    From rx-jersey with MIT License 5 votes vote down vote up
@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);
}
 
Example #10
Source File: RxJerseyBundle.java    From rx-jersey with MIT License 5 votes vote down vote up
public RxJerseyBundle() {
    setClientConfigurationProvider(configuration -> {
        int cores = Runtime.getRuntime().availableProcessors();
        JerseyClientConfiguration clientConfiguration = new JerseyClientConfiguration();
        clientConfiguration.setMaxThreads(cores);

        return clientConfiguration;
    });
}
 
Example #11
Source File: EmoModule.java    From emodb with Apache License 2.0 5 votes vote down vote up
@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());
}
 
Example #12
Source File: ComplianceToolModeAcceptanceTest.java    From verify-service-provider with MIT License 5 votes vote down vote up
@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);
}
 
Example #13
Source File: MsaMetadataConfiguration.java    From verify-service-provider with MIT License 5 votes vote down vote up
@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);
}
 
Example #14
Source File: KeystoreConfiguration.java    From dcos-commons with Apache License 2.0 4 votes vote down vote up
@JsonProperty("jerseyClient")
public JerseyClientConfiguration getJerseyClientConfiguration() {
    return jerseyClient;
}
 
Example #15
Source File: KeystoreConfiguration.java    From dcos-commons with Apache License 2.0 4 votes vote down vote up
@JsonProperty("jerseyClient")
public void setHttpClientConfiguration(JerseyClientConfiguration jerseyClient) {
    this.jerseyClient = jerseyClient;
}
 
Example #16
Source File: EmoModule.java    From emodb with Apache License 2.0 4 votes vote down vote up
/** 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");
}
 
Example #17
Source File: RxJerseyBundle.java    From rx-jersey with MIT License 4 votes vote down vote up
public RxJerseyBundle<T> setClientConfigurationProvider(Function<T, JerseyClientConfiguration> provider) {
    clientConfigurationProvider = provider;
    return this;
}
 
Example #18
Source File: RxJerseyBundle.java    From rx-jersey with MIT License 4 votes vote down vote up
private Client getClient(Environment environment, JerseyClientConfiguration jerseyClientConfiguration) {
    return new JerseyClientBuilder(environment)
            .using(jerseyClientConfiguration)
            .using(new GrizzlyConnectorProvider())
            .buildRx("rxJerseyClient", RxFlowableInvokerProvider.class);
}
 
Example #19
Source File: EmoConfiguration.java    From emodb with Apache License 2.0 4 votes vote down vote up
public EmoConfiguration setHttpClientConfiguration(JerseyClientConfiguration httpClientConfiguration) {
    _httpClientConfiguration = httpClientConfiguration;
    return this;
}
 
Example #20
Source File: EmoConfiguration.java    From emodb with Apache License 2.0 4 votes vote down vote up
public JerseyClientConfiguration getHttpClientConfiguration() {
    return _httpClientConfiguration;
}
 
Example #21
Source File: DropwizardServerConfiguration.java    From microservices-comparison with Apache License 2.0 4 votes vote down vote up
@JsonProperty("httpClient")
public JerseyClientConfiguration getJerseyClientConfiguration() {
    return httpClient;
}
 
Example #22
Source File: BreakerboxServiceConfiguration.java    From breakerbox with Apache License 2.0 4 votes vote down vote up
public JerseyClientConfiguration getTenacityClient() {
    return tenacityClient;
}
 
Example #23
Source File: DashboardConfiguration.java    From SeaCloudsPlatform with Apache License 2.0 4 votes vote down vote up
@JsonProperty("jerseyClient")
public JerseyClientConfiguration getJerseyClientConfiguration() {
    return jerseyClient;
}
 
Example #24
Source File: DashboardTestConfiguration.java    From SeaCloudsPlatform with Apache License 2.0 4 votes vote down vote up
public JerseyClientConfiguration getJerseyClientConfiguration() {
    return jerseyClient;
}
 
Example #25
Source File: TenacityClientBuilder.java    From tenacity with Apache License 2.0 4 votes vote down vote up
public TenacityClientBuilder using(JerseyClientConfiguration jerseyConfiguration) {
    this.jerseyConfiguration = jerseyConfiguration;
    return this;
}