Skip to content

Configure Using The Java API

Sondre Eikanger Kvalø edited this page Aug 13, 2013 · 1 revision

Constretto provides a fluent API to be used in any Java application. Its main interface is ConstrettoConfiguration, that supplies methods to query for values in your configuration. To initialize the ConstrettoConfiguration interface, use the supplied ConstrettoBuilder as shown in the example below:

ConstrettoConfiguration config =
                new ConstrettoBuilder()
                        .createPropertiesStore()
                            .addResource(new DefaultResourceLoader().getResource("classpath:test.properties"))
                            .addResource(new DefaultResourceLoader().getResource("file:test2.properties"))
                        .done()
                        .createIniFileConfigurationStore()
                            .addResource(new DefaultResourceLoader().getResource("classpath:test.ini"))
                        .done()
                        .createObjectConfigurationStore()
                            .addObject(new Object())
                        .done()
                        .createSystemPropertiesStore()
                        .getConfiguration();
Clone this wiki locally