Package groovy.lang

Examples of groovy.lang.Script.run()


                "\"/first\"(redirect:[controller: 'foo', action: 'bar'])\n" +
                "\"/second\"(redirect: '/bing/bang')\n" +
        "}");

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

        Closure closure = (Closure)binding.getVariable("mappings");
        List<UrlMapping> mappings = evaluator.evaluateMappings(closure);
        assertEquals(2, mappings.size());
        Object redirectInfo = mappings.get(0).getRedirectInfo();
View Full Code Here


                "        }\n" +
                "    }\n" +
                "}\n");

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

        Closure closure = (Closure) binding.getVariable("mappings");
        List mappings = evaluator.evaluateMappings(closure);

        assertEquals(1, mappings.size());
View Full Code Here

        Script script = shell.parse("mappings = {\n" +
                "\"/api/foo\"(resources: 'foo', version: '1.0', namespace: 'v1')\n" +
        "}");

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

        Closure closure = (Closure)binding.getVariable("mappings");
        List<UrlMapping> mappings = evaluator.evaluateMappings(closure);
        assertTrue(mappings.size() > 0);
        //Check that version and namespace are correct for each mapping
View Full Code Here

        if (stream != null) {
            GroovyClassLoader gcl = new GroovyClassLoader();
            try {
                Class<?> scriptClass = gcl.parseClass(IOUtils.toString(stream, "UTF-8"));
                Script script = (Script)scriptClass.newInstance();
                script.run();
                Binding binding = script.getBinding();
                if (binding.getVariables().containsKey(ConstraintsEvaluator.PROPERTY_NAME)) {
                    return (Closure<?>)binding.getVariable(ConstraintsEvaluator.PROPERTY_NAME);
                }
                LOG.warn("Unable to evaluate constraints from [" + constraintsScript + "], constraints closure not found!");
View Full Code Here

                    } catch (MissingMethodException mme) {
                        return callGlobal(name, args, context);
                    }
                }
            });
            return scriptObject.run();
        } catch (Exception e) {
            throw new ScriptException(e);
        }
    }
View Full Code Here

    public Object evaluate(Exchange exchange) {
        Script script = ExchangeHelper.newInstance(exchange, scriptType);
        // lets configure the script
        configure(exchange, script);
        return script.run();
    }

    private void configure(Exchange exchange, Script script) {
        final Binding binding = script.getBinding();
        ExchangeHelper.populateVariableMap(exchange, new AbstractMap<String, Object>() {
View Full Code Here

    public Object evaluate(Exchange exchange) {
        Script script = ExchangeHelper.newInstance(exchange, scriptType);
        // lets configure the script
        configure(exchange, script);
        return script.run();
    }

    private void configure(Exchange exchange, Script script) {
        final Binding binding = script.getBinding();
        ExchangeHelper.populateVariableMap(exchange, new AbstractMap<String, Object>() {
View Full Code Here

        try {
            final GroovyContext effective = getEffectiveContext(groovyCtx);
            effective.setEvaluatingLocation(true);
            boolean inGlobalContext = groovyCtx.getParent() instanceof SCXMLSystemContext;
            Script script = getScript(effective, groovyCtx.getScriptBaseClass(), scriptSource);
            Object result = script.run();
            if (inGlobalContext && useInitialScriptAsBaseScript) {
                groovyCtx.setScriptBaseClass(script.getClass().getName());
            }
            return result;
        } catch (Exception e) {
View Full Code Here

    }

    protected void executeScript(Class scriptClass, Permission missingPermission) {
        try {
            Script script = InvokerHelper.createScript(scriptClass, new Binding());
            script.run();
            //InvokerHelper.runScript(scriptClass, null);
        } catch (AccessControlException ace) {
            if (missingPermission != null && missingPermission.implies(ace.getPermission())) {
                return;
            } else {
View Full Code Here

                    final boolean completed [] = new boolean[2] ;
                    Thread thread1 = new Thread() {
                        public void run() {
                            try {
                                Script script = (Script) script1Class.newInstance();
                                script.run();
                                completed [0] = true;
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
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.