Example usage for com.google.gwt.core.ext TreeLogger INFO

List of usage examples for com.google.gwt.core.ext TreeLogger INFO

Introduction

In this page you can find the example usage for com.google.gwt.core.ext TreeLogger INFO.

Prototype

Type INFO

To view the source code for com.google.gwt.core.ext TreeLogger INFO.

Click Source Link

Document

Logs information.

Usage

From source file:com.ait.ext4j.rebind.TemplateGenerator.java

License:Apache License

/**
 * Given a TemplateResource interface, return the path to its .html file,
 * suitable for any classloader to find it as a resource. If the .html does
 * not exist or is empty see if the template was declared inline. If no
 * content is found we throw an exception.
 *///w w w .jav a 2  s. com
private String getTemplateContent(GeneratorContext context, TreeLogger logger, JClassType interfaceType)
        throws UnableToCompleteException {
    String templateHtmlFile = null;

    TemplateResource annotation = interfaceType.getAnnotation(TemplateResource.class);
    if (annotation == null) {
        // if the interface is defined as a nested class, use the name of
        // the
        // enclosing type
        if (interfaceType.getEnclosingType() != null) {
            interfaceType = interfaceType.getEnclosingType();
        }
        templateHtmlFile = slashify(interfaceType.getQualifiedBinaryName()) + TEMPLATE_SUFFIX;
        logger.log(TreeLogger.INFO, "Template : " + templateHtmlFile);

        InputStream stream = getTemplateResource(context, logger, templateHtmlFile);
        if (stream == null) {
            logger.log(Type.ERROR, "No data could be loaded - no data at path "
                    + interfaceType.getQualifiedBinaryName() + TEMPLATE_SUFFIX);
            throw new UnableToCompleteException();
        }
        return sanitize(Util.readStreamAsString(stream));

    } else {
        // first we look at the HTML File
        templateHtmlFile = annotation.source();

        if (templateHtmlFile.length() > 0) {

            if (!templateHtmlFile.endsWith(TEMPLATE_SUFFIX)) {
                logger.log(TreeLogger.ERROR, "Template file name must end with " + TEMPLATE_SUFFIX);
                throw new UnableToCompleteException();
            }

            if (annotation.value().length() != 0) {
                logger.log(Type.WARN, "Found both source file and inline template, using source file");
            }

            templateHtmlFile = slashify(interfaceType.getPackage().getName()) + "/" + templateHtmlFile;
            InputStream stream = getTemplateResource(context, logger, templateHtmlFile);
            return sanitize(Util.readStreamAsString(stream));

        } else if (annotation.value().length() > 0) {
            return annotation.value();
        } else {
            logger.log(Type.ERROR,
                    "Template annotation found with no contents, cannot generate method , this may cause other failures.");
        }

    }
    return null;
}

From source file:com.arcbees.chosen.rebind.Logger.java

License:Apache License

public void info(String message, Object... params) {
    internalLog(TreeLogger.INFO, String.format(message, params));
}

From source file:com.arondor.common.reflection.noreflect.gwtgenerator.GWTNoReflectRegistrarGenerator.java

License:Apache License

@Override
public String generate(TreeLogger logger, GeneratorContext context, String typeName)
        throws UnableToCompleteException {
    LOGGER.finest("Generating for: " + typeName);

    String packageName = getPackageName();
    String className = getClassName();
    String completeName = packageName + "." + className;

    PrintWriter src = context.tryCreate(logger, packageName, className);

    if (src == null) {
        LOGGER.finest("Already generated for : " + completeName);
        return completeName;
    }/*from ww  w.  j av a2 s .  c  o m*/

    Collection<AccessibleClass> accessibleClasses = getAccessibleClasses();

    NoReflectRegistrarGenerator noReflect = new NoReflectRegistrarGenerator();
    noReflect.setClassName(className);
    noReflect.setPackageName(packageName);

    JavaAccessibleClassParser accessibleClassParser = new JavaAccessibleClassParser();
    accessibleClassParser.setTryInstantiateClassForDefaultValue(false);
    noReflect.setAccessibleClassParser(accessibleClassParser);

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PrintStream printStream = new PrintStream(baos);

    noReflect.generate(printStream, accessibleClasses);

    printStream.close();

    String srcCode = new String(baos.toByteArray());

    LOGGER.info("Generated : " + srcCode.length() + " bytes for " + completeName);

    src.append(srcCode);

    context.commit(logger, src);

    return completeName;
}

From source file:com.bcdlog.SimpleAppCacheLinker.java

License:Apache License

public ArtifactSet link(TreeLogger logger, LinkerContext context, ArtifactSet artifacts, boolean onePermutation)
        throws UnableToCompleteException {

    ArtifactSet toReturn = new ArtifactSet(artifacts);

    if (onePermutation) {
        return toReturn;
    }//from   w  ww  .  j  av  a  2  s  .  c o m

    if (toReturn.find(SelectionInformation.class).isEmpty()) {
        logger.log(TreeLogger.INFO, "DevMode warning: Clobbering " + MANIFEST + " to allow debugging. "
                + "Recompile before deploying your app!");
        artifacts = null;
    }

    // Create the general cache-manifest resource for the landing page:
    toReturn.add(emitLandingPageCacheManifest(context, logger, artifacts));
    return toReturn;
}

From source file:com.bcdlog.SimpleAppCacheLinker.java

License:Apache License

/**
 * Creates the cache-manifest resource specific for the landing page.
 * /*from ww  w.j  a  va  2 s  .co  m*/
 * @param context
 *            the linker environment
 * @param logger
 *            the tree logger to record to
 * @param artifacts
 *            {@code null} to generate an empty cache manifest
 */
private Artifact<?> emitLandingPageCacheManifest(LinkerContext context, TreeLogger logger,
        ArtifactSet artifacts) throws UnableToCompleteException {
    StringBuilder publicSourcesSb = new StringBuilder();
    StringBuilder staticResoucesSb = new StringBuilder();

    if (artifacts != null) {
        // Iterate over all emitted artifacts, and collect all cacheable
        // artifacts
        for (@SuppressWarnings("rawtypes")
        Artifact artifact : artifacts) {
            if (artifact instanceof EmittedArtifact) {
                EmittedArtifact ea = (EmittedArtifact) artifact;
                String pathName = ea.getPartialPath();
                if (pathName.endsWith("symbolMap") || pathName.endsWith(".xml.gz")
                        || pathName.endsWith("rpc.log") || pathName.endsWith("gwt.rpc")
                        || pathName.endsWith("manifest.txt") || pathName.startsWith("rpcPolicyManifest")) {
                    // skip these resources
                } else {
                    publicSourcesSb.append(pathName + "\n");
                }
            }
        }

        String[] cacheExtraFiles = getCacheExtraFiles();
        for (int i = 0; i < cacheExtraFiles.length; i++) {
            staticResoucesSb.append(cacheExtraFiles[i]);
            staticResoucesSb.append("\n");
        }
    }

    // build cache list
    StringBuilder sb = new StringBuilder();
    sb.append("CACHE MANIFEST\n");
    sb.append("# Unique id #" + (new Date()).getTime() + "." + Math.random() + "\n");
    // we have to generate this unique id because the resources can change
    // but
    // the hashed cache.html files can remain the same.
    sb.append("# Note: must change this every time for cache to invalidate\n");
    sb.append("\n");
    sb.append("CACHE:\n");
    sb.append("# Static app files\n");
    sb.append(staticResoucesSb.toString());
    sb.append("\n# Generated app files\n");
    sb.append(publicSourcesSb.toString());
    sb.append("\n\n");
    sb.append("# All other resources require the user to be online.\n");
    sb.append("NETWORK:\n");
    sb.append("*\n");

    logger.log(TreeLogger.INFO, "Be sure your landing page's <html> tag declares a manifest:"
            + " <html manifest=" + context.getModuleFunctionName() + "/" + MANIFEST + "\">");

    // Create the manifest as a new artifact and return it:
    return emitString(logger, sb.toString(), MANIFEST);
}

From source file:com.cgxlib.xq.rebind.JsniBundleGenerator.java

License:Apache License

/**
 * Get the content of a javascript source. It supports remote sources hosted in CDN's.
 *//*from ww  w .j  a v  a 2  s .  c om*/
private String getContent(TreeLogger logger, String path, String src) throws UnableToCompleteException {
    HttpURLConnection connection = null;
    InputStream in = null;
    try {
        if (!src.matches("(?i)https?://.*")) {
            String file = path + "/" + src;
            logger.log(TreeLogger.INFO,
                    getClass().getSimpleName() + " - importing external javascript: " + file);

            in = this.getClass().getClassLoader().getResourceAsStream(file);
            if (in == null) {
                logger.log(TreeLogger.ERROR, "Unable to read javascript file: " + file);
            }
        } else {
            logger.log(TreeLogger.INFO,
                    getClass().getSimpleName() + " - downloading external javascript: " + src);
            URL url = new URL(src);
            connection = (HttpURLConnection) url.openConnection();
            connection.setRequestProperty("Accept-Encoding", "gzip, deflate");
            connection.setRequestProperty("Host", url.getHost());
            connection.setConnectTimeout(3000);
            connection.setReadTimeout(3000);

            int status = connection.getResponseCode();
            if (status != HttpURLConnection.HTTP_OK) {
                logger.log(TreeLogger.ERROR, "Server Error: " + status + " " + connection.getResponseMessage());
                throw new UnableToCompleteException();
            }

            String encoding = connection.getContentEncoding();
            in = connection.getInputStream();
            if ("gzip".equalsIgnoreCase(encoding)) {
                in = new GZIPInputStream(in);
            } else if ("deflate".equalsIgnoreCase(encoding)) {
                in = new InflaterInputStream(in);
            }
        }

        return inputStreamToString(in);
    } catch (IOException e) {
        logger.log(TreeLogger.ERROR, "Error: " + e.getMessage());
        throw new UnableToCompleteException();
    } finally {
        if (connection != null) {
            connection.disconnect();
        }
    }
}

From source file:com.goodow.web.dev.rebind.BaseAppCacheLinker.java

License:Apache License

@Override
public ArtifactSet link(final TreeLogger logger, final LinkerContext context, ArtifactSet artifacts,
        final boolean onePermutation) throws UnableToCompleteException {

    ArtifactSet toReturn = new ArtifactSet(artifacts);

    if (onePermutation) {
        return toReturn;
    }/*www  .j  a  v  a2 s .  c  o  m*/

    if (toReturn.find(SelectionInformation.class).isEmpty()) {
        logger.log(TreeLogger.INFO, "DevMode warning: Clobbering " + MANIFEST + " to allow debugging. "
                + "Recompile before deploying your app!");
        artifacts = null;
    }

    // Create the general cache-manifest resource for the landing page:
    toReturn.add(emitLandingPageCacheManifest(context, logger, artifacts));
    return toReturn;
}

From source file:com.goodow.web.dev.rebind.BaseAppCacheLinker.java

License:Apache License

/**
 * Creates the cache-manifest resource specific for the landing page.
 * /*from ww w.  ja  v  a  2s.  c  o m*/
 * @param context the linker environment
 * @param logger the tree logger to record to
 * @param artifacts {@code null} to generate an empty cache manifest
 */
private Artifact<?> emitLandingPageCacheManifest(final LinkerContext context, final TreeLogger logger,
        final ArtifactSet artifacts) throws UnableToCompleteException {
    StringBuilder publicSourcesSb = new StringBuilder();
    StringBuilder staticResoucesSb = new StringBuilder();

    if (artifacts != null) {
        // Iterate over all emitted artifacts, and collect all cacheable artifacts
        for (@SuppressWarnings("rawtypes")
        Artifact artifact : artifacts) {
            if (artifact instanceof EmittedArtifact) {
                EmittedArtifact ea = (EmittedArtifact) artifact;
                String pathName = ea.getPartialPath();
                if (pathName.endsWith("symbolMap") || pathName.endsWith(".xml.gz")
                        || pathName.endsWith("rpc.log") || pathName.endsWith("gwt.rpc")
                        || pathName.endsWith("manifest.txt") || pathName.endsWith(".cssmap")
                        || pathName.startsWith("rpcPolicyManifest") || pathName.startsWith("soycReport")) {
                    // skip these resources
                } else {
                    publicSourcesSb.append(pathName + "\n");
                }
            }
        }

        String[] cacheExtraFiles = getCacheExtraFiles();
        for (int i = 0; i < cacheExtraFiles.length; i++) {
            staticResoucesSb.append(cacheExtraFiles[i]);
            staticResoucesSb.append("\n");
        }
    }

    // build cache list
    StringBuilder sb = new StringBuilder();
    sb.append("CACHE MANIFEST\n");
    sb.append("# Unique id #" + (new Date()).getTime() + "." + Math.random() + "\n");
    // we have to generate this unique id because the resources can change but
    // the hashed cache.html files can remain the same.
    sb.append("# Note: must change this every time for cache to invalidate\n");
    sb.append("\n");
    sb.append("CACHE:\n");
    sb.append("# Static app files\n");
    sb.append(staticResoucesSb.toString());
    sb.append("\n# Generated app files\n");
    sb.append(publicSourcesSb.toString());
    sb.append("\n\n");
    sb.append("# All other resources require the user to be online.\n");
    sb.append("NETWORK:\n");
    sb.append("*\n");

    logger.log(TreeLogger.INFO, "Be sure your landing page's <html> tag declares a manifest:"
            + " <html manifest=" + context.getModuleFunctionName() + "/" + MANIFEST + "\">");

    // Create the manifest as a new artifact and return it:
    return emitString(logger, sb.toString(), MANIFEST);
}

From source file:com.google.code.gwt.appcache.linker.IFrameAppCacheLinker.java

License:Apache License

/**
 * Creates the cache-manifest resource specific for the landing page.
 *///from  w w w  .  ja  v  a  2 s . com
private Artifact<?> emitLandingPageCacheManifest(LinkerContext context, TreeLogger logger,
        ArtifactSet artifacts) throws UnableToCompleteException {
    // Create a list of cacheable resources:
    SortedSet<String> cachePaths = new TreeSet<String>();
    SortedSet<String> networkPaths = new TreeSet<String>();

    // Iterate over all emitted artifacts, and collect all
    // cacheable- and networked artifacts:
    for (Artifact artifact : artifacts) {
        // logger.log(TreeLogger.INFO, "Checking artifact "
        // + artifact.getClass().getName() + " created by "
        // + artifact.getLinker().getName() + ": " + artifact.toString() + "...");
        if (artifact instanceof EmittedArtifact) {
            EmittedArtifact ea = (EmittedArtifact) artifact;
            if (ea.getLinker().equals(getClass())) {
                if (ea.getPartialPath().endsWith(".cache.html")
                        || ea.getPartialPath().endsWith(".nocache.js")) {
                    cachePaths.add(ea.getPartialPath());
                }
            } else {
                cachePaths.add(ea.getPartialPath());
            }
        } else if (artifact instanceof NetworkSectionArtifact) {
            NetworkSectionArtifact nsa = (NetworkSectionArtifact) artifact;
            networkPaths.add(nsa.getUrl());
        }
    }

    String cacheEntries = concatPaths(cachePaths);
    String networkEntries = concatPaths(networkPaths);

    InputStream templateInput = getClass().getResourceAsStream(TEMPLATE_RESOURCE);
    StringBuilder tb = new StringBuilder();
    if (templateInput != null) {
        logger.log(TreeLogger.INFO, "HTML 5 cache-manifest resource '" + TEMPLATE_RESOURCE
                + "' found - using that resource as template.");
        // Read template into a StringBuilder:
        BufferedReader reader = new BufferedReader(new InputStreamReader(templateInput));
        try {
            String line = null;
            while ((line = reader.readLine()) != null) {
                if (!line.trim().startsWith("#")) {
                    line = searchAndReplace(line, CACHE_ENTRIES, cacheEntries);
                    line = searchAndReplace(line, NETWORK_ENTRIES, networkEntries);
                }
                tb.append(line).append('\n');
            }
            reader.close();
        } catch (IOException e) {
            logger.log(TreeLogger.ERROR, "Failed to read resource '" + TEMPLATE_RESOURCE + "'!", e);
        }
    }
    if (tb.length() == 0) {
        logger.log(TreeLogger.INFO, "HTML 5 cache-manifest resource '" + TEMPLATE_RESOURCE
                + "' not found (or empty or whatever) - generating default manifest.");
        tb.append("CACHE MANIFEST\n\nCACHE:\n").append(cacheEntries).append("\n\nNETWORK:\n")
                .append(networkEntries);
    }

    logger.log(TreeLogger.INFO,
            "Make sure you have the following"
                    + " attribute added to your landing page's <html> tag: manifest=\""
                    + context.getModuleFunctionName() + "/" + MANIFEST + "\"");

    // Create the manifest as a new artifact and return it:
    return emitString(logger, tb.toString(), MANIFEST);
}

From source file:com.google.gerrit.gwtdebug.GerritDebugLauncher.java

License:Apache License

@Override
public ServletContainer start(TreeLogger logger, int port, File warDir) throws Exception {
    TreeLogger branch = logger.branch(TreeLogger.INFO, "Starting Jetty on port " + port, null);

    checkStartParams(branch, port, warDir);

    // Setup our branch logger during startup.
    Log.setLog(new JettyTreeLogger(branch));

    // Turn off XML validation.
    System.setProperty("org.mortbay.xml.XmlParser.Validating", "false");

    AbstractConnector connector = getConnector();
    if (bindAddress != null) {
        connector.setHost(bindAddress.toString());
    }/*from w  w w .ja  v  a  2  s.  c  o m*/
    connector.setPort(port);

    // Don't share ports with an existing process.
    connector.setReuseAddress(false);

    // Linux keeps the port blocked after shutdown if we don't disable this.
    connector.setSoLingerTime(0);

    Server server = new Server();
    server.addConnector(connector);

    File top;
    String root = System.getProperty("gerrit.source_root");
    if (root != null) {
        top = new File(root);
    } else {
        // Under Maven warDir is "$top/gerrit-gwtui/target/gwt-hosted-mode"
        top = warDir.getParentFile().getParentFile().getParentFile();
    }

    File app = new File(top, "gerrit-war/src/main/webapp");
    File webxml = new File(app, "WEB-INF/web.xml");

    // Jetty won't start unless this directory exists.
    if (!warDir.exists() && !warDir.mkdirs())
        logger.branch(TreeLogger.ERROR, "Cannot create " + warDir, null);

    // Create a new web app in the war directory.
    //
    WebAppContext wac = new MyWebAppContext(warDir.getAbsolutePath(), "/");
    wac.setDescriptor(webxml.getAbsolutePath());

    RequestLogHandler logHandler = new RequestLogHandler();
    logHandler.setRequestLog(new JettyRequestLogger(logger));
    logHandler.setHandler(wac);
    server.setHandler(logHandler);
    server.start();
    server.setStopAtShutdown(true);

    // Now that we're started, log to the top level logger.
    Log.setLog(new JettyTreeLogger(logger));

    return new JettyServletContainer(logger, server, wac, connector.getLocalPort(), warDir);
}