Package groovy.lang

Examples of groovy.lang.Script.run()


                    Thread thread2 = new Thread() {
                        public void run() {
                            try {
                                Class cls = groovyLoader.loadClass("Script2", true, true);
                                Script script = (Script) cls.newInstance();
                                script.run();
                                completed [1] = true;
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
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

            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

                            return callGlobal(name, args, ctx);
                        }
                    }
                });

                return scriptObject.run();
            }
        } catch (Exception e) {
            throw new ScriptException(e);
        } finally {
            // Fix for GROOVY-3669: Can't use several times the same JSR-223 ScriptContext for different groovy script
View Full Code Here

        public Writer writeTo(Writer out) {
            Script scriptObject = InvokerHelper.createScript(script.getClass(), binding);
            PrintWriter pw = new PrintWriter(out);
            scriptObject.setProperty("out", pw);
            scriptObject.run();
            pw.flush();
            return out;
        }

        public String toString() {
View Full Code Here

                jd.setTerminatedWithError(false);
            }
            Binding binding = new Binding((Map) jobData.get(SchedulerConsts.CONFIG_JOB_PARAMS));
            GroovyShell shell = new GroovyShell(binding);
            Script script = shell.parse(groovyScript);
            retVal = script.run();
            log.info("job [{}] executed successfully , Groovy script returned {}", new Object[]{jobName, retVal });
        }
        catch (CompilationFailedException e)
        {
            log.error("An error occurred while parsing the script. Error message is {}", new Object[]{e.getMessage() });
View Full Code Here

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

    List temp = new ArrayList();
    GroovyShell gs = new GroovyShell(getBinding());
    for(Object obj:arg) {
      Script scr = gs.parse("\""+(String)obj+"\"");
      try {
        temp.add(scr.run().toString());
      }
      catch(MissingPropertyException e) {
        throw new SqoopException(ClientError.CLIENT_0004, e.getMessage(), e);
      }
    }
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 mme) {
            // not a script, try running through run method but properties will not be available
            if (scriptFile != null) {
                try {
View Full Code Here

    ClassLoader previousContextClassLoader = Thread.currentThread().getContextClassLoader();
    try {
      Thread.currentThread().setContextClassLoader(groovyShell.getClassLoader());
      fixture.setup();
      try {
        script.run();
      } finally {
        fixture.cleanup();
      }
    } finally {
      Thread.currentThread().setContextClassLoader(previousContextClassLoader);
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.