Skip to content

Format java beans

Sondre Eikanger Kvalø edited this page Aug 28, 2013 · 2 revisions

Java Objects used as configuration sources

Constretto are able to use Java objects as configuration sources, and then annotations are used to indicate which tags are used. Also the ConfigurationSource annotation can use an optional basePath attribute, that are prepended to the JavaBean property names found in the class resulting in "somedb.username" in the example below.

Example:

@ConfigurationSource(basePath ="somedb")
public class DefaultDataSourceConfigurer {

    public String getUsername() {
        return "default username";
    }
}

@ConfigurationSource(basePath = "somedb", tag = "production")
public class ProductionDataSourceConfigurer {

    public String getUsername() {
        return "username in production";
    }
}
Clone this wiki locally