org.apache.cocoon.generation
Class XMLDBCollectionGenerator

java.lang.Object
  |
  +--org.apache.avalon.framework.logger.AbstractLoggable
        |
        +--org.apache.cocoon.xml.AbstractXMLProducer
              |
              +--org.apache.cocoon.generation.AbstractGenerator
                    |
                    +--org.apache.cocoon.generation.ComposerGenerator
                          |
                          +--org.apache.cocoon.generation.XMLDBCollectionGenerator
All Implemented Interfaces:
Cacheable, org.apache.avalon.framework.component.Component, org.apache.avalon.framework.component.Composable, org.apache.avalon.framework.configuration.Configurable, Generator, org.apache.avalon.framework.activity.Initializable, org.apache.avalon.framework.logger.Loggable, org.apache.avalon.excalibur.pool.Poolable, org.apache.avalon.excalibur.pool.Recyclable, SitemapModelComponent, XMLProducer

public class XMLDBCollectionGenerator
extends ComposerGenerator
implements Cacheable, org.apache.avalon.excalibur.pool.Recyclable, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.activity.Initializable

This class implements generation of a XML:DB collection contents as a directory listing.

 <driver>
   (a valid DB:XML compliant driver)
 </driver>
 <base>
   xmldb:yourdriver://host/an/optional/path/to/be/prepended
 </base>
 
NOTE: the driver can be any DB:XML compliant driver (although this component has been tested only with dbXML, and the trailing slash in the base tag is important!

Author:
Gianugo Rabellino

Field Summary
protected  org.xml.sax.helpers.AttributesImpl attributes
           
protected  java.lang.String base
           
protected  java.lang.String col
           
protected  org.xmldb.api.base.Collection collection
           
protected static java.lang.String COLLECTION
           
protected static java.lang.String COLLECTION_COUNT_ATTR
           
protected  org.xmldb.api.base.Database database
           
protected  java.lang.String driver
           
protected static java.lang.String PREFIX
           
protected static java.lang.String QCOLLECTION
           
protected static java.lang.String QRESOURCE
           
protected static java.lang.String RESOURCE
           
protected static java.lang.String RESOURCE_COUNT_ATTR
           
protected static java.lang.String URI
           
 
Fields inherited from class org.apache.cocoon.generation.ComposerGenerator
manager
 
Fields inherited from class org.apache.cocoon.generation.AbstractGenerator
objectModel, parameters, resolver, source
 
Fields inherited from class org.apache.cocoon.xml.AbstractXMLProducer
contentHandler, lexicalHandler, xmlConsumer
 
Fields inherited from interface org.apache.cocoon.generation.Generator
ROLE
 
Constructor Summary
XMLDBCollectionGenerator()
           
 
Method Summary
 void collectionToSAX(org.xmldb.api.base.Collection collection)
          Output SAX events listing the collection.
 void compose(org.apache.avalon.framework.component.ComponentManager manager)
          Set the current ComponentManager instance used by this Composable.
 void configure(org.apache.avalon.framework.configuration.Configuration conf)
          Configure the component.
 void generate()
          Parse the requested URI, connect to the XML:DB database and fetch the requested resource.
 long generateKey()
          The component isn't cached (yet)
 CacheValidity generateValidity()
          The component isn't cached (yet)
 CacheValidity getValidity()
          The component isn't cached (yet)
 void initialize()
          Initialize the component getting a database instance.
 void recycle()
          Recycle the component, keep only the configuration variables and the database instance for reuse.
 void setup(SourceResolver resolver, java.util.Map objectModel, java.lang.String src, org.apache.avalon.framework.parameters.Parameters par)
          Set the SourceResolver, object model Map, the source and sitemap Parameters used to process the request.
 
Methods inherited from class org.apache.cocoon.xml.AbstractXMLProducer
setConsumer, setContentHandler, setLexicalHandler
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLoggable
getLogger, setLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.cocoon.xml.XMLProducer
setConsumer
 

Field Detail

URI

protected static final java.lang.String URI

PREFIX

protected static final java.lang.String PREFIX

RESOURCE_COUNT_ATTR

protected static final java.lang.String RESOURCE_COUNT_ATTR

COLLECTION_COUNT_ATTR

protected static final java.lang.String COLLECTION_COUNT_ATTR

COLLECTION

protected static final java.lang.String COLLECTION

QCOLLECTION

protected static final java.lang.String QCOLLECTION

RESOURCE

protected static final java.lang.String RESOURCE

QRESOURCE

protected static final java.lang.String QRESOURCE

driver

protected java.lang.String driver

base

protected java.lang.String base

col

protected java.lang.String col

database

protected org.xmldb.api.base.Database database

collection

protected org.xmldb.api.base.Collection collection

attributes

protected org.xml.sax.helpers.AttributesImpl attributes
Constructor Detail

XMLDBCollectionGenerator

public XMLDBCollectionGenerator()
Method Detail

compose

public void compose(org.apache.avalon.framework.component.ComponentManager manager)
             throws org.apache.avalon.framework.component.ComponentException
Description copied from class: ComposerGenerator
Set the current ComponentManager instance used by this Composable.
Overrides:
compose in class ComposerGenerator

recycle

public void recycle()
Recycle the component, keep only the configuration variables and the database instance for reuse.
Specified by:
recycle in interface org.apache.avalon.excalibur.pool.Recyclable
Overrides:
recycle in class AbstractGenerator

configure

public void configure(org.apache.avalon.framework.configuration.Configuration conf)
               throws org.apache.avalon.framework.configuration.ConfigurationException
Configure the component. This class is expecting a configuration like the following one:
 <driver>org.dbxml.client.xmldb.DatabaseImpl</driver>
 <base>xmldb:dbxml:///db/</base>
 
NOTE: the driver can be any DB:XML compliant driver (although this component has been tested only with dbXML, and the trailing slash in the base tag is important!
Specified by:
configure in interface org.apache.avalon.framework.configuration.Configurable
Throws:
org.apache.avalon.framework.configuration.ConfigurationException - (configuration invalid or missing)

initialize

public void initialize()
                throws java.lang.Exception
Initialize the component getting a database instance.
Specified by:
initialize in interface org.apache.avalon.framework.activity.Initializable
Throws:
java.lang.Exception - if an error occurs

setup

public void setup(SourceResolver resolver,
                  java.util.Map objectModel,
                  java.lang.String src,
                  org.apache.avalon.framework.parameters.Parameters par)
           throws ProcessingException,
                  org.xml.sax.SAXException,
                  java.io.IOException
Description copied from class: AbstractGenerator
Set the SourceResolver, object model Map, the source and sitemap Parameters used to process the request.
Overrides:
setup in class AbstractGenerator

getValidity

public CacheValidity getValidity()
The component isn't cached (yet)

generateValidity

public CacheValidity generateValidity()
The component isn't cached (yet)
Specified by:
generateValidity in interface Cacheable
Following copied from interface: org.apache.cocoon.caching.Cacheable
Returns:
The generated validity object or null if the component is currently not cacheable.

generateKey

public long generateKey()
The component isn't cached (yet)
Specified by:
generateKey in interface Cacheable
Following copied from interface: org.apache.cocoon.caching.Cacheable
Returns:
The generated key or 0 if the component is currently not cacheable.

generate

public void generate()
              throws java.io.IOException,
                     org.xml.sax.SAXException,
                     ProcessingException
Parse the requested URI, connect to the XML:DB database and fetch the requested resource.
Throws:
ProcessingException - something unexpected happened with the DB

collectionToSAX

public void collectionToSAX(org.xmldb.api.base.Collection collection)
                     throws org.xml.sax.SAXException
Output SAX events listing the collection.
Throws:
org.xml.sax.SAXException -  


Copyright © 1999-2002 Apache Software Foundation. All Rights Reserved.