Package groovy.lang

Examples of groovy.lang.Script


   * {@inheritDoc}
   */
  @Override
  public WroModel create() {
    final StopWatch stopWatch = new StopWatch("Create Wro Model from Groovy");
    final Script script;
    try {
      stopWatch.start("parseStream");
      script = new GroovyShell().parse(new InputStreamReader(getModelResourceAsStream()));
      LOG.debug("Parsing groovy script to build the model");
      stopWatch.stop();
View Full Code Here


  public GroovyResult execute(final String script, final Map<String, Object> variables)
  {
    if (script == null) {
      return new GroovyResult();
    }
    final Script groovyObject = compileGroovy(script, true);
    if (groovyObject == null) {
      return new GroovyResult();
    }
    return execute(groovyObject, variables);
  }
View Full Code Here

  public GroovyResult execute(final GroovyResult result, final String script, final Map<String, Object> variables)
  {
    if (script == null) {
      return result;
    }
    final Script groovyObject = compileGroovy(result, script, true);
    if (groovyObject == null) {
      return result;
    }
    return execute(result, groovyObject, variables);
  }
View Full Code Here

      if (result != null) {
        result.setException(ex);
      }
      return null;
    }
    Script groovyObject = null;
    try {
      groovyObject = (Script) groovyClass.newInstance();
    } catch (final InstantiationException ex) {
      log.error(ex.getMessage(), ex);
      if (result != null) {
        result.setException(ex);
      }
      return null;
    } catch (final IllegalAccessException ex) {
      log.error(ex.getMessage(), ex);
      if (result != null) {
        result.setException(ex);
      }
      return null;
    }
    if (bindScriptResult == true) {
      final Binding binding = groovyObject.getBinding();
      final GroovyResult scriptResult = new GroovyResult();
      binding.setVariable("scriptResult", scriptResult);
    }
    return groovyObject;
  }
View Full Code Here

  {
    if (accountRecordsExist == true) {
      // Nothing to do.
      return;
    }
    final Script groovyScript = config.getValueScript();
    if (groovyScript == null) {
      // Nothing to do.
      return;
    }
    amount = BigDecimal.ZERO;
View Full Code Here

        CpsStepContext cps = (CpsStepContext) getContext();
        CpsThread t = CpsThread.current();

        GroovyShell shell = t.getExecution().getShell();

        Script script = shell.parse(cwd.child(step.getPath()).readToString());

        node.addAction(new LabelAction("Loaded script: "+step.getPath()));

        // execute body as another thread that shares the same head as this thread
        // as the body can pause.
View Full Code Here

     * When loading additional scripts, we need to remember its source text so that
     * when we come back from persistent we can load them again.
     */
    @Override
    public Script parse(GroovyCodeSource codeSource) throws CompilationFailedException {
        Script s = super.parse(codeSource);
        if (execution!=null)
            execution.loadedScripts.put(s.getClass().getName(), codeSource.getScriptText());
        prepareScript(s);
        return s;
    }
View Full Code Here

            {
                jd.setTerminatedWithError(false);
            }
            Binding binding = new Binding((Map) jobData.get(SchedulerConsts.CONFIG_JOB_PARAMS));
            GroovyShell shell = new GroovyShell(binding);
            Script script = shell.parse(groovyScript);
            retVal = script.run();
            log.info("job [{}] executed successfully , Groovy script returned {}", new Object[]{jobName, retVal });
        }
        catch (CompilationFailedException e)
        {
            log.error("An error occurred while parsing the script. Error message is {}", new Object[]{e.getMessage() });
View Full Code Here

    @Override
    public void execute(DbStep step)
    {
        LOG.info("[GROOVY STEP]:" + step.getName() + " (" + step.getVersion() + ")");
        Reader scriptReader = step.getStepReader();
        Script s = shell.parse(scriptReader);
        s.invokeMethod(GROOVY_DBMAIN, new Object[] {dataSource, variables} );
    }
View Full Code Here

     *
     * @since 1.0
     */
    public Object run(final Loader loader, final Source source, final Binding binding)
            throws CompileException, LoadException, CreateException {
        Script script = create(loader, source);
        script.setBinding(binding);
        return script.run();
    }
View Full Code Here

TOP

Related Classes of groovy.lang.Script

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.