Hi,
I've got a bundle that I'm adding via the initialize method of my
Application.
The bundle needs some configuration passed to its constructor so that it
can be used later on. I'd like to get this configuration from my YAML file;
making use of environment variable substitution if needed. So the call
would be ideally be something like this:-
public void initialize(Bootstrap<MyConfig> bootstrap) {
MyConfig config = <get config>;
bootstrap.addBundle(new MyBundle<MyConfig>(*config*) {
@Override
public MyFactory getMyFactory(MyConfig config) {
return config.getMyFactory();
}
});
}
However, I've not been able to figure out how to access the configuration
object within the bootstrap method. I've taken a look at dropwizard's own
code and from what I can tell, this is the nearest I can find to being able
to automatically grab the config. If that's right, the issue then is how to
grab the namespace with the right path? Is there a way of getting the name
and path of the configuration file specified at runtime?
MyConfig config = parseConfiguration(bootstrap
.getConfigurationFactoryFactory(),
bootstrap.getConfigurationSourceProvider(),
bootstrap.getValidatorFactory().getValidator(),
namespace.getString("file"),
getConfigurationClass(),
bootstrap.getObjectMapper());
I could always pull in the environment variables I need directly but I'd
really like to make use of the config class I've got and so any guidance
would be very appreciated.
thanks
Matt
--
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.