Package javax.script

Examples of javax.script.Compilable


        if (compiledScript == null) {
            checkScriptTextAvailable();
        }
        if (compiledScript == null) {
            if (engine instanceof Compilable) {
                Compilable compilable = (Compilable) engine;
                compileScript(compilable);
            }
        }
    }
View Full Code Here


        if (compiledScript == null) {
            checkScriptTextAvailable();
        }
        if (compiledScript == null) {
            if (engine instanceof Compilable) {
                Compilable compilable = (Compilable) engine;
                compileScript(compilable);
            }
        }
    }
View Full Code Here

            // 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

      ScriptEngine se = mgr.getEngineByName("JUnit");
      assertNotNull(se);
      se.put("key", "value");
      assertEquals("value",se.eval("key"));
      if (se instanceof Compilable){
          Compilable co = (Compilable) se;
          CompiledScript cs = co.compile("key");
          assertNotNull(cs);
          assertEquals("value",cs.eval());
            assertEquals("value",cs.eval());         
      } else {
          fail("Expected engine to implement Compilable");
View Full Code Here

            // 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

            this.batchSize = batchSize;
           
            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 (compiledScript == null) {
            checkScriptTextAvailable();
        }
        if (compiledScript == null) {
            if (engine instanceof Compilable) {
                Compilable compilable = (Compilable) engine;
                compileScript(compilable);
            }
        }
    }
View Full Code Here

                   boolean deterministic)
    throws InvalidRequestException
    {
        super(name, argNames, argTypes, returnType, language, body, deterministic);

        Compilable scriptEngine = scriptEngines.get(language);
        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

        assertEquals("ERROR", outContent.toString());
    }

    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

        if (compiledScript == null) {
            checkScriptTextAvailable();
        }
        if (compiledScript == null) {
            if (engine instanceof Compilable) {
                Compilable compilable = (Compilable) engine;
                compileScript(compilable);
            }
        }
    }
View Full Code Here

TOP

Related Classes of javax.script.Compilable

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.