Package groovy.lang

Examples of groovy.lang.GroovyShell.evaluate()


      shell = new GroovyShell();
    } else {
      shell = new GroovyShell(bind);
    }
    // execute the script
    Object value = shell.evaluate(script);
    result = value.toString();
    // return the result
    return result;
  }
View Full Code Here


        InputStream inputStream = null;
        try
        {
            inputStream = script.getInputStream();
            shell.evaluate(IOUtils.toString(inputStream));
            Validate.isTrue(!connection.isClosed(), "JDBC Connection should not be closed.");
        }
        catch (IOException e)
        {
            throw new MigrationException(e);
View Full Code Here

    public void begin_scenario(Scenario scenario) throws IOException {
        clearHooksAndStepDefinitions();
        worldFactory = null;
        GroovyShell shell = new GroovyShell(new Binding());
        for (String groovyFile : groovyFiles) {
            shell.evaluate(new File(groovyFile));
        }
        currentWorld = worldFactory == null ? new Object() : worldFactory.call();
    }

    public void end_scenario() {
View Full Code Here

        b.setVariable("beans", beans);

        for (Resource resource : resources) {
            try {
                GroovyShell shell = classLoader == null ? new GroovyShell(b) : new GroovyShell(classLoader, b);
                shell.evaluate(new InputStreamReader(resource.getInputStream(), "UTF-8"));
            }
            catch (Throwable e) {
                throw new BeanDefinitionParsingException(
                        new Problem("Error evaluating bean definition script: " + e.getMessage(), new Location(resource), null, e));
            }
View Full Code Here

            GroovyShell shell = new GroovyShell( binding );
            InputStream is = null;
            try
            {
                is = groovySource.openStream();
                return shell.evaluate( new InputStreamReader( is ) );
            }
            finally
            {
                if( is != null )
                {
View Full Code Here

public class DefaultScriptingImpl implements Scripting {
    @Override
    public <T> T evaluateGroovy(String script, Map<String, Object> params) {
        Binding binding = new Binding(params);
        GroovyShell shell = new GroovyShell(Thread.currentThread().getContextClassLoader(), binding);
        return (T) shell.evaluate(script);
    }
}
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


    @SuppressWarnings("unchecked")
    public Map<String, Object> execute(String script, Binding binding) {
        GroovyShell shell = new GroovyShell(getClass().getClassLoader(), binding);
        shell.evaluate(script);
        return binding.getVariables();
    }


    private <V> List<Object> invokeWithClosure(Class<?> clz, List<String> attributes, Closure<V> callable) {
View Full Code Here

        Binding binding = new Binding();
        binding.setVariable( "env", System.getenv() );
        binding.setVariable( "sys", System.getProperties() );
        CompilerConfiguration config = new CompilerConfiguration();
        GroovyShell shell = new GroovyShell( binding, config );
        Object result = shell.evaluate( "return \"" + expression + "\"" );
        if ( result == null )
        {
            return "";
        }
        else
View Full Code Here

  public Object execute(final File script) throws Exception {

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

    final Object result = shell.evaluate(script);

    return result;

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