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

For more information, please explore the Attic.

Loading Modules

com.google.inject.Modules can be now load applying the SPI pattern in an easy way: define first which Modules you intend to load in the META-INF/services/com.google.inject.Module file(s):

# created by Jack Bauer in less than 24h

com.acme.FooModule
com.acme.BarModule
com.acme.FooTestCase$AcmeModule   # EOL comment

# comments and blank lines supported


#

then, load modules invoking org.apache.onami.spi.GuiceServiceLoader.* APIs:

import static org.apache.onami.spi.GuiceServiceLoader.loadModules;
import static com.google.inject.Guice.createInjector;

import com.google.inject.Injector;

...

Injector injector = createInjector( loadModules() );

Eh?!? Just that?!? YES!!! :)

Loading modules from SystemProperties

Alternatively, SPIs can be specified via Java System properties:

java -Dcom.google.inject.Module=com.acme.FooModule,com.acme.BarModule,com.acme.FooTestCase$AcmeModule

Where , is the separator character between Providers.

Note

If SPIs will be found in Java System properties, META-INF/services/com.google.inject.Module file(s) will be ignored

Apache Maven Users

Just add the dependency below and let Maven do the rest:

<dependency>
  <groupId>org.apache.onami.spi</groupId>
  <artifactId>org.apache.onami.spi.modules</artifactId>
  <version>1.0.1-SNAPSHOT</version>
  <scope>compile</scope>
</dependency>