Search in sources :

Example 1 with ModuleDef

use of com.google.gwt.dev.cfg.ModuleDef in project gwt-cs by iSergio.

the class CesiumScriptInjector method forceScriptLoad.

private boolean forceScriptLoad(TreeLogger logger, String moduleName, Float gwtVersion) {
    try {
        ModuleDef module;
        Method getModuleDef;
        if (gwtVersion < 2.6f) {
            getModuleDef = ModuleDefLoader.class.getDeclaredMethod("loadFromClassPath", new Class[] { TreeLogger.class, String.class });
            module = (ModuleDef) getModuleDef.invoke(null, logger, moduleName);
        } else if (gwtVersion < 2.8f) {
            Class compilerContextClass = Class.forName("com.google.gwt.dev.CompilerContext");
            Object context = compilerContextClass.getDeclaredConstructor().newInstance();
            getModuleDef = ModuleDefLoader.class.getDeclaredMethod("loadFromClassPath", new Class[] { TreeLogger.class, compilerContextClass, String.class });
            module = (ModuleDef) getModuleDef.invoke(null, logger, compilerContextClass.cast(context), moduleName);
        } else {
            getModuleDef = ModuleDefLoader.class.getDeclaredMethod("loadFromClassPath", new Class[] { TreeLogger.class, String.class, boolean.class });
            module = (ModuleDef) getModuleDef.invoke(null, logger, moduleName, false);
        }
        if (module != null)
            return CrossSiteIframeLinker.class.equals(module.getActivePrimaryLinker());
        logger.log(TreeLogger.WARN, "Can't find module reference - not injecting scripts.");
    } catch (Throwable t) {
        logger.log(TreeLogger.ERROR, "Encountered an exception while trying to resolve the ModuleDef for " + moduleName, t);
    }
    return false;
}
Also used : CrossSiteIframeLinker(com.google.gwt.core.linker.CrossSiteIframeLinker) TreeLogger(com.google.gwt.core.ext.TreeLogger) ModuleDef(com.google.gwt.dev.cfg.ModuleDef) Method(java.lang.reflect.Method) ModuleDefLoader(com.google.gwt.dev.cfg.ModuleDefLoader)

Aggregations

TreeLogger (com.google.gwt.core.ext.TreeLogger)1 CrossSiteIframeLinker (com.google.gwt.core.linker.CrossSiteIframeLinker)1 ModuleDef (com.google.gwt.dev.cfg.ModuleDef)1 ModuleDefLoader (com.google.gwt.dev.cfg.ModuleDefLoader)1 Method (java.lang.reflect.Method)1