Package groovy.lang

Examples of groovy.lang.Binding


    boolean
    setup(RewriteContext hr) {
  if (interp == null) {
      try {
    binding = new Binding();
    interp = new GroovyShell(binding);
      } catch (NoClassDefFoundError e) {
    hr.request.log(Server.LOG_ERROR, hr.prefix,
      "Missing Groovy libraries" + e);
    return false;
View Full Code Here


   * @param args
   * @throws Exception
   * @throws InstantiationException
   */
  public static void main(final String[] args) throws InstantiationException, Exception {
    Binding binding = new Binding();
    binding.setVariable("foo", new Integer(2));
    GroovyShell shell = new GroovyShell(binding);
    Script script = shell.parse("service.with{sru()} ;x = 123; return foo * 10;");
    MetaClass metaClass = script.getMetaClass();
    Binding binding2 = script.getBinding();
    // Object property = script.getProperty("service");
    script.setProperty("service", new CustomerService() {

      @Override
      public void sru() {
View Full Code Here

  /**
   * @param args
   */
  public static void main(final String[] args) {
    Binding binding = new Binding();
    binding.setVariable("foo", new Integer(2));
    GroovyShell shell = new GroovyShell(binding);
    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);
View Full Code Here

   */
  public static void main(final String[] args) throws Exception {
    GroovyScriptEngine gse = new GroovyScriptEngine("src/main/java");
    long start = System.currentTimeMillis();
    for (int i = 0; i < 1; i++) {
      Binding binding = new Binding();
      binding.setVariable("foo", new Integer(123));
      gse.run("test.groovy", binding);
      // System.out.println(binding.getVariable("output"));
    }
    long end = System.currentTimeMillis() - start;
    System.out.println("Engine " + end);
View Full Code Here

         if (object != null)
            return (T)object;
         ResourceResolver resolver = context.getResourceResolver(value);
         InputStream is = resolver.getInputStream(value);
         //TODO if is == null throw an exception saying the it's impossible to find the file
         Binding binding = new Binding();
         GroovyShell shell = new GroovyShell(Thread.currentThread().getContextClassLoader(), binding);
         object = shell.evaluate(is);
         is.close();
         return (T)object;
      }
View Full Code Here

   {
      try
      {
         ResourceResolver resolver = context.getResourceResolver(value);
         InputStream is = resolver.getInputStream(value);
         Binding binding = new Binding();
         GroovyShell shell = new GroovyShell(Thread.currentThread().getContextClassLoader(), binding);
         object = shell.evaluate(is);
         is.close();
         return (T)object;
      }
View Full Code Here

        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>() {
            @Override
            public Object put(String key, Object value) {
                binding.setProperty(key, value);
                return null;
            }

            public Set entrySet() {
                return Collections.EMPTY_SET;
View Full Code Here

    }

    public abstract void launch();

    protected Binding createBinding() {
        return new Binding(bindings);
    }
View Full Code Here

            o = shell.evaluate(StringUtil.convertOperatorSubstitutions(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;
        }
        return o;
View Full Code Here

                if (scriptHelper != null) {
                    vars.put(ScriptUtil.SCRIPT_HELPER_KEY, scriptHelper);
                }
            }
        }
        return new Binding(vars);
    }
View Full Code Here

TOP

Related Classes of groovy.lang.Binding

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.