Package groovy.lang

Examples of groovy.lang.GroovyShell


            }
        }
    }

    private Script constructScriptInstance(String scriptText) {
        GroovyShell shell = new GroovyShell(Thread.currentThread().getContextClassLoader());
        return shell.parse(scriptText);
    }
View Full Code Here


      Binding binding = new Binding();
      binding.setVariable("filename", filename);
      binding.setVariable("message", message);

      // Create a shell and evaluate
      GroovyShell shell = new GroovyShell(Thread.currentThread().getContextClassLoader(),
          binding);
      Object result = shell.evaluate(script);
      if (!(result instanceof String)) {
        throw new RuntimeException(
            "Groovy script should return a String indicating processed filename");
      }
      return (String) result;
View Full Code Here

        scriptPath = mapToPrebundledScript(scriptPath);
        if(scriptPath == null) {
            throw new ConfigurationException("No Groovy script specified on listener config " + config.getAttribute("name"));
        } else {
            try {
                GroovyShell shell = new GroovyShell();
                script = shell.parse(GroovyActionProcessor.getScriptFromClasspath(scriptPath));
            } catch (Exception e) {
                throw new ConfigurationException("Error loading Groovy script '" + scriptPath + "' stream.", e);
            }
        }
    }
View Full Code Here

            Debug.logVerbose("Evaluating -- " + expression, module);
        if (Debug.verboseOn())
            Debug.logVerbose("Using Context -- " + context, module);

        try {
            GroovyShell shell = new GroovyShell(getBinding(context));
            o = shell.evaluate(expression);

            if (Debug.verboseOn())
                Debug.logVerbose("Evaluated to -- " + o, module);

            // read back the context info
            Binding binding = shell.getContext();
            context.putAll(binding.getVariables());

        } catch (CompilationFailedException e) {
            Debug.logError(e, "Groovy Evaluation error.", module);
            throw e;
View Full Code Here

        logger.debug("evaluating script");
       
        try
        {
            logger.debug("creating Groovy shell");
            shell = new GroovyShell();
            logger.trace("shell: " + shell);

            logger.debug("setting script bindings");
            for(String key : pairs.keySet())
            {
View Full Code Here

        // Add some completors to fancy things up
        reader.addCompletor(new CommandNameCompletor());

        if (parent != null) {
            shell = new GroovyShell(parent, binding);
        }
        else {
            shell = new GroovyShell(binding);
        }       

        // Add some default variables to the shell
        Map map = shell.getContext().getVariables();
View Full Code Here

    /**
     * Process Sockets.
     */
    private void processSockets() throws CompilationFailedException, IOException {
        GroovyShell groovy = new GroovyShell(conf);
        //check the script is currently valid before starting a server against the script
        if (isScriptFile) {
            groovy.parse(new FileInputStream(huntForTheScriptFile(script)));
        } else {
            groovy.parse(script);
        }
        new GroovySocketServer(groovy, isScriptFile, script, autoOutput, port);
    }
View Full Code Here

    /**
     * Process the input files.
     */
    private void processFiles() throws CompilationFailedException, IOException {
        GroovyShell groovy = new GroovyShell(conf);

        Script s;

        if (isScriptFile) {
            s = groovy.parse(huntForTheScriptFile(script));
        } else {
            s = groovy.parse(script, "main");
        }

        if (args.isEmpty()) {
            BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
            PrintWriter writer = new PrintWriter(System.out);
View Full Code Here

   
    /**
     * Process the standard, single script with args.
     */
    private void processOnce() throws CompilationFailedException, IOException {
        GroovyShell groovy = new GroovyShell(conf);

        if (isScriptFile) {
            groovy.run(huntForTheScriptFile(script), args);
        }
        else {
            groovy.run(script, "script_from_command_line", args);
        }
    }
View Full Code Here

        final String scriptName = computeScriptName();
        final GroovyClassLoader classLoader = new GroovyClassLoader(baseClassLoader);
        addClassPathes(classLoader);
       
        final GroovyShell groovy = new GroovyShell(classLoader, new Binding(), configuration);
        parseAndRunScript(groovy, txt, mavenPom, scriptName, null, new AntBuilder(this));
    }
View Full Code Here

TOP

Related Classes of groovy.lang.GroovyShell

Copyright © 2018 www.massapicom. 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.