Example usage for com.google.gwt.dev.cfg ModuleDef getRules

List of usage examples for com.google.gwt.dev.cfg ModuleDef getRules

Introduction

In this page you can find the example usage for com.google.gwt.dev.cfg ModuleDef getRules.

Prototype

public synchronized Rules getRules() 

Source Link

Document

Gets a reference to the internal rules for this module def.

Usage

From source file:com.google.code.gwt.appcache.rebind.ApplicationCacheNetworkSectionGenerator.java

License:Apache License

/**
 * Invokes the deferred binding rule(s) in the specified module to the
 * specified typeName.//w  w w. jav a 2 s  .c  o m
 * 
 * @param module the module (which is already inherited!) to use as 'parent'
 *          module
 * @param logger
 * @param context
 * @param typeName the name of the type to rebind
 * @throws UnableToCompleteException if the module can't provide a substitute
 * @return the rebound typeName, or <code>null</code> if no binding took place
 */
private String rebindTypeByInheritedModule(String module, TreeLogger logger, GeneratorContext context,
        String typeName) throws UnableToCompleteException {
    ModuleDef rpcModule = ModuleDefLoader.loadFromClassPath(logger, module);
    Iterator<Rule> iter = rpcModule.getRules().iterator();
    while (iter.hasNext()) {
        Rule r = iter.next();
        if (r.isApplicable(logger, context, typeName)) {
            logger.log(TreeLogger.DEBUG, "The inherited module " + module + " found a rebinder for type "
                    + typeName + " by rule " + r);
            return r.realize(logger, context, typeName);
        }
    }
    logger.log(TreeLogger.WARN, "The inherit module rebinder did not rebind anything for type " + typeName
            + " in inherited module " + module);
    return null;
}