Package groovy.lang

Examples of groovy.lang.Script.run()


    //
    Script script = InvokerHelper.createScript(scriptClass, binding);

    //
    try {
      script.run();
    }
    catch (Exception e) {
      if (e instanceof IOException) {
        throw (IOException)e;
      }
View Full Code Here


        script = shell.parse((String) o);
      }
      if (null != script && null != var) {
        binding.setVariable(var, script);
      }
      return script.run();
    } catch (Throwable t) {
      // Doesn't do much good to dispatch into a script that has a syntax error, so...
      t.printStackTrace();
    }
    return null;
View Full Code Here

          else
            binding = new Binding(map);
          Script scriptObject = InvokerHelper.createScript(script.getClass(), binding);
          PrintWriter pw = new PrintWriter(writer);
          scriptObject.setProperty("out", pw);
          scriptObject.run();
          pw.flush();
          return writer;
        }

        /**
 
View Full Code Here

  public Map<String, Object> getParameters() {
    CompilerConfiguration config = new CompilerConfiguration();
    config.setScriptBaseClass(SimulationScript.class.getName());
    GroovyShell shell = new GroovyShell(config);
    Script script = shell.parse(new StringReader(_script));
    script.run();
    return script.getBinding().getVariables();
  }

  public MutableFudgeMsg toFudgeMsg(final FudgeSerializer serializer) {
    MutableFudgeMsg msg = serializer.newMessage();
View Full Code Here

    config.addCompilationCustomizers(customizer);
    config.setScriptBaseClass(SimulationScript.class.getName());
    Binding binding = new Binding(parameters);
    GroovyShell shell = new GroovyShell(binding, config);
    Script script = shell.parse(scriptReader);
    Object scriptOutput = script.run();
    if (scriptOutput == null) {
      throw new IllegalArgumentException("Script " + scriptReader + " didn't return an object");
    }
    if (expectedType.isInstance(scriptOutput)) {
      return expectedType.cast(scriptOutput);
View Full Code Here

          else
            binding = new Binding(map);
          Script scriptObject = InvokerHelper.createScript(script.getClass(), binding);
          PrintWriter pw = new PrintWriter(writer);
          scriptObject.setProperty("out", pw);
          scriptObject.run();
          pw.flush();
          return writer;
        }

        /**
 
View Full Code Here

      varProducer.fill(groovyScript);

      groovyScript.setProperty("monitor", monitor);

      groovyScript.run();
    } catch (RuntimeException e) {
      StringWriter stringWriter = new StringWriter();
      PrintWriter printWriter = new PrintWriter(stringWriter);
      e.printStackTrace(printWriter);
      monitor.println(stringWriter.toString());
View Full Code Here

            script.setProperty("properties", new AntProjectPropertiesDelegate(project));
            script.setProperty("target", task.getOwningTarget());
            script.setProperty("task", this);
            script.setProperty("args", task.getCommandLine().getCommandline());
            script.setProperty("pom", task.getBuild().getPom());
            script.run();
        }
        catch (final MissingMethodException mme) {
            // not a script, try running through run method but properties will not be available
            if (scriptFile != null) {
                try {
View Full Code Here

    public <T> T evaluate(Exchange exchange, Class<T> type) {
        Script script = ExchangeHelper.newInstance(exchange, scriptType);
        // lets configure the script
        configure(exchange, script);
        Object value = script.run();
        return exchange.getContext().getTypeConverter().convertTo(type, value);
    }

    private void configure(Exchange exchange, Script script) {
        final Binding binding = script.getBinding();
View Full Code Here

            Map<String, Object> allVars = new HashMap<>();
            if (vars != null) {
                allVars.putAll(vars);
            }
            Script scriptObject = createScript(compiledScript, allVars);
            return scriptObject.run();
        } catch (Exception e) {
            throw new ScriptException("failed to execute script", e);
        }
    }
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.