Example usage for javax.script ScriptEngineFactory getEngineVersion

List of usage examples for javax.script ScriptEngineFactory getEngineVersion

Introduction

In this page you can find the example usage for javax.script ScriptEngineFactory getEngineVersion.

Prototype

public String getEngineVersion();

Source Link

Document

Returns the version of the ScriptEngine.

Usage

From source file:Main.java

public static void main(String args[]) {
    ScriptEngineManager manager = new ScriptEngineManager();
    List<ScriptEngineFactory> factories = manager.getEngineFactories();
    for (ScriptEngineFactory factory : factories) {
        System.out.println(factory.getEngineName());
        System.out.println(factory.getEngineVersion());
        System.out.println(factory.getLanguageName());
        System.out.println(factory.getLanguageVersion());
        System.out.println(factory.getExtensions());
        System.out.println(factory.getMimeTypes());
        System.out.println(factory.getNames());
    }//from www .j a  v  a2s .  co m
}

From source file:MetadataDemo.java

public static void main(String[] args) {
    ScriptEngineManager manager = new ScriptEngineManager();
    List<ScriptEngineFactory> factories = manager.getEngineFactories();
    for (ScriptEngineFactory factory : factories) {
        System.out.println("Full name = " + factory.getEngineName());
        System.out.println("\nVersion = " + factory.getEngineVersion());
        System.out.println("\nSupported language version = " + factory.getLanguageVersion());
    }//from   w  ww .  ja v a  2 s .  c o  m
}

From source file:Main.java

public static void main(String[] args) {
    ScriptEngineManager manager = new ScriptEngineManager();

    // Get the list of all available engines
    List<ScriptEngineFactory> list = manager.getEngineFactories();

    // Print the details of each engine
    for (ScriptEngineFactory f : list) {
        System.out.println("Engine Name:" + f.getEngineName());
        System.out.println("Engine Version:" + f.getEngineVersion());
        System.out.println("Language Name:" + f.getLanguageName());
        System.out.println("Language Version:" + f.getLanguageVersion());
        System.out.println("Engine Short Names:" + f.getNames());
        System.out.println("Mime Types:" + f.getMimeTypes());
        System.out.println("===");
    }/*from  ww w .j  a v a 2 s. c o  m*/
}

From source file:EnumerateScriptEngines.java

public static void main(String[] args) {
    ScriptEngineManager manager = new ScriptEngineManager();

    List<ScriptEngineFactory> factories = manager.getEngineFactories();
    for (ScriptEngineFactory factory : factories) {
        System.out.println("Engine name (full): " + factory.getEngineName());
        System.out.println("Engine version: " + factory.getEngineVersion());
        System.out.println("Supported extensions:");
        List<String> extensions = factory.getExtensions();
        for (String extension : extensions)
            System.out.println("  " + extension);
        System.out.println("Language name: " + factory.getLanguageName());
        System.out.println("Language version: " + factory.getLanguageVersion());
        System.out.println("Supported MIME types:");
        List<String> mimetypes = factory.getMimeTypes();
        for (String mimetype : mimetypes)
            System.out.println("  " + mimetype);
        System.out.println("Supported short names:");
        List<String> shortnames = factory.getNames();
        for (String shortname : shortnames)
            System.out.println("  " + shortname);
        System.out.println();/*  w w w.j  av  a2 s. c o m*/
    }
}

From source file:com.xafero.vee.cmd.MainApp.java

private static void printLanguages() {
    ScriptEngineManager mgr = new ScriptEngineManager();
    for (ScriptEngineFactory factory : mgr.getEngineFactories())
        System.out.println(MoreObjects.toStringHelper("").add("name", factory.getEngineName())
                .add("version", factory.getEngineVersion())
                .add("extensions", "[ " + Strings.join(" | ", factory.getExtensions()) + " ]")
                .add("mimeTypes", "[ " + Strings.join(" | ", factory.getMimeTypes()) + " ]")
                .add("aliases", "[ " + Strings.join(" | ", factory.getNames()) + " ]")
                .add("language", factory.getLanguageName() + " " + factory.getLanguageVersion())
                .omitNullValues().toString().replace(", ", String.format(", %n ")));
}

From source file:org.mycontroller.standalone.scripts.McScriptEngineUtils.java

public static List<HashMap<String, Object>> getScriptEnginesDetail() {
    List<HashMap<String, Object>> engines = new ArrayList<HashMap<String, Object>>();
    ScriptEngineManager mgr = McScriptEngineUtils.getScriptEngineManager();
    List<ScriptEngineFactory> factories = mgr.getEngineFactories();
    for (ScriptEngineFactory factory : factories) {
        HashMap<String, Object> engine = new HashMap<String, Object>();
        engine.put("engineName", factory.getEngineName());
        engine.put("engineVersion", factory.getEngineVersion());
        engine.put("languageName", factory.getLanguageName());
        engine.put("languageVersion", factory.getLanguageVersion());
        engine.put("extensions", factory.getExtensions());
        engine.put("alias", factory.getNames());
        engines.add(engine);/*from www . java2 s . c  o m*/
    }
    return engines;
}

From source file:org.trafodion.rest.script.ScriptManager.java

private ScriptManager() {
    List<ScriptEngineFactory> engines = manager.getEngineFactories();
    if (engines.isEmpty()) {
        LOG.warn("No scripting engines were found");
        return;//from  w w w.  j a  va 2s  .c  om
    }

    StringBuffer sb = new StringBuffer();
    sb.append("\nThe following " + engines.size() + " scripting engine(s) were found");

    for (ScriptEngineFactory engine : engines) {
        sb.append("\nEngine name: " + engine.getEngineName() + "\nVersion: " + engine.getEngineVersion()
                + "\nLanguage: " + engine.getLanguageName());
        List<String> extensions = engine.getExtensions();
        if (extensions.size() > 0) {
            sb.append("\n\tEngine supports the following extensions:");
            for (String e : extensions) {
                sb.append("\n\t\t" + e);
            }
        }
        List<String> shortNames = engine.getNames();
        if (shortNames.size() > 0) {
            sb.append("\n\tEngine has the following short names:");
            for (String n : engine.getNames()) {
                sb.append("\n\t\t" + n);
            }
        }

        String[] params = { ScriptEngine.ENGINE, ScriptEngine.ENGINE_VERSION, ScriptEngine.LANGUAGE,
                ScriptEngine.LANGUAGE_VERSION, ScriptEngine.NAME, "THREADING" };

        sb.append("\n\tEngine has the following parameters:");
        for (String param : params) {
            sb.append("\n\t\t" + param + " = " + engine.getParameter(param));
        }
        sb.append("\n=========================");
    }
    LOG.debug(sb.toString());

    //Get -Drest.home.dir
    restHome = System.getProperty("rest.home.dir");

    //Start the scripts directory watcher
    watcherWorker = new ScriptManagerWatcher("ScriptManagerWatcher", restHome + "/bin/scripts");
}

From source file:cc.osint.graphd.script.GScriptEngine.java

public void dumpScriptEngines() throws Exception {
    ScriptEngineManager mgr = new ScriptEngineManager();
    List<ScriptEngineFactory> factories = mgr.getEngineFactories();

    for (ScriptEngineFactory factory : factories) {
        log.info("ScriptEngineFactory Info");
        String engName = factory.getEngineName();
        String engVersion = factory.getEngineVersion();
        String langName = factory.getLanguageName();
        String langVersion = factory.getLanguageVersion();

        System.out.printf("\tScript Engine: %s (%s)\n", engName, engVersion);

        List<String> engNames = factory.getNames();
        for (String name : engNames) {
            System.out.printf("\tEngine Alias: %s\n", name);
        }/*from   w w  w.j  a  v  a  2 s .c  o m*/

        System.out.printf("\tLanguage: %s (%s)\n", langName, langVersion);
    }
}

From source file:org.springframework.data.hadoop.scripting.Jsr223ScriptEvaluator.java

protected ScriptEngine discoverEngine(ScriptSource script, Map<String, Object> arguments) {
    ScriptEngineManager engineManager = new ScriptEngineManager(classLoader);
    ScriptEngine engine = null;/*from   ww w  . j a v  a2 s.  c  om*/

    if (StringUtils.hasText(language)) {
        engine = engineManager.getEngineByName(language);
    } else {
        // make use the extension (enhanced ScriptSource interface)
        Assert.hasText(extension, "no language or extension specified");
        engine = engineManager.getEngineByExtension(extension);
    }

    Assert.notNull(engine, "No suitable engine found for "
            + (StringUtils.hasText(language) ? "language " + language : "extension " + extension));

    if (log.isDebugEnabled()) {
        ScriptEngineFactory factory = engine.getFactory();
        log.debug(String.format("Using ScriptEngine %s (%s), language %s (%s)", factory.getEngineName(),
                factory.getEngineVersion(), factory.getLanguageName(), factory.getLanguageVersion()));
    }

    return engine;
}

From source file:ca.hedlund.jiss.preprocessor.LangPreprocessor.java

private void printLangs(JissModel model, StringBuffer cmd) {
    final ScriptEngineManager manager = new ScriptEngineManager(JissModel.class.getClassLoader());
    final List<String> cmds = new ArrayList<String>();

    for (ScriptEngineFactory factory : manager.getEngineFactories()) {
        final String engineInfo = factory.getLanguageName() + " " + factory.getLanguageVersion() + ":"
                + factory.getEngineName() + " " + factory.getEngineVersion();
        cmds.add(createPrintCmd(model, engineInfo));
    }//www.  j  a va 2  s  .  c  o m
    final ScriptEngineFactory factory = model.getScriptEngine().getFactory();
    final String prog = StringEscapeUtils.unescapeJava(factory.getProgram(cmds.toArray(new String[0])));
    cmd.append(prog);
}