I would do it like this!
I would create ParentModul
which would scan a predefined folder for vendors configs and install a Private module
for each vendor config found. Private module encapsulate binding from other modules so, you can bind your properties from config as constants
like @Named("vendor_name") String vendorName
.
Look at this presentation, it could give you better explanation how to use private module property. There is also a github example. http://slid.es/milanbaran/dec
There are some snippets:
Parent Module:
protected void loadVendorModules(String config) {
File configDir = new File(config);
if(!configDir.exists()) {
addError("Configuration directory [%s] doesn't exist. Also, it should contain broker definition files. [broker*.yml]",config);
}
if(!configDir.isDirectory()) {
addError("The `dir.config` parameter is supposed to be a directory. Actually it is not %s",config);
}
broker_files = new File(config).listFiles(new PatternFilenameFilter(FILE_PATTERN));
if(broker_files==null || broker_files.length==0) {
addError("Configuration directory [%s] doesn't contain any broker definition files, please add at least one to start.",config);
}
for(File f : broker_files) {
install(new VendorPrivateModule<T>(f.getAbsolutePath()));
}
return;
}
Vendor Private Module:
protected void configure() {
....
if(config.getConfig()!=null) {
for(String name : config.getConfig().keySet()) {
String value = config.getConfig().get(name);
if(value!=null) {
bind(Key.get(String.class, Names.named(name)))
.toInstance(value);
} else {
bind(Key.get(String.class, Names.named(name)))
.toProvider(Providers.of((String) null));
}
}
}
...