Package javax.script

Examples of javax.script.ScriptEngineManager


      return null;
    }
    else {
      String language = annotation.value();
      if (!cachedEngines.containsKey(language)) {
        ScriptEngine engine = new ScriptEngineManager().getEngineByName(language);
        if (engine == null) {
          throw LOG.noScriptEngineFoundForLanguage(language);
        }
        cachedEngines.put(language, engine);
      }
View Full Code Here


   * @param jscript the script to be evaluated
   * @return the return type made by javascript
   * @throws ScriptException if the script is not valid javascript text
   */
  public static Object eval(String jscript) throws ScriptException{
    final ScriptEngineManager manager = new ScriptEngineManager();
      final ScriptEngine engine = manager.getEngineByName("js");
      return engine.eval(jscript);
  }
View Full Code Here

public class JavascriptEval {
  public static Object evalJS(String script) throws Exception{
    //System.out.println(script);
    // create a script engine manager
        final ScriptEngineManager factory = new ScriptEngineManager();
        // create JavaScript engine
        final ScriptEngine engine = factory.getEngineByName("JavaScript");
        // evaluate JavaScript code from given file - specified by first argument
        //System.out.println(script);
        return engine.eval(script);
  }
View Full Code Here

   *
   * @throws ScriptException In case no JSR 223 compatible engine for the given language could be found.
   */
  private ScriptEvaluator createNewScriptEvaluator(String languageName) throws ScriptException {

    ScriptEngine engine = new ScriptEngineManager().getEngineByName( languageName );

    if ( engine == null ) {
      throw new ScriptException( "No JSR 223 script engine found for language \"" + languageName + "\"." );
    }

View Full Code Here

        model.addObjectListener(this);

        // get all installed script engines
        scriptExtensions = new HashSet<String>();
        ScriptEngineManager mgr = new ScriptEngineManager();
        for (ScriptEngineFactory sef : mgr.getEngineFactories()) {
            scriptExtensions.addAll(sef.getExtensions());
        }

        createGUI();
    }
View Full Code Here

    /* The Groovy script invokable instance */
    private Invocable invokable_;
   
    private CalloutManager()
    {
        ScriptEngineManager scriptManager = new ScriptEngineManager();
        ScriptEngine groovyEngine = scriptManager.getEngineByName("groovy");
        compiler_ = (Compilable)groovyEngine;
        invokable_ = (Invocable)groovyEngine;
    }
View Full Code Here

            }

            return Optional.of((ScriptEngine) new GremlinGroovyScriptEngine(
                    new DefaultImportCustomizerProvider(imports, staticImports), securityCustomizerProvider));
        } else {
            final ScriptEngineManager manager = new ScriptEngineManager();
            return Optional.ofNullable(manager.getEngineByName(language));
        }
    }
View Full Code Here

  private ScriptEngineFactory[] getScriptEngineLanguages()
  {
    final LinkedHashSet<ScriptEngineFactory> langSet = new LinkedHashSet<ScriptEngineFactory>();
    langSet.add(null);
    final List<ScriptEngineFactory> engineFactories = new ScriptEngineManager().getEngineFactories();
    for (final ScriptEngineFactory engineFactory : engineFactories)
    {
      langSet.add(engineFactory);
    }
    return langSet.toArray(new ScriptEngineFactory[langSet.size()]);
View Full Code Here

    @Test
    public void testScripts() throws Exception {
        Stream.of(
            new File(getClass().getResource("/org/jooq/example/test").toURI()).listFiles((dir, name) -> name.endsWith(".js"))
        ).forEach(file -> {
            ScriptEngineManager manager = new ScriptEngineManager();
            ScriptEngine engine = manager.getEngineByName("nashorn");

            Bindings bindings = engine.getBindings(ENGINE_SCOPE);
            bindings.put("connection", connection);

            try {
View Full Code Here

            throw new JBIException("Failed to parse compiledScript. Reason:  " + e, e);
        }
    }

    protected ScriptEngine createScriptEngine() {
        ScriptEngineManager manager = new ScriptEngineManager();
        return manager.getEngineByName(scriptEngineName);
    }
View Full Code Here

TOP

Related Classes of javax.script.ScriptEngineManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.