org.kohsuke.stapler.jelly.groovy
Class GroovyClosureScript

java.lang.Object
  extended by groovy.lang.GroovyObjectSupport
      extended by groovy.lang.Script
          extended by 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
protected GroovyClosureScript()
           
protected GroovyClosureScript(groovy.lang.Binding binding)
           
 
Method Summary
 groovy.lang.GroovyObject getDelegate()
           
 java.lang.Object getProperty(java.lang.String property)
           
 java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args)
           
 void setDelegate(groovy.lang.GroovyObject delegate)
          Sets the delegation target.
 void setProperty(java.lang.String property, java.lang.Object newValue)
           
 
Methods inherited from class groovy.lang.Script
evaluate, evaluate, getBinding, print, printf, printf, println, println, run, run, setBinding
 
Methods inherited from class groovy.lang.GroovyObjectSupport
getMetaClass, setMetaClass
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GroovyClosureScript

protected GroovyClosureScript()

GroovyClosureScript

protected GroovyClosureScript(groovy.lang.Binding binding)
Method Detail

setDelegate

public void setDelegate(groovy.lang.GroovyObject delegate)
Sets the delegation target.


getDelegate

public groovy.lang.GroovyObject getDelegate()

invokeMethod

public java.lang.Object invokeMethod(java.lang.String name,
                                     java.lang.Object args)
Specified by:
invokeMethod in interface groovy.lang.GroovyObject
Overrides:
invokeMethod in class groovy.lang.Script

getProperty

public java.lang.Object getProperty(java.lang.String property)
Specified by:
getProperty in interface groovy.lang.GroovyObject
Overrides:
getProperty in class groovy.lang.Script

setProperty

public void setProperty(java.lang.String property,
                        java.lang.Object newValue)
Specified by:
setProperty in interface groovy.lang.GroovyObject
Overrides:
setProperty in class groovy.lang.Script


Copyright © 2012. All Rights Reserved.