org.apache.cocoon.generation
public class: XMLDBGenerator [javadoc |
source]
java.lang.Object
org.apache.avalon.framework.logger.AbstractLogEnabled
org.apache.cocoon.xml.AbstractXMLProducer
org.apache.cocoon.generation.AbstractGenerator
org.apache.cocoon.generation.ServiceableGenerator
org.apache.cocoon.generation.XMLDBGenerator
All Implemented Interfaces:
CacheableProcessingComponent, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.activity.Initializable, org.apache.avalon.framework.activity.Disposable, org.apache.avalon.framework.service.Serviceable, Generator, org.apache.avalon.excalibur.pool.Recyclable, XMLProducer
Deprecated! Use - the XML:DB pseudo protocol instead.
This class implements generation of XML documents from a
XML:DB compliant database.
It must to be configured as follows:
<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:
< - a href="mailto:gianugo@rabellino.it">Gianugo Rabellino
- version:
CVS - $Id: XMLDBGenerator.java 433543 2006-08-22 06:22:54Z crossley $
| Field Summary |
|---|
| protected String | driver | |
| protected String | base | |
| protected String | col | |
| protected String | res | |
| protected Database | database | |
| protected Collection | collection | |
| protected XMLResource | xmlResource | |
| Methods from org.apache.cocoon.generation.ServiceableGenerator: |
|---|
|
dispose, service |
| Methods from org.apache.cocoon.generation.AbstractGenerator: |
|---|
|
recycle, setup |
| Method from org.apache.cocoon.generation.XMLDBGenerator Detail: |
public void configure(Configuration conf) throws ConfigurationException {
this.driver = conf.getChild("driver").getValue();
this.base = conf.getChild("base").getValue();
} Deprecated!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! |
public void generate() throws IOException, SAXException, ProcessingException {
String col = "/";
if (source.indexOf('/") != -1)
col = "/" + source.substring(0, source.lastIndexOf('/"));
res = source.substring(source.lastIndexOf('/") + 1);
try {
collection = DatabaseManager.getCollection(base + col);
xmlResource = (XMLResource) collection.getResource(res);
if (xmlResource == null) {
throw new ResourceNotFoundException("Document " + col + "/" + res +
" not found");
}
xmlResource.getContentAsSAX(this.xmlConsumer);
collection.close();
} catch (XMLDBException xde) {
throw new ProcessingException("Unable to fetch content: " +
xde.getMessage());
} catch (NullPointerException npe) {
getLogger().error("The XML:DB driver raised an exception");
getLogger().error("probably the document was not found");
throw new ProcessingException("Null pointer exception while " +
"retrieving document : " + npe.getMessage());
}
} Deprecated!Parse the requested URI, connect to the XML:DB database
and fetch the requested resource. |
public Serializable getKey() {
return null;
} Deprecated!The component isn't cached (yet) |
public SourceValidity getValidity() {
return null;
} Deprecated!The component isn't cached (yet) |
public void initialize() throws Exception {
try {
Class c = Class.forName(driver);
database = (Database)c.newInstance();
DatabaseManager.registerDatabase(database);
} catch (XMLDBException xde) {
getLogger().error("Unable to connect to the XML:DB database");
throw new ProcessingException("Unable to connect to the XMLDB database: "
+ xde.getMessage());
} catch (Exception e) {
getLogger().error("There was a problem setting up the connection");
getLogger().error("Make sure that your driver is available");
throw new ProcessingException("Problem setting up the connection: "
+ e.getMessage());
}
} Deprecated!Initialize the component getting a database instance. |
public void recycle() {
super.recycle();
this.col = null;
this.res = null;
this.xmlResource = null;
this.collection = null;
} Deprecated!Recycle the component, keep only the configuration variables
and the database instance for reuse. |
public void setup(SourceResolver resolver,
Map objectModel,
String src,
Parameters par) throws IOException, SAXException, ProcessingException {
Deprecation.logger.warn("The XMLDBGenerator is deprecated. Use the XML:DB pseudo protocol instead");
super.setup(resolver, objectModel, src, par);
} Deprecated! |