Fork me on GitHub

The Configuration module

The com.googlecode.rocoto.configuration.ConfigurationModule is a dependencies-less, lightweight yet powerful Guice module to simplify the task of loading configurations and bind them to the Guice Binder.

With this tool users are now ready to load properties files, creating and configuring the module:


import com.googlecode.rocoto.configuration.ConfigurationModule;


Injector injector = Guice.createInjector( new ConfigurationModule()

        protected void bindConfigurations()

            bindProperties( URI.create( "classpath:/org/nnsoft/guice/rocoto/configuration/" ) );
            bindProperties( "proxy.xml" ).inXMLFormat();

            File parentConf = new File( "src/test/data/org/nnsoft" );
            bindProperties( new File( parentConf, "" ) );
            bindProperties( new File( parentConf, "guice/" ) );
            bindProperties( new File( parentConf, "guice/rocoto/configuration/memcached.xml" ) ).inXMLFormat();

            bindProperty( "JDBC.url").toValue( "jdbc:mysql://${|localhost}:${JDBC.port}/${JDBC.schema}" );


Now users can access to configuration parameters through the annotation.

NOTE Environment Variables will be referred with the env. prefix. compatibility

Users can still load properties using the Google Guice Names.