Package org.kohsuke.stapler.jelly.groovy
Class GroovyClosureScript
java.lang.Object
groovy.lang.GroovyObjectSupport
groovy.lang.Script
org.kohsuke.stapler.jelly.groovy.GroovyClosureScript
- All Implemented Interfaces:
groovy.lang.GroovyObject
- Direct Known Subclasses:
StaplerClosureScript
public abstract class GroovyClosureScript
extends groovy.lang.Script
Script that performs method invocations and property access like Closure does.
For example, when the script is:
a = 1;
b(2);
Using GroovyClosureScript as the base class would run it as:
delegate.a = 1;
delegate.b(2);
... whereas in plain Script, this will be run as:
binding.setProperty("a",1);
((Closure)binding.getProperty("b")).call(2);
This is convenient for building DSL as you can use an external object to define
methods and properties.- Author:
- Kohsuke Kawaguchi
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedprotectedGroovyClosureScript(groovy.lang.Binding binding) -
Method Summary
Modifier and TypeMethodDescriptiongroovy.lang.GroovyObjectgetProperty(String property) invokeMethod(String name, Object args) voidsetDelegate(groovy.lang.GroovyObject delegate) Sets the delegation target.voidsetProperty(String property, Object newValue) Methods inherited from class groovy.lang.Script
evaluate, evaluate, getBinding, print, printf, printf, println, println, run, run, setBindingMethods inherited from class groovy.lang.GroovyObjectSupport
getMetaClass, setMetaClass
-
Constructor Details
-
GroovyClosureScript
protected GroovyClosureScript() -
GroovyClosureScript
protected GroovyClosureScript(groovy.lang.Binding binding)
-
-
Method Details
-
setDelegate
public void setDelegate(groovy.lang.GroovyObject delegate) Sets the delegation target. -
getDelegate
public groovy.lang.GroovyObject getDelegate() -
invokeMethod
- Specified by:
invokeMethodin interfacegroovy.lang.GroovyObject- Overrides:
invokeMethodin classgroovy.lang.Script
-
getProperty
- Specified by:
getPropertyin interfacegroovy.lang.GroovyObject- Overrides:
getPropertyin classgroovy.lang.Script
-
setProperty
- Specified by:
setPropertyin interfacegroovy.lang.GroovyObject- Overrides:
setPropertyin classgroovy.lang.Script
-