2016/02/07 - Apache Onami has been retired.

For more information, please explore the Attic.

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.google.inject.Guice;
import com.google.inject.Injector;

import com.googlecode.rocoto.configuration.ConfigurationModule;

...

Injector injector = Guice.createInjector( new ConfigurationModule()
{

        @Override
        protected void bindConfigurations()
        {
            bindEnvironmentVariables();
            bindSystemProperties();

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

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

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

    },
    ...
);

Now users can access to configuration parameters through the @com.google.inject.name.Named annotation.

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

com.google.inject.name.Names compatibility

Users can still load properties using the Google Guice Names.