Package org.codehaus.groovy.runtime

Examples of org.codehaus.groovy.runtime.MethodClosure


        MarkupBuilder builder = new MarkupBuilder(output.getWriter());
        builder.setExpandEmptyElements(true);
        super.setVariable("html", builder);
       
        // bind forward method
        MethodClosure c = new MethodClosure(this, "forward");
        super.setVariable("forward", c);
       
        // bind include method
        c = new MethodClosure(this, "include");
        super.setVariable("include", c);
       
        // bind redirect method
        c = new MethodClosure(this, "redirect");
        super.setVariable("redirect", c);
    }
View Full Code Here


    addMethod("pushRoute");
  }
 
  private void addMethod(String name)
  {
    super.setVariable(name, new MethodClosure(this, name));
    _reservedNames.add(name);
  }
View Full Code Here

    private final Binding binding;
    protected GroovyProfile(final WebEngine engine, final Map<String,?> options, final Reader script) {
        super(engine, options);
        binding = new NullBinding();
        binding.setVariable("engine", engine);
        binding.setVariable("js", new MethodClosure(this, "executeJS"));
        binding.setVariable("options", options);
        new GroovyShell(binding).evaluate(script);
    }
View Full Code Here

        try {
            final Script scriptObject = InvokerHelper.createScript(scriptClass, binding);
            Stream.of(scriptClass.getMethods()).forEach(m -> {
                final String name = m.getName();
                globalClosures.put(name, new MethodClosure(scriptObject, name));
            });

            final MetaClass oldMetaClass = scriptObject.getMetaClass();
            scriptObject.setMetaClass(new DelegatingMetaClass(oldMetaClass) {
                @Override
View Full Code Here

  public static void main (String[] args) throws Exception {
    System.setProperty("groovysh.prompt", Constants.SQOOP_PROMPT);
    Groovysh shell = new Groovysh();

    // Install our error hook (exception handling)
    shell.setErrorHook(new MethodClosure(ThrowableDisplayer.class, "errorHook"));

    CommandRegistry registry = shell.getRegistry();
    @SuppressWarnings("unchecked")
    Iterator<Command> iterator = registry.iterator();
    while (iterator.hasNext()) {
View Full Code Here

            final Object owner = closure.getOwner();

            if (CLOSURE_CALL_METHOD.equals(methodName) || CLOSURE_DO_CALL_METHOD.equals(methodName)) {
                final Class objectClass = object.getClass();
                if (objectClass == MethodClosure.class) {
                    final MethodClosure mc = (MethodClosure) object;
                    methodName = mc.getMethod();
                    final Class ownerClass = owner instanceof Class ? (Class) owner : owner.getClass();
                    final MetaClass ownerMetaClass = registry.getMetaClass(ownerClass);
                    return ownerMetaClass.invokeMethod(ownerClass, owner, methodName, arguments, false, false);
                } else if (objectClass == CurriedClosure.class) {
                    final CurriedClosure cc = (CurriedClosure) object;
View Full Code Here

                // create a Map of MethodClosures from this new script object
                Method[] methods = scriptClass.getMethods();
                Map<String, Closure> closures = new HashMap<String, Closure>();
                for (Method m : methods) {
                    String name = m.getName();
                    closures.put(name, new MethodClosure(scriptObject, name));
                }

                // save all current closures into global closures map
                globalClosures.putAll(closures);
View Full Code Here

    System.setProperty("groovysh.prompt", Constants.SQOOP_PROMPT);
    Groovysh shell = new Groovysh();

    // Install our error hook (exception handling)
    shell.setErrorHook(
      new MethodClosure(ThrowableDisplayer.class, "errorHook"));
    ThrowableDisplayer.setIo(shell.getIo());

    CommandRegistry registry = shell.getRegistry();
    @SuppressWarnings("unchecked")
    Iterator<Command> iterator = registry.iterator();
View Full Code Here

                // create a Map of MethodClosures from this new script object
                Method[] methods = scriptClass.getMethods();
                Map<String, Closure> closures = new HashMap<String, Closure>();
                for (Method m : methods) {
                    String name = m.getName();
                    closures.put(name, new MethodClosure(scriptObject, name));
                }

                // save all current closures into global closures map
                globalClosures.putAll(closures);
View Full Code Here

            final Object owner = closure.getOwner();

            if (CLOSURE_CALL_METHOD.equals(methodName) || CLOSURE_DO_CALL_METHOD.equals(methodName)) {
                final Class objectClass = object.getClass();
                if (objectClass == MethodClosure.class) {
                    final MethodClosure mc = (MethodClosure) object;
                    methodName = mc.getMethod();
                    final Class ownerClass = owner instanceof Class ? (Class) owner : owner.getClass();
                    final MetaClass ownerMetaClass = registry.getMetaClass(ownerClass);
                    return ownerMetaClass.invokeMethod(ownerClass, owner, methodName, arguments, false, false);
                } else if (objectClass == CurriedClosure.class) {
                    final CurriedClosure cc = (CurriedClosure) object;
View Full Code Here

TOP

Related Classes of org.codehaus.groovy.runtime.MethodClosure

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.