Package groovy.lang

Examples of groovy.lang.Script.run()


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


        gContext.put("delegator", dispatcher.getDelegator());
        try {
            Script script = InvokerHelper.createScript(GroovyUtil.getScriptClassFromLocation(this.getLocation(modelService)), GroovyUtil.getBinding(gContext));
            Object resultObj = null;
            if (UtilValidate.isEmpty(modelService.invoke)) {
                resultObj = script.run();
            } else {
                resultObj = script.invokeMethod(modelService.invoke, EMPTY_ARGS);
            }
            if (resultObj != null && resultObj instanceof Map<?, ?>) {
                return cast(resultObj);
View Full Code Here

        Binding processorBinding = new Binding();
        processorBinding.setVariable("processor", builder);

        script.setBinding(processorBinding);

        script.run();

        return contentHandler.getModuleDescriptor();
    }

    private GroovyShell getGroovyShell()
View Full Code Here

        System.out.println("sruuu");

      }

    });
    script.run();

    String fileName = "src/main/java/Tester.groovy";
    GroovyClassLoader gcl = new GroovyClassLoader();
    Class clazz = gcl.parseClass(new File(fileName));
    Field[] fields = clazz.getFields();
View Full Code Here

    long start = System.currentTimeMillis();
    Script script = shell.parse("x = 123; return foo * 10");
    MetaClass metaClass = script.getMetaClass();
    Binding binding2 = script.getBinding();
    for (int i = 0; i < 1000; i++) {
      script.run();
    }
    long end = System.currentTimeMillis() - start;
    System.out.println("Parsowenie " + end);

    start = System.currentTimeMillis();
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 static Object runScriptAtLocation(String location, String methodName, Map<String, Object> context, GroovyClassLoader groovyClassLoader) throws GeneralException {
        Script script = InvokerHelper.createScript(getScriptClassFromLocation(location, groovyClassLoader), getBinding(context));
        Object result = null;
        if (UtilValidate.isEmpty(methodName)) {
            result = script.run();
        } else {
            result = script.invokeMethod(methodName, new Object[] { context });
        }
        return result;
    }
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

            binding.setVariable("payloadProxy", payloadProxy);
            binding.setVariable("logger", logger);

            execScript.setBinding(binding);

            Object returnVal = execScript.run();

            if(returnVal instanceof Message) {
                return (Message) returnVal;
            } else {
                return message;
View Full Code Here

    String script = imports.toString() + StringUtil.join(commandInfo, ' ');
    try {
      Class clazz = compiler.parseClass(script);
      if (Script.class.isAssignableFrom(clazz)) {
        Script scriptClass = (Script) ReflectionUtil.newInstance(clazz, new Class[] { Binding.class }, ctx.getUI().domain);
        return scriptClass.run();
      } else {
        ctx.getUI().info("Class created: " + clazz);
      }
    } catch (Throwable e) {
      ctx.getUI().error("Error executing: " + script, e);
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.