use of com.google.gwt.inject.client.GinModules in project google-gin by gwtplus.
the class FrameworkGenerator method createGinjector.
private String createGinjector(TreeLogger logger, GeneratorContext context, String packageName, String requestedName, String newClassName, String moduleName) {
String ginjectorName = requestedName + "Ginjector";
ClassSourceFileComposerFactory ginjectorFactory = new ClassSourceFileComposerFactory(packageName, ginjectorName);
ginjectorFactory.makeInterface();
ginjectorFactory.addImplementedInterface(Ginjector.class.getCanonicalName());
ginjectorFactory.addImport(GinModules.class.getCanonicalName());
ginjectorFactory.addAnnotationDeclaration("@GinModules(" + moduleName + ".class)");
SourceWriter ginjectorWriter = ginjectorFactory.createSourceWriter(context, context.tryCreate(logger, packageName, ginjectorName));
ginjectorWriter.println("void injectMembers(" + newClassName + " obj);");
ginjectorWriter.commit(logger);
return ginjectorName;
}
use of com.google.gwt.inject.client.GinModules in project gwt-test-utils by gwt-test-utils.
the class GInjectorCreateHandler method readGinModules.
private Class<? extends GinModule>[] readGinModules(Class<? extends Ginjector> classLiteral) {
LOGGER.debug("inspecting classLiteral " + classLiteral);
GinModules annotation = classLiteral.getAnnotation(GinModules.class);
if (annotation == null) {
// Throw an exception if we don't find this specific annotation.
throw new IllegalArgumentException(classLiteral.getName() + " doesn't have any @GinModules annotation present");
}
Class<? extends GinModule>[] ginModules = annotation.value();
if (ginModules.length == 0) {
// there are no GinModules present in the Ginjector.
throw new IllegalArgumentException(classLiteral.getName() + " doesn't have any GinModules. " + "Runtime should not work.");
}
LOGGER.debug("discovered modules " + annotation);
return ginModules;
}
Aggregations