// Iterate through all annotations of the main class and convert them into
// their BootstrapModules
for (final Annotation annot : main.getDeclaredAnnotations()) {
final Class<? extends Annotation> type = annot.annotationType();
LOG.info("Found bootstrap annotation {}", type.getName());
Bootstrap bootstrap = type.getAnnotation(Bootstrap.class);
if (bootstrap != null) {
boolean added = false;
// This is a suite
if (!bootstrap.value().equals(Bootstrap.NullLifecycleInjectorBuilderSuite.class)) {
LOG.info("Adding Suite {}", bootstrap.bootstrap());
suites
.addBinding()
.to(bootstrap.value())
.asEagerSingleton();
added = true;
}
// This is a bootstrap module
if (!bootstrap.bootstrap().equals(Bootstrap.NullBootstrapModule.class)) {
Preconditions.checkState(added==false, bootstrap.annotationType().getName() + " already added as a LifecycleInjectorBuilderSuite");
added = true;
LOG.info("Adding BootstrapModule {}", bootstrap.bootstrap());
bootstrapModules
.addBinding()
.to(bootstrap.bootstrap())
.asEagerSingleton();
// Make this annotation injectable into any plain Module
builder.withAdditionalBootstrapModules(forAnnotation(annot));
}
// This is a plain guice module
if (!bootstrap.module().equals(Bootstrap.NullModule.class)) {
Preconditions.checkState(added==false, bootstrap.annotationType().getName() + " already added as a BootstrapModule");
added = true;
LOG.info("Adding Module {}", bootstrap.bootstrap());
builder.withAdditionalModuleClasses(bootstrap.module());
// Make the annotation injectable into the module
builder.withAdditionalBootstrapModules(forAnnotation(annot));
}
// Makes the annotation injectable into LifecycleInjectorBuilderSuite