/** * @see de.matrixweb.smaller.javascript.JavaScriptExecutor#addGlobalFunction(java.lang.String, * java.lang.Object) */ @Override public void addGlobalFunction(final String name, final Object object) { addGlobalFunction(name, object, name); }
@Override public void call(final Reader reader, final Writer writer) throws IOException { UglifyjsProcessor.this.executor.run(reader, writer); } });
/** * @see de.matrixweb.smaller.javascript.JavaScriptExecutor#addCallScript(java.lang.String) */ @Override public void addCallScript(final String source) { this.executor.addCallScript(source); }
/** * */ public YcssminProcessor() { this.executor = new JavaScriptExecutorFast("ycssmin-913e1945c2", 9, getClass()); this.executor.addScriptSource("var exports = {};", "rhino.js"); this.executor.addScriptFile(getClass().getResource( "/ycssmin-913e1945c2/cssmin-913e1945c2.js")); this.executor.addCallScript("exports.cssmin(%s);"); }
private void setupJavascriptExecutor() { if (this.executor == null) { this.executor = new JavaScriptExecutorFast("jshint-1.1.0", 9, JshintProcessor.class); this.executor.addScriptFile(getClass().getResource( "/jshint-1.1.0/jshint-1.1.0.js")); this.executor.addScriptFile(getClass().getResource( "/jshint-1.1.0/jshint-call.js")); this.executor.addCallScript("hint(%s);"); } }
/** * @see de.matrixweb.smaller.resource.Processor#dispose() */ @Override public void dispose() { this.executor.dispose(); }
/** * @see de.matrixweb.smaller.javascript.JavaScriptExecutor#addScriptFile(java.lang.String) */ @Override public void addScriptFile(final String file) { this.executor.addScriptFile(file); }
/** * @see de.matrixweb.smaller.javascript.JavaScriptExecutor#addScriptSource(java.lang.String, * java.lang.String) */ @Override public void addScriptSource(final String source, final String name) { this.executor.addScriptSource(source, name); }
/** * @param name * @param optimizationLevel * @param clazz */ public JavaScriptExecutorFast(final String name, final int optimizationLevel, final Class<?> clazz) { try { LOGGER.info("Try v8 executor"); this.executor = new JavaScriptExecutorV8(name, clazz); } catch (final NoClassDefFoundError e) { LOGGER.info("Fallback to rhino executor"); this.executor = new JavaScriptExecutorRhino(name, optimizationLevel, clazz); } catch (final UnsatisfiedLinkError e) { LOGGER.info("Fallback to rhino executor"); this.executor = new JavaScriptExecutorRhino(name, optimizationLevel, clazz); } }
/** * @see de.matrixweb.smaller.javascript.JavaScriptExecutor#addGlobalFunction(java.lang.String, * java.lang.Object) */ @Override public void addGlobalFunction(final String name, final Object object) { this.executor.addGlobalFunction(name, object); }
/** * @see de.matrixweb.smaller.javascript.JavaScriptExecutor#addGlobalFunction(java.lang.String, * java.lang.Object) */ @Override public final void addGlobalFunction(final String name, final Object object) { addGlobalFunction(name, object, name); }
/** * This creates a new script environment. * * @param name * The path of the script to add * @param optimizationLevel * The optimization level to use (-1 lowest, 9 highest) * @param clazz * The class used for resource resolving */ public JavaScriptExecutorRhino(final String name, final int optimizationLevel, final Class<?> clazz) { this.name = name; this.optimizationLevel = optimizationLevel; init(clazz); }
private Resource executeWithJs(final VFS vfs, final Resource resource, final Map<String, Object> options) throws IOException { if (this.executor == null) { this.executor = new JavaScriptExecutorFast("uglify-" + this.version, 9, getClass()); this.executor.addScriptSource("module = {};", "rhino.js"); this.executor.addScriptFile(getClass().getResource( "/uglify-" + this.version + "/uglify-js.js")); this.executor.addCallScript("uglify(%s, {});"); } return ProcessorUtil.process(vfs, resource, "js", new ProcessorCallback() { @Override public void call(final Reader reader, final Writer writer) throws IOException { UglifyjsProcessor.this.executor.run(reader, writer); } }); }
/** * @see de.matrixweb.smaller.javascript.JavaScriptExecutor#dispose() */ @Override public void dispose() { this.executor.dispose(); }
/** * @see de.matrixweb.smaller.javascript.JavaScriptExecutor#run(java.io.Reader, * java.io.Writer) */ @Override public void run(final Reader input, final Writer output) throws IOException { this.executor.run(input, output); }
/** * @see de.matrixweb.smaller.javascript.JavaScriptExecutor#addScriptFile(java.net.URL) */ @Override public void addScriptFile(final URL url) { this.executor.addScriptFile(url); }
/** * @see de.matrixweb.smaller.javascript.JavaScriptExecutor#addGlobalFunction(java.lang.String, * java.lang.Object, java.lang.String) */ @Override public void addGlobalFunction(final String name, final Object object, final String method) { this.executor.addGlobalFunction(name, object, method); }
/** * @see de.matrixweb.smaller.resource.Processor#dispose() */ @Override public void dispose() { if (this.executor != null) { this.executor.dispose(); } if (this.node != null) { this.node.dispose(); } }
@Override public void call(final Reader reader, final Writer writer) throws IOException { YcssminProcessor.this.executor.run(reader, writer); } });
/** * @see de.matrixweb.smaller.resource.Processor#dispose() */ @Override public void dispose() { if (this.node != null) { this.node.dispose(); } if (this.executor != null) { this.executor.dispose(); } }