Examples of MethodClosure


Examples of org.codehaus.groovy.runtime.MethodClosure

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

Examples of org.codehaus.groovy.runtime.MethodClosure

    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

Examples of org.codehaus.groovy.runtime.MethodClosure

        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

Examples of org.codehaus.groovy.runtime.MethodClosure

  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

Examples of org.codehaus.groovy.runtime.MethodClosure

            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

Examples of org.codehaus.groovy.runtime.MethodClosure

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

Examples of org.codehaus.groovy.runtime.MethodClosure

    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

Examples of org.codehaus.groovy.runtime.MethodClosure

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

Examples of org.codehaus.groovy.runtime.MethodClosure

            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

Examples of org.codehaus.groovy.runtime.MethodClosure

import org.codehaus.groovy.runtime.MethodClosure;

public class Groovy4104A {
    public MethodClosure createMethodClosure() {
        return new MethodClosure(this, "someMethod");
    }
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.