src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/scripting/NashornScriptEngineFactory.java

Print this page




  27 
  28 import java.util.Arrays;
  29 import java.util.Collections;
  30 import java.util.List;
  31 import javax.script.ScriptEngine;
  32 import javax.script.ScriptEngineFactory;
  33 import jdk.nashorn.internal.runtime.Context;
  34 import jdk.nashorn.internal.runtime.Version;
  35 
  36 /**
  37  * JSR-223 compliant script engine factory for Nashorn. The engine answers for:
  38  * <ul>
  39  * <li>names {@code "nashorn"}, {@code "Nashorn"}, {@code "js"}, {@code "JS"}, {@code "JavaScript"},
  40  * {@code "javascript"}, {@code "ECMAScript"}, and {@code "ecmascript"};</li>
  41  * <li>MIME types {@code "application/javascript"}, {@code "application/ecmascript"}, {@code "text/javascript"}, and
  42  * {@code "text/ecmascript"};</li>
  43  * <li>as well as for the extension {@code "js"}.</li>
  44  * </ul>
  45  * Programs executing in engines created using {@link #getScriptEngine(String[])} will have the passed arguments
  46  * accessible as a global variable named {@code "arguments"}.


  47  */

  48 public final class NashornScriptEngineFactory implements ScriptEngineFactory {
  49     @Override
  50     public String getEngineName() {
  51         return (String) getParameter(ScriptEngine.ENGINE);
  52     }
  53 
  54     @Override
  55     public String getEngineVersion() {
  56         return (String) getParameter(ScriptEngine.ENGINE_VERSION);
  57     }
  58 
  59     @Override
  60     public List<String> getExtensions() {
  61         return Collections.unmodifiableList(extensions);
  62     }
  63 
  64     @Override
  65     public String getLanguageName() {
  66         return (String) getParameter(ScriptEngine.LANGUAGE);
  67     }




  27 
  28 import java.util.Arrays;
  29 import java.util.Collections;
  30 import java.util.List;
  31 import javax.script.ScriptEngine;
  32 import javax.script.ScriptEngineFactory;
  33 import jdk.nashorn.internal.runtime.Context;
  34 import jdk.nashorn.internal.runtime.Version;
  35 
  36 /**
  37  * JSR-223 compliant script engine factory for Nashorn. The engine answers for:
  38  * <ul>
  39  * <li>names {@code "nashorn"}, {@code "Nashorn"}, {@code "js"}, {@code "JS"}, {@code "JavaScript"},
  40  * {@code "javascript"}, {@code "ECMAScript"}, and {@code "ecmascript"};</li>
  41  * <li>MIME types {@code "application/javascript"}, {@code "application/ecmascript"}, {@code "text/javascript"}, and
  42  * {@code "text/ecmascript"};</li>
  43  * <li>as well as for the extension {@code "js"}.</li>
  44  * </ul>
  45  * Programs executing in engines created using {@link #getScriptEngine(String[])} will have the passed arguments
  46  * accessible as a global variable named {@code "arguments"}.
  47  *
  48  * @since 1.8u40
  49  */
  50 @jdk.Exported
  51 public final class NashornScriptEngineFactory implements ScriptEngineFactory {
  52     @Override
  53     public String getEngineName() {
  54         return (String) getParameter(ScriptEngine.ENGINE);
  55     }
  56 
  57     @Override
  58     public String getEngineVersion() {
  59         return (String) getParameter(ScriptEngine.ENGINE_VERSION);
  60     }
  61 
  62     @Override
  63     public List<String> getExtensions() {
  64         return Collections.unmodifiableList(extensions);
  65     }
  66 
  67     @Override
  68     public String getLanguageName() {
  69         return (String) getParameter(ScriptEngine.LANGUAGE);
  70     }