Loading Modules
GSPI allows loading com.google.inject.Modules from the SPI 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.nnsoft.guice.gspi.GuiceServiceLoader.* APIs:
import static org.nnsoft.guice.gspi.GuiceServiceLoader.loadModules; import static com.google.inject.Guice.createInjector; import com.google.inject.Injector; ... Injector injector = createInjector( loadModules() );
Eh?!? Just that?!? YES!!! :)