Package javax.script

Examples of javax.script.Compilable.compile()


            // pre-compile script if we have it as text
            if (reader != null) {
                ScriptEngine engine = this.scriptEngineFactory.getScriptEngine();
                if (engine instanceof Compilable) {
                    Compilable compilable = (Compilable) engine;
                    this.compiledScript = compilable.compile(scriptText);
                    LOG.debug("Using compiled script: {}", this.compiledScript);
                }
            }
        } catch (IOException e) {
            throw new ScriptEvaluationException("Cannot load " + scriptLanguage + " script from resource: " + scriptResource, e);
View Full Code Here


            LOG.debug("Created metric pickler with prefix {} and batchSize {}", prefix, batchSize);
           
            ScriptEngine engine = new ScriptEngineManager().getEngineByName("python");           
            Compilable compilable = (Compilable) engine;
            try {
                pickleScript = compilable.compile(PICKLER_SCRIPT);
            } catch (ScriptException e) {
                throw new RuntimeException("Unable to compile pickle script", e);
            }

        }
View Full Code Here

        if (scriptEngine == null)
            throw new InvalidRequestException(String.format("Invalid language '%s' for function '%s'", language, name));

        try
        {
            this.script = scriptEngine.compile(body);
        }
        catch (RuntimeException | ScriptException e)
        {
            logger.info("Failed to compile function '{}' for language {}: ", name, language, e);
            throw new InvalidRequestException(
View Full Code Here

    }

    public void testCompilable() throws Exception {
        assertTrue("Engine should implement Compilable", engine instanceof Compilable);
        Compilable cengine = (Compilable) engine;
        CompiledScript script = cengine.compile("40 + 2");
        assertEquals(Integer.valueOf(42), script.eval());
        assertEquals(Integer.valueOf(42), script.eval());
    }
}
View Full Code Here

    {
        CompiledScript result = null;
        try
        {
            Compilable c = (Compilable)this.engine;
            result = c.compile(string);
        } catch (ScriptException se) {}
        setExpectingMoreInput(result == null);
        return result;
    }
  public CompiledScript addInput(String line) throws ScriptException {
View Full Code Here

      parserText = lib + parserText;

      Compilable c = (Compilable) scriptEngine;
      try {
        compiledScript = c.compile(parserText);
      } catch (ScriptException e) {
        scriptManager.getErrorMessage(e, parserText);
      }

      request.setCompiledScript(compiledScript);
View Full Code Here

            LOG.debug("Created metric pickler with prefix {} and batchSize {}", prefix, batchSize);
           
            ScriptEngine engine = new ScriptEngineManager().getEngineByName("python");           
            Compilable compilable = (Compilable) engine;
            try {
                pickleScript = compilable.compile(PICKLER_SCRIPT);
            } catch (ScriptException e) {
                throw new RuntimeException("Unable to compile pickle script", e);
            }

        }
View Full Code Here

      } else if (cl.hasOption(script.getOpt())) {
        String inlineScript = cl.getOptionValue(script.getOpt());
        try {
          if (engine instanceof Compilable) {
            Compilable compiledEng = (Compilable) engine;
            CompiledScript script = compiledEng.compile(inlineScript);
            script.eval(ctx);
            if (invoke) {
              this.invokeFunctionOrMethod(shellState, engine, cl, argArray);
            }
          } else {
View Full Code Here

            LOG.debug("Created metric pickler with prefix {} and batchSize {}", prefix, batchSize);
           
            ScriptEngine engine = new ScriptEngineManager().getEngineByName("python");           
            Compilable compilable = (Compilable) engine;
            try {
                pickleScript = compilable.compile(PICKLER_SCRIPT);
            } catch (ScriptException e) {
                throw new RuntimeException("Unable to compile pickle script", e);
            }

        }
View Full Code Here

      fis = new FileInputStream(file);
      isr = new InputStreamReader(fis);
      buff = new BufferedReader(isr);

      // TODO lock file
      cs = eng.compile(buff);
      if(cs instanceof Serializable)
      {
        synchronized (_compiledScriptCache)
        {
          _compiledScriptCache.put(relativeName, new CompiledScriptHolder(cs, file));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.