Cernunnos Manual


<groovy>

Description:

Invokes operations specified by SCRIPT using the groovy engine.

Groovy Logo Among dozens of things we can say about Groovy, it is a dynamic language for the Java platform. This feature -- dynamic -- offers tremendous synergy with Cernunnos because it allows us to evaluate expressions at runtime and then execute them. This feature is especially handy for tasks like <if> and <choose> that rely on conditionals.

The Groovy Language is also concise, modern, and powerful. Its syntax is based on regular Java syntax, so Java developers will experience little difficulty getting up to speed. Since it runs on the JVM, Groovy also integrates with exisiting Java code seamlessly.

Reagents:

Name XPath Description Reagent Type Expected Type Required
CACHE @cache A shared Map to cache items in. The default is the value of the 'Attributes.CACHE' request attribute. PHRASE java.util.Map No
CACHE_MODEL @cache-model Specify either NONE, ONE, or ALL. PHRASE java.lang.String No
SCRIPT script/text() Script content to execute. Must be placed within a child <script> element. PHRASE java.lang.String Yes
SUBTASKS subtasks/* The set of tasks that are children of this task. NODE_LIST java.util.List No

Examples:

Takes a web address as a parameter (e.g. 'www.yahoo.com'); computes the checksum value of the document at the specified address, then copies that document to a local file called 'markup.html' and finally compares the checksum value of the local document against the previous, online checksum value:

 
       
        <with-attribute key="onlineChecksum" value="${checksum(http://${$1})}"> 
          <copy-file location="http://${$1}/" to-file="markup.html"/>  
          <with-attribute key="localChecksum" value="${checksum(markup.html)}"> 
            <groovy> 
              <script>if (onlineChecksum == localChecksum) { println 'Both checksum values are the same: ' + onlineChecksum; } else { println 'The checksum values are different:\n\tonline=' + onlineChecksum + '\n\tlocal=' + localChecksum; }</script> 
            </groovy> 
          </with-attribute> 
        </with-attribute>