}
}
// Search for Errai extensions.
ConfigUtil.visitAllTargets(configRootTargets, new ConfigVisitor() {
public void visit(Class<?> loadClass) {
if (ErraiConfigExtension.class.isAssignableFrom(loadClass)
&& loadClass.isAnnotationPresent(ExtensionComponent.class)) {
// We have an annotated ErraiConfigExtension. So let's configure it.
final Class<? extends ErraiConfigExtension> clazz =
loadClass.asSubclass(ErraiConfigExtension.class);
try {
final Runnable create = new Runnable() {
public void run() {
AbstractModule module = new AbstractModule()
{
@Override
protected void configure()
{
bind(ErraiConfigExtension.class).to(clazz);
bind(ErraiServiceConfigurator.class).toInstance(configInst);
bind(MessageBus.class).toInstance(bus);
// Add any extension bindings.
for (Map.Entry<Class, Provider> entry : extensionBindings.entrySet())
{
bind(entry.getKey()).toProvider(entry.getValue());
}
}
};
Guice.createInjector(module)
.getInstance(ErraiConfigExtension.class)
.configure(extensionBindings, resourceProviders);
}
};
try {
create.run();
}
catch (CreationException e) {
deferred.add(create);
}
}
catch (Throwable e) {
e.printStackTrace();
throw new RuntimeException("could not initialize extension: " + loadClass.getName(), e);
}
}
}
});
ConfigUtil.visitAllTargets(configRootTargets,
new ConfigVisitor() {
public void visit(final Class<?> loadClass) {
if (Module.class.isAssignableFrom(loadClass)) {
final Class<? extends Module> clazz = loadClass.asSubclass(Module.class);
if (clazz.isAnnotationPresent(LoadModule.class)) {