List of usage examples for com.google.gwt.core.ext TreeLogger DEBUG
Type DEBUG
To view the source code for com.google.gwt.core.ext TreeLogger DEBUG.
Click Source Link
From source file:cc.alcina.framework.gwt.appcache.linker.AppCacheManifestLinker.java
License:Apache License
private EmittedArtifact emitManifest(TreeLogger logger, LinkerContext context, EmittedArtifact userManifest, SortedSet<EmittedArtifact> artifacts) throws UnableToCompleteException { logger = logger.branch(TreeLogger.DEBUG, "Creating manifest artifact", null); // Try getting a user-defined manifest StringBuffer out = readManifestTemplate(logger, userManifest); // Use the template in the MD5 computation digester.update(Util.getBytes(out.toString())); // Look for @filter expressions in the manifest template Set<Pattern> filters = extractFilters(logger, out); // Append the builtin filters for (String pattern : BUILTIN_FILTERS) { filters.add(Pattern.compile(pattern)); }//from w ww .j a v a 2s. com filters.add(Pattern.compile(".*?(^|/)\\.[^/]+"));// ignore .-prefixed // files (e.g. // .cvsignore) // Generate the manifest entries String entries = generateEntries(logger, context, filters, artifacts); replaceAll(out, "__VERSION__", StringUtils.toHexString(digester.digest())); replaceAll(out, "__ENTRIES__", entries.toString()); /* * NB: It's tempting to use LinkerContext.optimizeJavaScript here, but * the JSON standard requires that the keys in the object literal will * be enclosed in double-quotes. In our optimized JS form, the * double-quotes would normally be removed. */ return emitBytes(logger, Util.getBytes(out.toString()), "appcache.nocache.manifest"); }
From source file:cc.alcina.framework.gwt.appcache.linker.AppCacheManifestLinker.java
License:Apache License
/** * Find all instances of the filter pragma in the manifest template and * return compiled regular expression Pattern objects. *//*from ww w.j a va2 s. c om*/ private Set<Pattern> extractFilters(TreeLogger logger, CharSequence source) throws UnableToCompleteException { logger.branch(TreeLogger.DEBUG, "Finding @filter expressions", null); boolean filterError = false; Matcher filterMatcher = FILTER_PATTERN.matcher(source); Set<Pattern> filters = new HashSet<Pattern>(); while (filterMatcher.find()) { String pattern = filterMatcher.group(1); try { filters.add(Pattern.compile(pattern)); } catch (PatternSyntaxException e) { logger.log(TreeLogger.ERROR, "Could not compile filter pattern at character offset " + filterMatcher.start(), e); filterError = true; } } if (filterError) { throw new UnableToCompleteException(); } return filters; }
From source file:cc.alcina.framework.gwt.appcache.linker.AppCacheManifestLinker.java
License:Apache License
/** * Generate a string containing object literals for each manifest entry. *///from ww w . j a v a 2 s. co m private String generateEntries(TreeLogger logger, LinkerContext context, Set<Pattern> filters, SortedSet<EmittedArtifact> artifacts) throws UnableToCompleteException { logger = logger.branch(TreeLogger.DEBUG, "Generating manifest contents", null); StringBuffer entries = new StringBuffer(); paths: for (EmittedArtifact artifact : artifacts) { if (artifact.getVisibility() != Visibility.Public) { // These artifacts won't be in the module output directory continue; } String path = artifact.getPartialPath(); for (Pattern p : filters) { if (p.matcher(path).matches()) { logger.log(TreeLogger.DEBUG, "Filtering resource " + path, null); continue paths; } } entries.append("/" + context.getModuleName() + "/" + path); entries.append("\n"); // Read the artifact into the digester InputStream in = artifact.getContents(logger); byte[] buffer = new byte[4096]; int read; try { while ((read = in.read(buffer)) != -1) { digester.update(buffer, 0, read); } } catch (IOException e) { logger.log(TreeLogger.ERROR, "Unable to read artifact " + artifact.getPartialPath(), e); throw new UnableToCompleteException(); } } // Add an alias for Module.nocache.js?compiled to support hosted-mode entries.append("/" + context.getModuleName() + "/" + context.getModuleName() + ".nocache.js?compiled\n"); entries.append("/" + context.getModuleName() + "/" + context.getModuleName() + ".nocache.js\n"); return entries.toString(); }
From source file:cc.alcina.framework.gwt.appcache.linker.AppCacheManifestLinker.java
License:Apache License
/** * Load the contents of the manifest template from a file named * {@value #APPCACHE_MANIFEST} in the root of the public path. Failing that, * use the built-in template.//from ww w .jav a2s . c o m */ private StringBuffer readManifestTemplate(TreeLogger logger, EmittedArtifact userManifest) throws UnableToCompleteException { logger = logger.branch(TreeLogger.DEBUG, "Reading manifest template", null); InputStream in; // See if we have a user-provided manifest to work with if (userManifest != null) { logger.log(TreeLogger.DEBUG, "Reading user-provided manifest", null); in = userManifest.getContents(logger); if (in == null) { logger.log(TreeLogger.ERROR, "Unable to read contents of user manifest", null); throw new UnableToCompleteException(); } } else { // Fall back to the built-in manifest String packagePath = getClass().getPackage().getName().replace('.', '/'); String resourceName = packagePath + "/" + APPCACHE_MANIFEST; in = getClass().getClassLoader().getResourceAsStream(resourceName); if (in == null) { logger.log(TreeLogger.ERROR, "Could not load built-in manifest from " + resourceName, null); throw new UnableToCompleteException(); } } StringBuffer out = new StringBuffer(); BufferedReader reader = new BufferedReader(new InputStreamReader(in)); try { for (String line = reader.readLine(); line != null; line = reader.readLine()) { out.append(line).append("\n"); } } catch (IOException e) { logger.log(TreeLogger.ERROR, "Unable to read manifest template", e); throw new UnableToCompleteException(); } return out; }
From source file:com.arcbees.chosen.rebind.Logger.java
License:Apache License
public void debug(String message, Object... params) { internalLog(TreeLogger.DEBUG, String.format(message, params)); }
From source file:com.bedatadriven.rebar.appcache.linker.AppCacheIFrameLinker.java
License:Apache License
private EmittedArtifact doEmitManifest(TreeLogger logger, PermutationContext context, ManifestWriter writer) throws UnableToCompleteException { logger = logger.branch(TreeLogger.DEBUG, "Generating " + writer.getSuffix() + " contents", null); StringBuffer out = readManifestTemplate(logger, context, writer.getSuffix()); // Generate the manifest entries appendEntries(logger, context, writer); // use the current time as the version number replaceAll(out, "__NAME__", context.getModuleName()); replaceAll(out, "__VERSION__", context.getStrongName()); replaceAll(out, "__ENTRIES__", writer.getEntries()); /*/* w w w .j a v a2 s.c o m*/ * NB: It's tempting to use LinkerContext.optimizeJavaScript here, but the * JSON standard requires that the keys in the object literal will be * enclosed in double-quotes. In our optimized JS form, the double-quotes * would normally be removed. */ return emitBytes(logger, Util.getBytes(out.toString()), context.getStrongName() + "." + writer.getSuffix()); }
From source file:com.bedatadriven.rebar.appcache.linker.AppCacheIFrameLinker.java
License:Apache License
/** * Generate a string containing object literals for each manifest entry. *//*from w w w. j a v a 2 s .c om*/ private void appendEntries(TreeLogger logger, PermutationContext context, ManifestWriter writer) throws UnableToCompleteException { logger = logger.branch(TreeLogger.DEBUG, "Generating manifest entries", null); // add the bootstrap script (provided by the server) writer.appendEntry(logger, context.getModuleName() + ".nocache.js"); for (EmittedArtifact artifact : context.getToCache()) { if (artifact.getVisibility() == Visibility.Public) { logger.log(TreeLogger.DEBUG, "adding to manifest:" + artifact.getPartialPath() + " of class " + artifact.getClass().getName() + " and visibility " + artifact.getVisibility()); if (artifact.getPartialPath().endsWith(".gwt.rpc")) { // only used by the server continue; } String path = artifact.getPartialPath(); // certain paths on the Windows platform (notably deferredjs stuff) // show up with backslahes, which throws an illegal escape sequence // error when the json is parsed. path = path.replace('\\', '/'); logger.log(TreeLogger.DEBUG, "adding: " + path); writer.appendEntry(logger, path); } else { logger.log(TreeLogger.DEBUG, "excluding " + artifact.getVisibility() + ": " + artifact.getPartialPath()); } } }
From source file:com.cgxlib.xq.rebind.SelectorGeneratorBase.java
License:Apache License
protected void debug(String s) { // System.err.println(s); treeLogger.log(TreeLogger.DEBUG, s, null); }
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.//from w w w .j ava 2s . c om * * @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; }
From source file:com.google.code.gwt.database.rebind.DataServiceGenerator.java
License:Apache License
@Override public String generate(TreeLogger logger, GeneratorContext context, String requestedClass) throws UnableToCompleteException { // Assertions: TypeOracle typeOracle = context.getTypeOracle(); assert (typeOracle != null); JClassType dataService = typeOracle.findType(requestedClass); if (dataService == null) { logger.log(TreeLogger.ERROR, "Unable to find metadata for type '" + requestedClass + "'", null); throw new UnableToCompleteException(); }//from w w w .j a va2s . c o m if (dataService.isInterface() == null) { logger.log(TreeLogger.ERROR, dataService.getQualifiedSourceName() + " is not an interface", null); throw new UnableToCompleteException(); } Connection conAnnotation = getAnnotation(dataService, Connection.class); if (conAnnotation == null) { logger.log(TreeLogger.ERROR, "DataService interface (or the interface it is implementing) must be annotated" + " with @Connection to define database connection details"); throw new UnableToCompleteException(); } // All basic assertions checked: Generate the code! SqlProxyCreator creator = new SqlProxyCreator( logger.branch(TreeLogger.DEBUG, "Generating proxy methods to database '" + conAnnotation.name() + "'..."), context, dataService); return creator.create(); }