Can you provide more details at a higher level of what you are trying to achieve?
On Tue, Apr 2, 2019 at 6:52 AM Vaibhav Somani <[email protected]> wrote: > I am working on dropwizard project where I want to set the a different > configuration source provider based on the if a config value is enabled or > not. > > Since the configuration object isn't accessible in initialize, I created > a global bootstrap variable. Though I am still unable to update the config > values. > > Any help or guidance on how can this be resolved? > > private Bootstrap<MyConfiguration> bootstrap; > @Overridepublic void initialize(final Bootstrap<MyConfiguration> bootstrap) { > super.initialize(bootstrap); > this.bootstrap = bootstrap;} > > @Overridepublic void run(final MyConfiguration configuration, > final Environment environment) { > > this.bootstrap.setConfigurationFactoryFactory( > new ImportConfigurationFactoryFactory<>()); > > if(configuration.isEnabled()) { > this.bootstrap.setConfigurationSourceProvider( > new SubstitutingSourceProvider( > this.bootstrap.getConfigurationSourceProvider(), > new StrSubstitutor(new ConfigSwitcher()))); > } else { > this.bootstrap.setConfigurationSourceProvider( > new SubstitutingSourceProvider( > this.bootstrap.getConfigurationSourceProvider(), > new EnvironmentVariableSubstitutor(false))); > }} > > -- > You received this message because you are subscribed to the Google Groups > "dropwizard-user" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "dropwizard-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
