Package javax.script

Examples of javax.script.CompiledScript


    public void testCompileEvalString() throws ScriptException {
        ScriptEngineManager manager = new ScriptEngineManager();
        ScriptEngine pythonEngine = manager.getEngineByName("python");

        CompiledScript five = ((Compilable) pythonEngine).compile("5");
        assertEquals(Integer.valueOf(5), five.eval());
    }
View Full Code Here


    public void testCompileEvalReader() throws ScriptException {
        ScriptEngineManager manager = new ScriptEngineManager();
        ScriptEngine pythonEngine = manager.getEngineByName("python");

        CompiledScript five = ((Compilable) pythonEngine).compile(new StringReader("5"));
        assertEquals(Integer.valueOf(5), five.eval());
    }
View Full Code Here

            }
            mvelInputParamTypes.put(CONTEXT_BINDING_NAME, EPLScriptContext.class);
            compiled = MVELHelper.compile(script.getName(), script.getExpression(), mvelInputParamTypes);
        }
        else {
            CompiledScript compiledScript = JSR223Helper.verifyCompileScript(script, dialect);
            compiled = new ExpressionScriptCompiledJSR223(compiledScript);
        }
        script.setCompiled(compiled);
    }
View Full Code Here

    this.compileScripts = compileScripts;
  }

  public ExecutableScript createScript(String src, String language) {

    CompiledScript compiledScript = null;
    if (compileScripts) {
      compiledScript = scriptingEngines.compile(src, language);
    }

    if(compiledScript != null) {
View Full Code Here

    assertEquals("PASSED", getOutput());
    resetOutBuffer();
  }
 
  public void testCompileScript() {
    CompiledScript script = null;
   
    StringReader reader = new StringReader(
        "context.getWriter().println(\"PASSED\");");
    try {
      script = engine.compile(reader);
    } catch (ScriptException ex) {
      fail(buildMessage("RhinoScriptEngine.compileScript(): Unexpected " +
          "ScriptException ..", ex.getMessage()));
    }
   
    try {
      script.eval();
      String str = getOutput();
      assertEquals("PASSED", str);
    } catch (ScriptException ex) {
      fail(buildMessage("RhinoScriptEngine.compileScript(): Unexpected " +
          "ScriptException ..", ex.getMessage()));
View Full Code Here

            }
            mvelInputParamTypes.put(CONTEXT_BINDING_NAME, EPLScriptContext.class);
            compiled = MVELHelper.compile(script.getName(), script.getExpression(), mvelInputParamTypes);
        }
        else {
            CompiledScript compiledScript = JSR223Helper.verifyCompileScript(script, dialect);
            compiled = new ExpressionScriptCompiledJSR223(compiledScript);
        }
        script.setCompiled(compiled);
    }
View Full Code Here

            Compilable compilable = (Compilable) engine;
            Bindings bindings = engine.createBindings();
            bindings.put("invokers", invokersCopy);
            bindings.put("invocation", invocation);
            bindings.put("context", RpcContext.getContext());
            CompiledScript function = compilable.compile(rule);
            Object obj = function.eval(bindings);
            if (obj instanceof Invoker[]) {
                invokersCopy = Arrays.asList((Invoker<T>[]) obj);
            } else if (obj instanceof Object[]) {
                invokersCopy = new ArrayList<Invoker<T>>();
                for (Object inv : (Object[]) obj) {
View Full Code Here

            Compilable compilable = (Compilable) engine;
            Bindings bindings = engine.createBindings();
            bindings.put("invokers", invokersCopy);
            bindings.put("invocation", invocation);
            bindings.put("context", RpcContext.getContext());
            CompiledScript function = compilable.compile(rule);
            Object obj = function.eval(bindings);
            if (obj instanceof Invoker[]) {
                invokersCopy = Arrays.asList((Invoker<T>[]) obj);
            } else if (obj instanceof Object[]) {
                invokersCopy = new ArrayList<Invoker<T>>();
                for (Object inv : (Object[]) obj) {
View Full Code Here

            }
            mvelInputParamTypes.put(CONTEXT_BINDING_NAME, EPLScriptContext.class);
            compiled = MVELHelper.compile(script.getName(), script.getExpression(), mvelInputParamTypes);
        }
        else {
            CompiledScript compiledScript = JSR223Helper.verifyCompileScript(script, dialect);
            compiled = new ExpressionScriptCompiledJSR223(compiledScript);
        }
        script.setCompiled(compiled);
    }
View Full Code Here

            Compilable compilable = (Compilable) engine;
            Bindings bindings = engine.createBindings();
            bindings.put("invokers", invokersCopy);
            bindings.put("invocation", invocation);
            bindings.put("context", RpcContext.getContext());
            CompiledScript function = compilable.compile(rule);
            Object obj = function.eval(bindings);
            if (obj instanceof Invoker[]) {
                invokersCopy = Arrays.asList((Invoker<T>[]) obj);
            } else if (obj instanceof Object[]) {
                invokersCopy = new ArrayList<Invoker<T>>();
                for (Object inv : (Object[]) obj) {
View Full Code Here

TOP

Related Classes of javax.script.CompiledScript

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.