Examples of GroovyShell


Examples of com.dotcms.repackage.groovy.lang.GroovyShell

       */
      public void initialize(BSFManager mgr, String lang, Vector declaredBeans) throws BSFException {
          super.initialize(mgr, lang, declaredBeans);

          // create a shell
          shell = new GroovyShell(mgr.getClassLoader());
//          shell.
          // register the mgr with object name "bsf"
          shell.setVariable("bsf", new BSFFunctions(mgr, this));

          int size = declaredBeans.size();
View Full Code Here

Examples of groovy.lang.GroovyShell

        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

        final Console console = new Console(Console.class.getClassLoader());
        console.setBeforeExecution(new Closure(null) {
          public void doCall() {
            console.setShell(new GroovyShell(Console.class.getClassLoader(), new Binding()) {
              public Object run(String scriptText, String fileName, String[] args) throws org.codehaus.groovy.control.CompilationFailedException {
                return super.run(IMPORTS + scriptText, fileName, args);
              };
            });
          }
View Full Code Here

Examples of groovy.lang.GroovyShell

                log.log( Level.INFO, "Executing script: " + request.getUrl() );
            }
            Binding binding = createScriptContext(request, response);

            try {
                GroovyShell shell = new GroovyShell( binding );
                File groovyScript = Http.translatePath( groovyDir, request.getUrl() );
                if( groovyScript.exists() ) {
                    shell.evaluate( groovyScript.getAbsolutePath() );
                } else {
                    response.sendError( HttpURLConnection.HTTP_NOT_FOUND, request.getUrl() + " not found.");
                }
            } catch (ClassNotFoundException e) {
                log.log( Level.SEVERE, e.getMessage(), e );
View Full Code Here

Examples of groovy.lang.GroovyShell

    /**
     * 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(DefaultGroovyMethods.getText(huntForTheScriptFile(script)));
        } else {
            groovy.parse(script);
        }
        new GroovySocketServer(groovy, isScriptFile, script, autoOutput, port);
    }
View Full Code Here

Examples of groovy.lang.GroovyShell

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

Examples of groovy.lang.GroovyShell

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

Examples of groovy.lang.GroovyShell

    if (args != null) {
      groovyBinding.setVariable("args", args.toArray(new String[args.size()]));
    } else {
      groovyBinding.setVariable("args", new String[0]);
    }
    final GroovyShell interp = new GroovyShell(groovyBinding);
    boolean ret = true;

    try {
      final File f = new File(groovyScript);
      interp.evaluate(f);
    } catch (final Exception e) {
      logger.error("Exception while sourcing file " + groovyScript, e);
      setMessage(e.getMessage());
      ret = false;
    } catch (final Error e) {
View Full Code Here

Examples of groovy.lang.GroovyShell

    final int autoclose = MathHelper.parseInt(attributes.get("autoclose"));
   
    ChatCondition condition = null;
    final String condString = attributes.get("condition");
    if (condString != null) {
      final GroovyShell interp = new GroovyShell(new Binding());
      String code = "import games.stendhal.server.entity.npc.condition.*;\r\n"
        + condString;
      try {
        condition = (ChatCondition) interp.evaluate(code);
      } catch (CompilationFailedException e) {
        throw new IllegalArgumentException(e);
      }
    }

View Full Code Here

Examples of groovy.lang.GroovyShell

    String value = ctx.getString("condition", null);
    if (value == null) {
      return null;
    }
    Binding groovyBinding = new Binding();
    final GroovyShell interp = new GroovyShell(groovyBinding);
    try {
      String code = "import games.stendhal.server.entity.npc.condition.*;\r\n"
        + value;
      return (ChatCondition) interp.evaluate(code);
    } catch (CompilationFailedException e) {
      throw new IllegalArgumentException(e);
    }
  }
View Full Code Here

Examples of groovy.lang.GroovyShell

    String value = ctx.getString("action", null);
    if (value == null) {
      return null;
    }
    Binding groovyBinding = new Binding();
    final GroovyShell interp = new GroovyShell(groovyBinding);
    try {
      String code = "import games.stendhal.server.entity.npc.action.*;\r\n"
        + value;
      return (ChatAction) interp.evaluate(code);
    } catch (CompilationFailedException e) {
      throw new IllegalArgumentException(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.