Example usage for javax.script ScriptEngineManager getEngineByMimeType

List of usage examples for javax.script ScriptEngineManager getEngineByMimeType

Introduction

In this page you can find the example usage for javax.script ScriptEngineManager getEngineByMimeType.

Prototype

public ScriptEngine getEngineByMimeType(String mimeType) 

Source Link

Document

Look up and create a ScriptEngine for a given mime type.

Usage

From source file:Main.java

public static void main(String[] args) {
    ScriptEngineManager manager = new ScriptEngineManager();
    ScriptEngine jsEngine = manager.getEngineByMimeType("text/javascript");
    if (!(jsEngine == null)) {
        System.out.println("text/javascript MIME type retrieved:" + jsEngine);
    }//from w  w w  .  j av a2s . com
    ScriptEngine jsEngine2 = manager.getEngineByMimeType("text/vbscript");
    if (jsEngine2 == null)
        System.out.println("\nNo supported script engine found for text/vbscript MIME type.");
}

From source file:GetEngineByMimeDemo.java

public static void main(String[] args) {
    ScriptEngineManager manager = new ScriptEngineManager();
    /* Retrieve a ScriptEngine that supports the text/javascript MIME type */
    ScriptEngine jsEngine = manager.getEngineByMimeType("text/javascript");
    if (!(jsEngine == null)) {
        System.out.println("text/javascript MIME type retrieved:" + jsEngine);
    }/*from w w  w . java2s . co m*/
    ScriptEngine jsEngine2 = manager.getEngineByMimeType("text/vbscript");
    if (jsEngine2 == null)
        System.out.println("\nNo supported script engine found for text/vbscript MIME type.");
}

From source file:ObtainScriptEngine.java

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

    ScriptEngine engine1 = manager.getEngineByExtension("js");
    System.out.println(engine1);/*from   ww w  . j av  a 2  s . c  o m*/

    ScriptEngine engine2 = manager.getEngineByMimeType("application/javascript");
    System.out.println(engine2);

    ScriptEngine engine3 = manager.getEngineByName("rhino");
    System.out.println(engine3);
}

From source file:de.perdoctus.synology.jdadapter.controller.JdAdapter.java

private String extractKey(String jk) throws ScriptException {
    final ScriptEngineManager scriptEngineManager = new ScriptEngineManager();
    final ScriptEngine scriptEngine = scriptEngineManager.getEngineByMimeType("text/javascript");
    scriptEngine.eval(jk + "\nvar result = f();");
    return scriptEngine.get("result").toString();
}