Package javax.script

Examples of javax.script.Compilable


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


      if (lib == null)
        lib = "";

      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

            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

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

            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(Config.DEBUG)
    {
      LOG.info("Compiling script: " + file);
    }
   
    Compilable eng = (Compilable) engine;
    FileInputStream fis = null;
   
    BufferedReader buff = null;
    InputStreamReader isr = null;
    CompiledScript cs = null;
   
    try{
     
      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

            CompiledScript cs = _cache.loadCompiledScript(engine, file);
            cs.eval(context);
          }
          else
          {
            Compilable eng = (Compilable) engine;
            CompiledScript cs = eng.compile(lnr);
            cs.eval(context);
          }
        }
        finally
        {
View Full Code Here

  public Object eval(ScriptEngine engine, String script, ScriptContext context) throws ScriptException
  {
    if(engine instanceof Compilable && Config.SCRIPT_ALLOW_COMPILATION)
    {
      Compilable eng = (Compilable) engine;
      CompiledScript cs = eng.compile(script);
      return context != null ? cs.eval(context) : cs.eval();
    }
    return context != null ? engine.eval(script, context) : engine.eval(script);
  }
View Full Code Here

    @SuppressWarnings("unchecked")
    public <T> List<Invoker<T>> route(List<Invoker<T>> invokers, URL url, Invocation invocation) throws RpcException {
        try {
            List<Invoker<T>> invokersCopy = new ArrayList<Invoker<T>>(invokers);
            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>>();
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;
            pickleScript = compilable.compile(PICKLER_SCRIPT);

            writer = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream(), "UTF-8"));
        }
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.