Package groovy.lang

Examples of groovy.lang.Script.run()


     */
    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


    }

    public <T> T evaluate(Exchange exchange, Class<T> type) {
        Script script = instantiateScript(exchange);
        script.setBinding(createBinding(exchange));
        Object value = script.run();

        return exchange.getContext().getTypeConverter().convertTo(type, value);
    }

    @SuppressWarnings("unchecked")
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

    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

    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

            script.setProperty("task", this);
            script.setProperty("args", cmdline.getCommandline());
            if (mavenPom != null) {
                script.setProperty("pom", mavenPom);
            }
            script.run();
        }
        catch (final MissingMethodException e) {
            // not a script, try running through run method but properties will not be available
            groovy.run(txt, scriptName, cmdline.getCommandline());
        }
View Full Code Here

                LOG.fine("eval() - Using cached script...");
            }
            //can't cache the script because the context may be different.
            //but don't bother loading parsing the class again
            Script s = InvokerHelper.createScript(scriptClass, context);
            return s.run();
        } catch (Exception e) {
            throw new BSFException(BSFException.REASON_EXECUTION_ERROR, "exception from Groovy: " + e, e);
        }
    }
View Full Code Here

            MappingCapturingClosure closure = new MappingCapturingClosure(script);
            b.setVariable("mappings", closure);
            script.setBinding(b);

            script.run();

            Closure mappings = closure.getMappings();

            Binding binding = script.getBinding();
            return evaluateMappings(script, mappings, binding);
View Full Code Here

        springGroovyResourcesBeanBuilder = new BeanBuilder(null, config,Thread.currentThread().getContextClassLoader());
        springGroovyResourcesBeanBuilder.setBinding(new Binding(CollectionUtils.newMap(
            "application", application,
            "grailsApplication", application))); // GRAILS-7550
        Script script = (Script) groovySpringResourcesClass.newInstance();
        script.run();
        Object beans = script.getProperty("beans");
        springGroovyResourcesBeanBuilder.beans((Closure<?>)beans);
        return springGroovyResourcesBeanBuilder;
    }
View Full Code Here

                "name thirdMapping: \"/third/one\" {\n" +
                "}\n" +
        "}");

        script.setBinding(binding);
        script.run();

        Closure closure = (Closure)binding.getVariable("mappings");
        List mappings = evaluator.evaluateMappings(closure);
        assertEquals(3, mappings.size());
    }
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.