Package groovy.lang

Examples of groovy.lang.Closure.call()


    }

    private Object callGlobal(final String name, final Object args[], final ScriptContext ctx) {
        Closure closure = globalClosures.get(name);
        if (closure != null) {
            return closure.call(args);
        }
        Object value = ctx.getAttribute(name);
        if (value instanceof Closure) {
            return ((Closure) value).call(args);
        } else {
View Full Code Here


    public final DynamicDispatchActor become(final Closure closure) {
        if (closure != null) {
            final Closure cloned = (Closure) closure.clone();
            cloned.setResolveStrategy(Closure.DELEGATE_FIRST);
            cloned.setDelegate(this);
            cloned.call();
        }
        return this;
    }

    public final void when(final Closure closure) {
View Full Code Here

     */
    final void onMessage(final Object message) {
        if (nextContinuation != null) {
            final Closure closure = nextContinuation;
            nextContinuation = null;
            closure.call(message);
        } else
            throw new IllegalStateException("The actor " + this + " cannot handle the message " + message + ", as it has no registered message handler at the moment.");
        if (nextContinuation == null && !terminatingFlag) {
            if (loopCondition == null || evalLoopCondition()) {
                if (loopCode == null)
View Full Code Here

            final Closure enhancedClosure = enhanceClosure(closure);
            this.loopClosure = enhancedClosure;

            assert nextContinuation == null;
            while (!terminatingFlag && nextContinuation == null && (loopCondition == null || evalLoopCondition())) {
                enhancedClosure.call();
            }
            if (!terminatingFlag && nextContinuation == null && afterLoopCode != null) {
                runAfterLoopCode(afterLoopCode);
            }
        } else {
View Full Code Here

            final Runnable startCode = loopCode;
            loopCode = null;
            if (startCode != null) {
                if (startCode instanceof Closure) {
                    final Closure closure = enhanceClosure((Closure) startCode);
                    closure.call();
                } else {
                    startCode.run();
                }
            } else act();
            if (nextContinuation == null) terminate();
View Full Code Here

        assert searchable != null;

        // Build user-defined specific mappings
        Closure closure = (Closure) searchable.clone();
        closure.setDelegate(this);
        closure.call();

        buildMappingFromOnlyExcept(grailsDomainClass, inheritedProperties);
    }

    public void buildHashMapMapping(LinkedHashMap map, GrailsDomainClass domainClass, Set<String> inheritedProperties) {
View Full Code Here

        initialize(new Closure(this) {
            private static final long serialVersionUID = 4092639210342260198L;

            @Override
            public Object call(final Object arguments) {
                ReactiveActor.this.replyIfExists(cloned.call(new Object[]{arguments}));
                return null;
            }
        });
    }
}
View Full Code Here

    public File getOutputFile() {
        if (outputFile instanceof File) {
            return (File) outputFile;
        } else if (outputFile instanceof Closure) {
            Closure c = (Closure) outputFile;
            return (File) c.call();
        }

        assert false;
        return null;
    }
View Full Code Here

          constructorArgs = resolveConstructorArguments(args, 0, index);
        }
      }
      this.currentBeanDefinition = new GroovyBeanDefinitionWrapper(null, type, constructorArgs);
      if (callable != null) {
        callable.call(this.currentBeanDefinition);
      }
      return this.currentBeanDefinition.getBeanDefinition();

    }
    finally {
View Full Code Here

    if (hasClosureArgument) {
      Closure callable = (Closure)args[args.length-1];
      callable.setDelegate(this);
      callable.setResolveStrategy(Closure.DELEGATE_FIRST);
      callable.call(new Object[]{currentBeanDefinition});
    }

    GroovyBeanDefinitionWrapper beanDefinition = currentBeanDefinition;
    this.currentBeanDefinition = null;
    beanDefinition.getBeanDefinition().setAttribute(GroovyBeanDefinitionWrapper.class.getName(), beanDefinition);
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.