-
-
Notifications
You must be signed in to change notification settings - Fork 212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suport properties in DataBase #124
Comments
Thanks @erickjx . At the moment there is no built-in support for proprierties from Database, but there is a pluggable mechanism to load properties from different sources. See Basically your Loader should be able to accept a custom URI (for instance As example you can have a look how the XMLLoader is implemented. In short, you have to implement the public class DatabaseLoader extends Loader {
public DatabaseLoader(DataSource dataSource) {
this.dataSource = dataSource;
}
public boolean accept(URI uri) {
// this tells owner that this loader is able to parse the given uri
return uri.getScheme().equals("database");
}
public void load(Properties result, URI uri) throws IOException {
// obtain a connection
// make the query
// fill the result object.
}
// you probably don't need to implement this, or just return the urlPrefix.
public String defaultSpecFor(String urlPrefix) {
return urlPrefix;
}
}
// Then from the calling code you need to do:
@Sources("database:mytable")
public class MyConfig extends Config {
//...
}
DataSource myDataSource = ... // get it from jndi or whatever you use.
ConfigFactory.registerLoader(new DatabaseLoader(myDataSource))
MyConfig cfg = ConfigFactory.create(...); I am planning to change this mechanism, sometime in future. Since this doesn't allow the "automatic hot reload" feature (you can still trigger the reload programmatically or via jmx). |
Its possible read from DB, and if not available fall back to properties or url o jar?, i will made a Generic Hibernate Loader |
yes, http://owner.aeonbits.org/docs/loading-strategies/ In particular have a look at the "merge" loading strategy. |
Hi, great work.
It's possible add suport to read properties from DataBase?
The text was updated successfully, but these errors were encountered: