org.exist.cocoon
Class XQueryGenerator

java.lang.Object
  extended byorg.apache.avalon.framework.logger.AbstractLogEnabled
      extended byorg.apache.cocoon.xml.AbstractXMLProducer
          extended byorg.apache.cocoon.generation.AbstractGenerator
              extended byorg.apache.cocoon.generation.ServiceableGenerator
                  extended byorg.exist.cocoon.XQueryGenerator
All Implemented Interfaces:
org.apache.cocoon.caching.CacheableProcessingComponent, org.apache.avalon.framework.component.Component, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.activity.Disposable, org.apache.cocoon.generation.Generator, org.apache.avalon.framework.logger.LogEnabled, org.apache.avalon.framework.parameters.Parameterizable, org.apache.avalon.excalibur.pool.Poolable, org.apache.avalon.excalibur.pool.Recyclable, org.apache.avalon.framework.service.Serviceable, org.apache.cocoon.sitemap.SitemapModelComponent, org.apache.cocoon.xml.XMLProducer

public class XQueryGenerator
extends org.apache.cocoon.generation.ServiceableGenerator
implements org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.parameters.Parameterizable, org.apache.cocoon.caching.CacheableProcessingComponent

A generator for Cocoon which reads an XQuery script, executes it and passes the results into the Cocoon pipeline. The following optional attributes are accepted on the component declaration as default eXist settings:

  • collection: identifies the XML:DB root collection used to process the request
  • user
  • password
  • authen
  • : if set to session, then use the user and password from the session. Otherwise use the parameter values.
  • create-session: if set to "true", indicates that an HTTP session should be created upon the first invocation.
  • expand-xincludes
  • cache-validity: if specified, the XQuery content is cached until the specified delay expressed in milliseconds is elapsed or until the XQuery file is modified. The identity of the cached content is computed using the XQuery file URI and the list of all parameters passed to the XQuery.
  • The component also accept default parameters that will be declared as implicit variables in the XQuery. See below an example declaration of the XQueryGenerator component with default eXist settings, and an extra user-defined parameter: These settings and parameters can be overriden on a per-pipeline basis with sitemap parameters, see below with default values and the extra user-defined parameter:
      <map:parameter name="collection" value="xmldb:exist:///db"/>
      <map:parameter name="user" value="guest"/>
      <map:parameter name="password" value="guest"/>
      <map:parameter name="create-session" value="false"/>
      <map:parameter name="expand-xincludes" value="false"/>
      <map:parameter name="cache-validity" value="-1quot;/>
      <map:parameter name="myProjectURI" value="/db/myproject"/>
     
    The last sitemap parameter overrides the value of the XQuery variable defined in the component parameters, whereas others override the default eXist settings defined on the component attributes.

    Author:
    wolf

    Field Summary
    static java.lang.String DRIVER
               
     
    Fields inherited from interface org.apache.cocoon.generation.Generator
    ROLE
     
    Constructor Summary
    XQueryGenerator()
               
     
    Method Summary
     void configure(org.apache.avalon.framework.configuration.Configuration config)
               
     void generate()
               
     java.io.Serializable getKey()
               
     org.apache.excalibur.source.SourceValidity getValidity()
               
     void parameterize(org.apache.avalon.framework.parameters.Parameters params)
               
     void recycle()
               
     void setup(org.apache.cocoon.environment.SourceResolver resolver, java.util.Map objectModel, java.lang.String source, org.apache.avalon.framework.parameters.Parameters parameters)
               
     
    Methods inherited from class org.apache.cocoon.generation.ServiceableGenerator
    dispose, service
     
    Methods inherited from class org.apache.cocoon.xml.AbstractXMLProducer
    setConsumer, setContentHandler, setLexicalHandler
     
    Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
    enableLogging
     
    Methods inherited from class java.lang.Object
    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     
    Methods inherited from interface org.apache.cocoon.xml.XMLProducer
    setConsumer
     

    Field Detail

    DRIVER

    public static final java.lang.String DRIVER
    See Also:
    Constant Field Values
    Constructor Detail

    XQueryGenerator

    public XQueryGenerator()
    Method Detail

    setup

    public void setup(org.apache.cocoon.environment.SourceResolver resolver,
                      java.util.Map objectModel,
                      java.lang.String source,
                      org.apache.avalon.framework.parameters.Parameters parameters)
               throws org.apache.cocoon.ProcessingException,
                      org.xml.sax.SAXException,
                      java.io.IOException
    Specified by:
    setup in interface org.apache.cocoon.sitemap.SitemapModelComponent
    Throws:
    org.apache.cocoon.ProcessingException
    org.xml.sax.SAXException
    java.io.IOException

    recycle

    public void recycle()
    Specified by:
    recycle in interface org.apache.avalon.excalibur.pool.Recyclable

    generate

    public void generate()
                  throws java.io.IOException,
                         org.xml.sax.SAXException,
                         org.apache.cocoon.ProcessingException
    Specified by:
    generate in interface org.apache.cocoon.generation.Generator
    Throws:
    java.io.IOException
    org.xml.sax.SAXException
    org.apache.cocoon.ProcessingException
    See Also:
    Generator.generate()

    configure

    public void configure(org.apache.avalon.framework.configuration.Configuration config)
                   throws org.apache.avalon.framework.configuration.ConfigurationException
    Specified by:
    configure in interface org.apache.avalon.framework.configuration.Configurable
    Throws:
    org.apache.avalon.framework.configuration.ConfigurationException
    See Also:
    Configurable.configure(org.apache.avalon.framework.configuration.Configuration)

    parameterize

    public void parameterize(org.apache.avalon.framework.parameters.Parameters params)
                      throws org.apache.avalon.framework.parameters.ParameterException
    Specified by:
    parameterize in interface org.apache.avalon.framework.parameters.Parameterizable
    Throws:
    org.apache.avalon.framework.parameters.ParameterException
    See Also:
    Parameterizable.parameterize(org.apache.avalon.framework.parameters.Parameters)

    getKey

    public java.io.Serializable getKey()
    Specified by:
    getKey in interface org.apache.cocoon.caching.CacheableProcessingComponent

    getValidity

    public org.apache.excalibur.source.SourceValidity getValidity()
    Specified by:
    getValidity in interface org.apache.cocoon.caching.CacheableProcessingComponent


    Copyright (C) Wolfgang Meier. All rights reserved.