Package groovy.lang

Examples of groovy.lang.GroovyShell.evaluate()


  public Object execute(final String script) throws Exception {

    final GroovyShell shell = new GroovyShell(binding());

    final Object result = shell.evaluate(script);

    return result;

  }
View Full Code Here


    public static void main(String[] args) throws IOException {
        File baseDir = new File(args[0]);
        Binding binding = new Binding();
        binding.setVariable("basedir", baseDir);
        GroovyShell shell = new GroovyShell(binding);
        shell.evaluate(new File(baseDir, "verify.groovy"));
    }
}
View Full Code Here

        try
        {
            Binding binding = new Binding();
            GroovyShell shell = new GroovyShell(binding);

            String result = (String) shell.evaluate(
                    getContent(controllerState));
            return new OutletResult(result);
        }
        finally
        {
View Full Code Here

    GroovyShell groovyShell = new GroovyShell(this.classLoader, new Binding(arguments));
    try {
      String filename = (script instanceof ResourceScriptSource ?
          ((ResourceScriptSource) script).getResource().getFilename() : null);
      if (filename != null) {
        return groovyShell.evaluate(script.getScriptAsString(), filename);
      }
      else {
        return groovyShell.evaluate(script.getScriptAsString());
      }
    }
View Full Code Here

          ((ResourceScriptSource) script).getResource().getFilename() : null);
      if (filename != null) {
        return groovyShell.evaluate(script.getScriptAsString(), filename);
      }
      else {
        return groovyShell.evaluate(script.getScriptAsString());
      }
    }
    catch (IOException ex) {
      throw new ScriptCompilationException(script, "Cannot access script", ex);
    }
View Full Code Here

    binding.setVariable("beans", beans);

    int countBefore = getRegistry().getBeanDefinitionCount();
    try {
      GroovyShell shell = new GroovyShell(getResourceLoader().getClassLoader(), binding);
      shell.evaluate(encodedResource.getReader(), encodedResource.getResource().getFilename());
    }
    catch (Throwable ex) {
      throw new BeanDefinitionParsingException(new Problem("Error evaluating Groovy script: " + ex.getMessage(),
          new Location(encodedResource.getResource()), null, ex));
    }
View Full Code Here

                if (refCube == null)
                {
                    throw new IllegalStateException("Reference to not-loaded NCube '" + cubeName + "', from NCube '" + ncube.getName() + "', url: " + url);
                }

                Map coord = (Map) shell.evaluate(m.group(3));
                input.putAll(coord);
                Object val = refCube.getCell(input);
                val = (val == null) ? "" : val.toString();
                expandedUrl.append(val);
                last = m.end();
View Full Code Here

    }

    private void init() {
        ClassLoader loader = getClass().getClassLoader();
        GroovyShell shell = new GroovyShell(loader);
        shell.evaluate(loader.getResourceAsStream("org/apache/camel/language/groovy/ConfigureCamel.groovy"));

        // TODO compile Groovy as part of build!
        //new ConfigureCamel().run();
    }
}
View Full Code Here

public class SeansBug extends TestSupport {

    public void testBug() throws Exception {
        String code = "for (i in 1..10) \n{\n  println(i)\n}";
        GroovyShell shell = new GroovyShell();
        shell.evaluate(code);
    }

    public void testMarkupBug() throws Exception {
        String[] lines =
                {
View Full Code Here

                        "    elem2('hello2') ",
                        "    elem3(x:7) ",
                        "}"};
        String code = asCode(lines);
        GroovyShell shell = new GroovyShell();
        shell.evaluate(code);
    }

    /**
     * Converts the array of lines of text into one string with newlines
     */
 
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.