Search in sources :

Example 1 with GinModules

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;
}
Also used : ClassSourceFileComposerFactory(com.google.gwt.user.rebind.ClassSourceFileComposerFactory) Ginjector(com.google.gwt.inject.client.Ginjector) GinModules(com.google.gwt.inject.client.GinModules) SourceWriter(com.google.gwt.user.rebind.SourceWriter)

Example 2 with GinModules

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;
}
Also used : GinModules(com.google.gwt.inject.client.GinModules) GinModule(com.google.gwt.inject.client.GinModule)

Aggregations

GinModules (com.google.gwt.inject.client.GinModules)2 GinModule (com.google.gwt.inject.client.GinModule)1 Ginjector (com.google.gwt.inject.client.Ginjector)1 ClassSourceFileComposerFactory (com.google.gwt.user.rebind.ClassSourceFileComposerFactory)1 SourceWriter (com.google.gwt.user.rebind.SourceWriter)1