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

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

Introduction

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

Prototype

Type SPAM

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

Click Source Link

Document

Logs extremely verbose and detailed information that is typically useful only to product implementors.

Usage

From source file:com.google.gdt.eclipse.designer.hosted.tdz.BrowserShell.java

License:Open Source License

/**
 * Initializes and attaches module space to this browser widget. Called by subclasses in response to calls
 * from JavaScript./*from w  w w  . j  a v  a  2s. c  o m*/
 * 
 * @param space
 *            ModuleSpace instance to initialize
 */
protected final void attachModuleSpace(ModuleSpace space) throws UnableToCompleteException {
    space.setDevClassLoader(m_host.getDevClassLoader());
    loadedModules.put(null, space);
    m_logger.log(TreeLogger.SPAM, "Loading module " + space.getModuleName(), null);
    // Let the space do its thing.
    //
    space.onLoad(m_logger);
}

From source file:com.google.gdt.eclipse.designer.hosted.tdz.BrowserShell.java

License:Open Source License

/**
 * Unload the specified module.//  ww w. j a  v a2  s.  co  m
 * 
 * @param moduleSpace
 *            a ModuleSpace instance to unload.
 */
protected void unloadModule(ModuleSpace moduleSpace) {
    String moduleName = moduleSpace.getModuleName();
    moduleSpace.dispose();
    m_logger.log(TreeLogger.SPAM, "Unloading module " + moduleName, null);
}

From source file:com.gwtplatform.dispatch.rest.rebind.utils.Logger.java

License:Apache License

public void spam(String message, Object... params) {
    String format = String.format(message, params);
    treeLogger.log(TreeLogger.SPAM, format);
}

From source file:com.totsp.gwittir.rebind.beans.IntrospectorGenerator.java

License:Open Source License

private void writeBeanDescriptor(TreeLogger logger, BeanResolver info, MethodWrapper[] methods,
        SourceWriter writer) {/*from w w  w. j ava2 s .c o  m*/
    writer.println("new BeanDescriptor() { ");
    writer.indent();
    writer.println("private HashMap lookup;");
    writer.println("private Property[] properties;");
    writer.println("public Property[] getProperties(){");
    writer.indent();

    {
        writer.println("if( this.properties != null ) ");
        writer.indentln("return this.properties;");
        writer.println("this.properties = new Property[" + (info.getProperties().size()) + "];");

        Collection pds = info.getProperties().values();
        String[] propertyNames = new String[pds.size()];
        logger.log(TreeLogger.SPAM, "" + (pds == null), null);

        if (pds != null) {
            int i = 0;

            for (Iterator it = pds.iterator(); it.hasNext(); i++) {
                RProperty p = (RProperty) it.next();
                propertyNames[i] = p.getName();
                writer.println("{");
                writer.indent();

                writer.print("Method readMethod = ");

                if (p.getReadMethod() == null) {
                    writer.println("null;");
                } else {
                    writer.println(this.packageName + "." + this.methodsImplementationName + ".METHOD_"
                            + +this.find(methods, p.getReadMethod()) + ";");
                }

                writer.print("Method writeMethod = ");

                if (p.getWriteMethod() == null) {
                    writer.println("null;");
                } else {
                    writer.println(this.packageName + "." + this.methodsImplementationName + ".METHOD_"
                            + +this.find(methods, p.getWriteMethod()) + ";");
                }

                logger.log(TreeLogger.DEBUG, p.getName() + " " + p.getType().getQualifiedSourceName(), null);

                JType ptype = this.resolveType(p.getType());

                logger.log(TreeLogger.DEBUG, p.getName() + " (Erased) " + ptype.getQualifiedSourceName(), null);
                writer.println("this.properties[" + (i) + "] = new Property( \"" + p.getName() + "\", "
                        + ((p.getType() != null) ? ptype.getQualifiedSourceName() : "Object")
                        + ".class,  readMethod, writeMethod );");
                writer.outdent();
                writer.println("}");
            }
        }

        writer.println("return this.properties;");
    }

    writer.outdent();
    writer.println("} //end getProperties()");
    writer.println("public Property getProperty( String name ) {");
    writer.indent();
    //TODO Rewrite this to a nested if loop using the propertyNames parameter.
    writer.println("Property p = null;");
    writer.println("if( this.lookup != null ) {");
    writer.indentln("p = (Property) lookup.get(name); ");
    writer.println("} else {");
    writer.indent();
    writer.println("this.lookup = new HashMap();");
    writer.println("Property[] props = this.getProperties(); ");
    writer.println("for( int i=0; i < props.length; i++ ) {");
    writer.indent();
    writer.println("this.lookup.put( props[i].getName(), props[i] );");
    writer.outdent();
    writer.println("}");
    writer.println("p = (Property) this.lookup.get(name);");
    writer.outdent();
    writer.println("}");
    writer.println("if( p == null ) throw new RuntimeException(\"Couldn't find property \"+name+\" for "
            + info.getType().getQualifiedSourceName() + "\");");
    writer.println("else return p;");
    writer.outdent();
    writer.println("}");

    writer.outdent();
    writer.print("}");
}

From source file:com.totsp.gwittir.rebind.beans.IntrospectorGenerator.java

License:Open Source License

private void writeMethod(TreeLogger logger, MethodWrapper method, SourceWriter writer) {
    JType ptype = this.resolveType(method.getDeclaringType());

    writer.println("new Method(){ ");
    writer.indent();// ww w.  j a  va  2  s  .c  om
    writer.println("public String getName() {");
    writer.indentln("return \"" + method.getBaseMethod().getName() + "\";");
    writer.println(" }");
    writer.println("public Object invoke( Object target, Object[] args ) throws Exception {");
    writer.indent();
    writer.println(ptype.getQualifiedSourceName() + " casted =");
    writer.println("(" + ptype.getQualifiedSourceName() + ") target;");
    logger.log(TreeLogger.SPAM, "Method: " + method.getBaseMethod().getName() + " "
            + method.getBaseMethod().getReturnType().getQualifiedSourceName(), null);

    if (!(method.getBaseMethod().getReturnType().isPrimitive() == JPrimitiveType.VOID)) {
        writer.print("return ");
    }

    JType type = this.resolveType(method.getBaseMethod().getReturnType());

    boolean boxed = this.box(type, writer);
    writer.print("casted." + method.getBaseMethod().getName() + "(");

    if (method.getBaseMethod().getParameters() != null) {
        for (int j = 0; j < method.getBaseMethod().getParameters().length; j++) {
            JType arg = this.resolveType(method.getBaseMethod().getParameters()[j].getType());

            this.unbox(arg, "args[" + j + "]", writer);

            if (j != (method.getBaseMethod().getParameters().length - 1)) {
                writer.print(", ");
            }
        }
    }

    writer.print(")");

    if (boxed) {
        writer.print(")");
    }

    writer.println(";");

    if (method.getBaseMethod().getReturnType().getQualifiedSourceName().equals("void")) {
        writer.println("return null;");
    }

    writer.outdent();
    writer.println("}");
    writer.outdent();
    writer.println("};");
}

From source file:gwt.ns.webworker.linker.WorkerCompilationLinker.java

License:Apache License

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

    ArtifactSet toReturn = new ArtifactSet(artifacts);

    // get set of requests for insideWorker compilations from artifacts
    SortedSet<WorkerRequestArtifact> workerRequests = toReturn.find(WorkerRequestArtifact.class);
    if (workerRequests.size() == 0) {
        logger.log(TreeLogger.SPAM, "No Worker compilations requested. No action taken.");
        return toReturn; // early exit, sorry
    }/*  www.  j a v  a2s . c  o m*/

    // compile all requested workers
    // if this is a recursive call, requests were passed up to parent so
    // returned value is null
    SortedMap<WorkerRequestArtifact, String> workerScripts = WorkerCompiler.run(logger, workerRequests);

    // if they exist, deal with compiled scripts:
    if (workerScripts != null && workerScripts.size() != 0) {
        // directory strong name from all scripts
        byte[][] bytejs = Util.getBytes(workerScripts.values().toArray(new String[0]));
        String scriptDirStrongName = Util.computeStrongName(bytejs);

        // emit worker scripts
        for (Map.Entry<WorkerRequestArtifact, String> script : workerScripts.entrySet()) {
            WorkerRequestArtifact req = script.getKey();
            toReturn.add(emitString(logger, script.getValue(),
                    req.getRelativePath(scriptDirStrongName, File.separator)));
        }

        // get the set of current compilation results
        SortedSet<CompilationResult> compResults = toReturn.find(CompilationResult.class);

        /*
         * Reading the js from and writing it to a new CompilationResult is
         * expensive (possibly disk cached), so read once and write only if
         * altered.
         */
        for (CompilationResult compRes : compResults) {
            // assume all need modification
            // TODO: rule out emulated permutations via properties
            toReturn.remove(compRes);

            CompilationResult altered = replacePlaceholder(logger, compRes,
                    WorkerRequestArtifact.getPlaceholderStrongName(), scriptDirStrongName);
            toReturn.add(altered);
        }
    }

    return toReturn;
}

From source file:gwt.ns.webworker.linker.WorkerCompilationLinker.java

License:Apache License

/**
 * Searches for all instances of a placeholder String in a
 * CompilationResult. If found, they are replaced as specified and a
 * new CompilationResult, with a newly generated strong name, is returned.
 * If no occurrences were found, the original CompilationResult is
 * returned.//from w w  w  .  j a va2s .  c  om
 * 
 * @param logger
 * @param result CompilationResult to process
 * @param placeholder String to be replaced
 * @param replacement String to insert in place of placeholder
 * 
 * @return A CompilationResult suitable for emitting
 */
public CompilationResult replacePlaceholder(TreeLogger logger, CompilationResult result, String placeholder,
        String replacement) {

    boolean needsMod = false;

    String[] js = result.getJavaScript();
    StringBuffer[] jsbuf = new StringBuffer[js.length];
    for (int i = 0; i < jsbuf.length; i++) {
        jsbuf[i] = new StringBuffer(js[i]);
    }

    // search and replace in all fragments
    for (StringBuffer fragment : jsbuf) {
        needsMod |= replaceAll(fragment, placeholder, replacement);
    }

    // by default, returning unaltered result
    CompilationResult toReturn = result;

    // code has been altered, need to create new CompilationResult
    if (needsMod) {
        logger.log(TreeLogger.SPAM,
                "Compilation permutation " + result.getPermutationId() + " being modified.");

        // new js for compilation result
        byte[][] newcode = new byte[jsbuf.length][];
        for (int i = 0; i < jsbuf.length; i++) {
            newcode[i] = Util.getBytes(jsbuf[i].toString());
        }

        // new strong name
        String strongName = Util.computeStrongName(newcode);

        // same symbolMap copied over since none altered
        // symbolMap a little more complicated
        // can only get deserialized version, need to reserialize
        // code from com.google.gwt.dev.jjs.JavaToJavaScriptCompiler
        // TODO: turns out this can get pretty bad. Workaround?
        SymbolData[] symbolMap = result.getSymbolMap();
        byte[] serializedSymbolMap;
        try {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            Util.writeObjectToStream(baos, (Object) symbolMap);
            serializedSymbolMap = baos.toByteArray();
        } catch (IOException e) {
            // should still never happen
            logger.log(TreeLogger.ERROR, "IOException while reserializing " + "SymbolMap.");
            throw new RuntimeException("Should never happen with in-memory stream", e);
        }

        StandardCompilationResult altered = new StandardCompilationResult(strongName, newcode,
                serializedSymbolMap, result.getStatementRanges(), result.getPermutationId());

        // need to copy permutation properties to new result
        for (Map<SelectionProperty, String> propertyMap : result.getPropertyMap()) {
            altered.addSelectionPermutation(propertyMap);
        }

        toReturn = altered;

        logger.log(TreeLogger.SPAM, "Compilation permuation " + toReturn.getPermutationId()
                + " altered to include path to worker script(s).");
    }

    return toReturn;
}