org.apache.commons.jelly.avalon
Class JellyServiceImpl

java.lang.Object
  extended byorg.apache.commons.jelly.avalon.JellyServiceImpl
All Implemented Interfaces:
org.apache.avalon.framework.configuration.Configurable, JellyService

public class JellyServiceImpl
extends java.lang.Object
implements JellyService, org.apache.avalon.framework.configuration.Configurable

An Avalon based service for executing Jelly scripts. The service allows executing a script based on a name as well as by a URL.

Version:
$Revision: 1.2 $
Author:
Robert McIntosh

Field Summary
private  boolean m_configured
           
private  java.util.Map m_scripts
           
 
Constructor Summary
JellyServiceImpl()
          Constructor for JellyService.
 
Method Summary
 void configure(org.apache.avalon.framework.configuration.Configuration config)
          Configures the Jelly Service with named scripts.
protected  org.apache.commons.jelly.JellyContext createJellyContext()
          Factory method to create a new JellyContext instance.
protected  org.apache.commons.jelly.XMLOutput createXMLOutput()
          Factory method to create a new XMLOutput to give to scripts as they run.
 java.util.Map runNamedScript(java.lang.String name, java.util.Map params)
          Executes a named script with the supplied Map of parameters.
 java.util.Map runNamedScript(java.lang.String name, java.util.Map params, java.io.OutputStream out)
          Executes a named script with the supplied Map of parameters and send the output of the script to the supplied output stream.
 java.util.Map runNamedScript(java.lang.String name, java.util.Map params, org.apache.commons.jelly.XMLOutput output)
          Executes a named script with the supplied Map of parameters.
 java.util.Map runScript(java.lang.String url, java.util.Map params)
          Runs a script from the supplied url
 java.util.Map runScript(java.lang.String url, java.util.Map params, java.io.OutputStream out)
          Runs a script from the supplied url and sends the output of the script to the supplied OutputStream.
 java.util.Map runScript(java.lang.String url, java.util.Map params, org.apache.commons.jelly.XMLOutput output)
          Runs a script from the supplied url
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_configured

private boolean m_configured

m_scripts

private java.util.Map m_scripts
Constructor Detail

JellyServiceImpl

public JellyServiceImpl()
Constructor for JellyService.

Method Detail

runNamedScript

public java.util.Map runNamedScript(java.lang.String name,
                                    java.util.Map params)
                             throws java.lang.Exception
Description copied from interface: JellyService
Executes a named script with the supplied Map of parameters.

Specified by:
runNamedScript in interface JellyService
Parameters:
params - Parameters to be supplied to the script
Returns:
All of the variables from the JellyContext
Throws:
java.lang.Exception - if the script raises some kind of exception while processing
See Also:
org.apache.commons.jelly.avalon.JellyService.runNamedScript(String, Map)

runNamedScript

public java.util.Map runNamedScript(java.lang.String name,
                                    java.util.Map params,
                                    org.apache.commons.jelly.XMLOutput output)
                             throws java.lang.Exception
Description copied from interface: JellyService
Executes a named script with the supplied Map of parameters.

Specified by:
runNamedScript in interface JellyService
Parameters:
name - is the name of the script to run
params - Parameters to be supplied to the script
output - is the XMLOutput for any output to be sent
Returns:
All of the variables from the JellyContext
Throws:
java.lang.Exception - if the script raises some kind of exception while processing
See Also:
org.apache.commons.jelly.avalon.JellyService.runNamedScript(String, Map, XMLOutput)

runNamedScript

public java.util.Map runNamedScript(java.lang.String name,
                                    java.util.Map params,
                                    java.io.OutputStream out)
                             throws java.lang.Exception
Description copied from interface: JellyService
Executes a named script with the supplied Map of parameters and send the output of the script to the supplied output stream.

Specified by:
runNamedScript in interface JellyService
Parameters:
name - is the name of the script to run
params - Parameters to be supplied to the script
out - is the outputStream for output to be sent
Returns:
All of the variables from the JellyContext
Throws:
java.lang.Exception - if the script raises some kind of exception while processing
See Also:
org.apache.commons.jelly.avalon.JellyService.runNamedScript(String, Map, OutputStream)

runScript

public java.util.Map runScript(java.lang.String url,
                               java.util.Map params,
                               org.apache.commons.jelly.XMLOutput output)
                        throws java.lang.Exception
Description copied from interface: JellyService
Runs a script from the supplied url

Specified by:
runScript in interface JellyService
Parameters:
url - The URL of the script
params - Parameters to be supplied to the script
output - is the XMLOutput where output of the script will go
Returns:
All of the variables from the JellyContext
Throws:
java.lang.Exception
See Also:
org.apache.commons.jelly.avalon.JellyService.runScript(String, Map, XMLOutput)

runScript

public java.util.Map runScript(java.lang.String url,
                               java.util.Map params,
                               java.io.OutputStream out)
                        throws java.lang.Exception
Description copied from interface: JellyService
Runs a script from the supplied url and sends the output of the script to the supplied OutputStream.

Specified by:
runScript in interface JellyService
Parameters:
url - The URL of the script
params - Parameters to be supplied to the script
out - The OutputStream to send the output of the script to
Returns:
All of the variables from the JellyContext
Throws:
java.lang.Exception - if the script raises some kind of exception while processing
See Also:
org.apache.commons.jelly.avalon.JellyService.runScript(String, Map, OutputStream)

runScript

public java.util.Map runScript(java.lang.String url,
                               java.util.Map params)
                        throws java.lang.Exception
Description copied from interface: JellyService
Runs a script from the supplied url

Specified by:
runScript in interface JellyService
Parameters:
url - The URL of the script
params - Parameters to be supplied to the script
Returns:
All of the variables from the JellyContext
Throws:
java.lang.Exception - if the script raises some kind of exception while processing
See Also:
org.apache.commons.jelly.avalon.JellyService.runScript(String, Map)

configure

public void configure(org.apache.avalon.framework.configuration.Configuration config)
               throws org.apache.avalon.framework.configuration.ConfigurationException

Configures the Jelly Service with named scripts.

The configuration looks like:

<jelly>
  <script>
    <name>script name</name>
    <url validate="false">url to script file</url>
  </script>
</jelly>

Where each <script> element defines a seperate script. The validate attribute on the url tag is optional and defaults to false.

Specified by:
configure in interface org.apache.avalon.framework.configuration.Configurable
Parameters:
config - The configuration
Throws:
org.apache.avalon.framework.configuration.ConfigurationException

createJellyContext

protected org.apache.commons.jelly.JellyContext createJellyContext()
Factory method to create a new JellyContext instance. Derived classes could overload this method to provide a custom JellyContext instance.


createXMLOutput

protected org.apache.commons.jelly.XMLOutput createXMLOutput()
Factory method to create a new XMLOutput to give to scripts as they run. Derived classes could overload this method, such as to pipe output to some log file etc.