Similar to my answer here, you implement the ConfigurationSourceProvider
interface the way you wish to implement and configure your dropwizard application to use it on your Application class by:
@Override
public void initialize(Bootstrap<MyConfiguration> bootstrap){
bootstrap.setConfigurationSourceProvider(new MyDatabaseConfigurationSourceProvider());
}
By default, the InputStream
you return is read as YAML and mapped to the Configuration
object. The default implementation
You can override this via
bootstrap.setConfigurationFactoryFactory(new MyDatabaseConfigurationFactoryFactory<>());
Then you have your FactoryFactory
:) that returns a Factory
which reads the InputStream
and returns your Configuration
.
public T build(ConfigurationSourceProvider provider, String path {
Decode.onWhateverFormatYouWish(provider.open(path));
}