Package groovy.lang

Examples of groovy.lang.Script.run()


    if (file.isExists()) {
      try {
        Class clazz = compiler.parseClass(file.getInputStream());
        if (Script.class.isAssignableFrom(clazz)) {
          Script script = (Script) ReflectionUtil.newInstance(clazz, new Class[] { Binding.class }, ctx.getUI().getDomain());
          return script.run();
        } else {
          ctx.getUI().error("File is not a script: " + filename + ": " + clazz, null);
        }
      } catch (CompilationFailedException e) {
        ctx.getUI().error("Could not compile script", e);
View Full Code Here


    InputStream input = null;
    try {
      Class<Script> clazz = gcl.parseClass(mis.getInputStream());
      Script script = (Script) ReflectionUtil.newInstance(clazz, new Class[0]);
      script.setBinding(this);
      return (T) script.run();
    } catch (CompilationFailedException e) {
      throw ThrowableManagerRegistry.caught(e);
    } catch (IOException e) {
      throw ThrowableManagerRegistry.caught(e);
    } finally {
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

    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(ShellError.SHELL_0004, e.getMessage(), e);
      }
    }
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

        try {
            Class scriptClass = (Class) compiledScript;
            Script scriptObject = (Script) scriptClass.newInstance();
            Binding binding = new Binding(vars);
            scriptObject.setBinding(binding);
            return scriptObject.run();
        } catch (Exception e) {
            throw new ScriptException("failed to execute script", e);
        }
    }
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

    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

    }

    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

                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

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.