Search in sources :

Example 1 with EnvironmentVariableSubstitutor

use of io.dropwizard.configuration.EnvironmentVariableSubstitutor in project verify-hub by alphagov.

the class StubEventSinkApplication method initialize.

@Override
public final void initialize(Bootstrap<StubEventSinkConfiguration> bootstrap) {
    // Enable variable substitution with environment variables
    bootstrap.setConfigurationSourceProvider(new SubstitutingSourceProvider(bootstrap.getConfigurationSourceProvider(), new EnvironmentVariableSubstitutor(false)));
    GuiceBundle<StubEventSinkConfiguration> guiceBundle = defaultBuilder(StubEventSinkConfiguration.class).modules(new StubEventSinkModule()).build();
    bootstrap.addBundle(guiceBundle);
    bootstrap.addBundle(new ServiceStatusBundle());
    bootstrap.addBundle(new MonitoringBundle());
    bootstrap.addBundle(new LoggingBundle());
}
Also used : SubstitutingSourceProvider(io.dropwizard.configuration.SubstitutingSourceProvider) LoggingBundle(uk.gov.ida.bundles.LoggingBundle) ServiceStatusBundle(uk.gov.ida.bundles.ServiceStatusBundle) EnvironmentVariableSubstitutor(io.dropwizard.configuration.EnvironmentVariableSubstitutor) MonitoringBundle(uk.gov.ida.bundles.MonitoringBundle)

Example 2 with EnvironmentVariableSubstitutor

use of io.dropwizard.configuration.EnvironmentVariableSubstitutor in project verify-hub by alphagov.

the class PolicyApplication method initialize.

@Override
public final void initialize(Bootstrap<PolicyConfiguration> bootstrap) {
    // Enable variable substitution with environment variables
    bootstrap.setConfigurationSourceProvider(new SubstitutingSourceProvider(bootstrap.getConfigurationSourceProvider(), new EnvironmentVariableSubstitutor(false)));
    bootstrap.addBundle(new ServiceStatusBundle());
    bootstrap.addBundle(new MonitoringBundle());
    bootstrap.addBundle(new LoggingBundle());
    bootstrap.addBundle(new IdaJsonProcessingExceptionMapperBundle());
    final InfinispanBundle infinispanBundle = new InfinispanBundle();
    // the infinispan cache manager needs to be lazy loaded because it is not initialized at this point.
    bootstrap.addBundle(infinispanBundle);
    guiceBundle = GuiceBundle.defaultBuilder(PolicyConfiguration.class).modules(getPolicyModule(), new EventEmitterModule(), bindInfinispan(infinispanBundle.getInfinispanCacheManagerProvider())).build();
    bootstrap.addBundle(guiceBundle);
}
Also used : SubstitutingSourceProvider(io.dropwizard.configuration.SubstitutingSourceProvider) IdaJsonProcessingExceptionMapperBundle(uk.gov.ida.hub.policy.exception.IdaJsonProcessingExceptionMapperBundle) LoggingBundle(uk.gov.ida.bundles.LoggingBundle) ServiceStatusBundle(uk.gov.ida.bundles.ServiceStatusBundle) EnvironmentVariableSubstitutor(io.dropwizard.configuration.EnvironmentVariableSubstitutor) MonitoringBundle(uk.gov.ida.bundles.MonitoringBundle) EventEmitterModule(uk.gov.ida.eventemitter.EventEmitterModule) InfinispanBundle(uk.gov.ida.shared.dropwizard.infinispan.util.InfinispanBundle)

Example 3 with EnvironmentVariableSubstitutor

use of io.dropwizard.configuration.EnvironmentVariableSubstitutor in project timbuctoo by HuygensING.

the class TimbuctooV4 method initialize.

@Override
public void initialize(Bootstrap<TimbuctooConfiguration> bootstrap) {
    // bundles
    activeMqBundle = new ActiveMQBundle();
    bootstrap.addBundle(activeMqBundle);
    bootstrap.addBundle(new MultiPartBundle());
    bootstrap.addBundle(new AssetsBundle("/static", "/static", "index.html"));
    /*
     * Make it possible to use environment variables in the config.
     * see: http://www.dropwizard.io/0.9.1/docs/manual/core.html#environment-variables
     */
    bootstrap.setConfigurationSourceProvider(new SubstitutingSourceProvider(bootstrap.getConfigurationSourceProvider(), new EnvironmentVariableSubstitutor(true)));
}
Also used : SubstitutingSourceProvider(io.dropwizard.configuration.SubstitutingSourceProvider) MultiPartBundle(io.dropwizard.forms.MultiPartBundle) ActiveMQBundle(com.kjetland.dropwizard.activemq.ActiveMQBundle) EnvironmentVariableSubstitutor(io.dropwizard.configuration.EnvironmentVariableSubstitutor) AssetsBundle(io.dropwizard.assets.AssetsBundle)

Example 4 with EnvironmentVariableSubstitutor

use of io.dropwizard.configuration.EnvironmentVariableSubstitutor in project api-core by ca-cwds.

the class ElasticSearchLiveTestRunner method main.

/**
 * Let 'er rip!
 *
 * @param args command line
 * @throws Exception Exception rises to the top
 */
public static void main(String... args) throws Exception {
    if (args.length < 2) {
        throw new ApiException("Usage: java " + ElasticSearchLiveTestRunner.class.getName() + " <ES config file> <search terms>");
    }
    final String path = args[0];
    final String searchFor = args[1];
    final ConfigurationSourceProvider provider = new SubstitutingSourceProvider(new FileConfigurationSourceProvider(), new EnvironmentVariableSubstitutor(false));
    ElasticsearchConfiguration config;
    try (InputStream iss = provider.open(path)) {
        config = YAML_MAPPER.readValue(iss, ElasticsearchConfiguration.class);
    }
    try (AutoCloseElasticsearchDao autoCloseDao = new AutoCloseElasticsearchDao(elasticsearchClient(config))) {
        ElasticSearchLiveTestRunner job = new ElasticSearchLiveTestRunner(autoCloseDao, searchFor);
        job.run();
    }
}
Also used : SubstitutingSourceProvider(io.dropwizard.configuration.SubstitutingSourceProvider) ConfigurationSourceProvider(io.dropwizard.configuration.ConfigurationSourceProvider) FileConfigurationSourceProvider(io.dropwizard.configuration.FileConfigurationSourceProvider) InputStream(java.io.InputStream) EnvironmentVariableSubstitutor(io.dropwizard.configuration.EnvironmentVariableSubstitutor) ElasticsearchConfiguration(gov.ca.cwds.rest.ElasticsearchConfiguration) ApiException(gov.ca.cwds.rest.api.ApiException) FileConfigurationSourceProvider(io.dropwizard.configuration.FileConfigurationSourceProvider)

Example 5 with EnvironmentVariableSubstitutor

use of io.dropwizard.configuration.EnvironmentVariableSubstitutor in project api-core by ca-cwds.

the class BaseApiApplication method initialize.

@Override
public final void initialize(Bootstrap<T> bootstrap) {
    bootstrap.setConfigurationSourceProvider(new SubstitutingSourceProvider(bootstrap.getConfigurationSourceProvider(), new EnvironmentVariableSubstitutor(false)));
    bootstrap.addBundle(new ViewBundle<T>());
    guiceBundle = GuiceBundle.<T>newBuilder().addModule(applicationModule(bootstrap)).setConfigClass(bootstrap.getApplication().getConfigurationClass()).enableAutoConfig(getClass().getPackage().getName()).build();
    bootstrap.addBundle(guiceBundle);
    bootstrap.addBundle(shiroBundle);
    initializeInternal(bootstrap);
}
Also used : SubstitutingSourceProvider(io.dropwizard.configuration.SubstitutingSourceProvider) EnvironmentVariableSubstitutor(io.dropwizard.configuration.EnvironmentVariableSubstitutor)

Aggregations

EnvironmentVariableSubstitutor (io.dropwizard.configuration.EnvironmentVariableSubstitutor)13 SubstitutingSourceProvider (io.dropwizard.configuration.SubstitutingSourceProvider)13 LoggingBundle (uk.gov.ida.bundles.LoggingBundle)6 MonitoringBundle (uk.gov.ida.bundles.MonitoringBundle)6 ServiceStatusBundle (uk.gov.ida.bundles.ServiceStatusBundle)6 EventEmitterModule (uk.gov.ida.eventemitter.EventEmitterModule)3 AssetsBundle (io.dropwizard.assets.AssetsBundle)2 ResourceConfigurationSourceProvider (io.dropwizard.configuration.ResourceConfigurationSourceProvider)2 SwaggerBundleConfiguration (io.federecio.dropwizard.swagger.SwaggerBundleConfiguration)2 InfinispanBundle (uk.gov.ida.shared.dropwizard.infinispan.util.InfinispanBundle)2 RenderCommand (com.example.helloworld.cli.RenderCommand)1 ActiveMQBundle (com.kjetland.dropwizard.activemq.ActiveMQBundle)1 ElasticsearchConfiguration (gov.ca.cwds.rest.ElasticsearchConfiguration)1 ApiException (gov.ca.cwds.rest.api.ApiException)1 ConfigurationSourceProvider (io.dropwizard.configuration.ConfigurationSourceProvider)1 FileConfigurationSourceProvider (io.dropwizard.configuration.FileConfigurationSourceProvider)1 DataSourceFactory (io.dropwizard.db.DataSourceFactory)1 MultiPartBundle (io.dropwizard.forms.MultiPartBundle)1 InputStream (java.io.InputStream)1 Map (java.util.Map)1