com.xmlmill.connector.cocoon
Class XMLMillSerializer_214

java.lang.Object
  |
  +--org.apache.avalon.framework.logger.AbstractLogEnabled
        |
        +--org.apache.cocoon.xml.AbstractXMLProducer
              |
              +--org.apache.cocoon.xml.AbstractXMLPipe
                    |
                    +--org.apache.cocoon.serialization.AbstractSerializer
                          |
                          +--com.xmlmill.connector.cocoon.XMLMillSerializer_214
All Implemented Interfaces:
org.apache.cocoon.caching.CacheableProcessingComponent, org.apache.avalon.framework.component.Component, org.apache.avalon.framework.configuration.Configurable, org.xml.sax.ContentHandler, org.xml.sax.ext.LexicalHandler, org.apache.avalon.framework.logger.LogEnabled, org.apache.avalon.excalibur.pool.Poolable, org.apache.avalon.excalibur.pool.Recyclable, org.apache.cocoon.serialization.Serializer, org.apache.avalon.framework.service.Serviceable, org.apache.cocoon.sitemap.SitemapOutputComponent, org.apache.cocoon.xml.XMLConsumer, org.apache.excalibur.xml.sax.XMLConsumer, org.apache.cocoon.xml.XMLPipe, org.apache.cocoon.xml.XMLProducer

public class XMLMillSerializer_214
extends org.apache.cocoon.serialization.AbstractSerializer
implements org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.service.Serviceable, org.apache.cocoon.caching.CacheableProcessingComponent

The XMLMillSerializer represents an instance to be used when generating .pdf documents in a Cocoon environment (version 2.1.4).

*** This class can only be used with Cocoon 2.1.4. If you want to use this class into an earlier version you need to modify the source code. The source code of this class can be found in the download. Do not hesitate to contact us (support@xmlmill.com) if you need any help. ***

The needed .jar files (located in cocoon/WEBINF/lib) are:

  1. cocoon2.1.4.jar
  2. avalon-framwork-4.1.4.jar
  3. xmlmill154.jar (or higher)
  4. xalan.jar
  5. xercesImpl.jar
  6. xml-apis.jar
  7. excalibur-sourceresolve-1.0.2
  8. excalibur-pool-1.2.jar

Add to your sitemap.xmap of your web-application following:


<map:serializer logger="xmlmill.serializer.ml2pdf-webpages" mime-type="application/pdf" 
name="ml2pdf-webpages" src="com.xmlmill.connector.cocoon.XMLMillSerializer">
 <!-- The XMLMill configuration to use (if any) -->
 <config-file/>
 <!-- The log-file -->
 <log-file>logs/xmlmill.log</log-file>
 <!-- The log-level -->
 <log-level>debug</log-level>
 <!-- Should serializer set content length header or not? -->
 <set-content-length>true</set-content-length>
 <!-- Should WARNings lead to abortion of the generation ? -->
 <abort-on-warning>true</abort-on-warning>
 <!-- Should ERRORs lead to abortion of the generation ? -->
 <abort-on-error>true</abort-on-error>
 <!-- he systemid (needed to define relative URLs (should point to the resources used to generate the document. -->
 <systemid>context://xmlmill</systemid>
 </map:serializer>
 
When Cocoon is started these parameters are passed to the XMLMillSerializer instance using the Configure method.

And also a matcher:


 <map:match pattern="*.topdf">
   <!-- Generate xml document -->
   <map:generate type="file" src="documents/{1}.xml"/>
   <!-- Transform main document to the .mill format -->
   <map:transform src="stylesheets/topdf/rnotes.xsl"/>
   <!-- Serialize using the 'ml2pdf' serializer -->
   <map:serialize type="ml2pdf"/>
 </map:match>
 

Since:
1.60
Version:
1.60
Author:
Stefan Geelen, support@xmlmill.com

Fields inherited from interface org.apache.cocoon.serialization.Serializer
ROLE
 
Constructor Summary
XMLMillSerializer_214()
           
 
Method Summary
 void configure(org.apache.avalon.framework.configuration.Configuration conf)
          Set the configurations for this serializer.
 java.io.Serializable getKey()
          Generate the unique key.
 java.lang.String getMimeType()
          Return the MIME type.
 org.apache.excalibur.source.SourceValidity getValidity()
          Generate the validity object.
 void recycle()
          Recycle serializer by removing references.
 void service(org.apache.avalon.framework.service.ServiceManager manager)
          Set the component manager for this serializer.
 void setOutputStream(java.io.OutputStream out)
          Create the XMLMill driver Set the OutputStream where the XML should be serialized.
 boolean shouldSetContentLength()
          Test if the component wants to set the content length.
 
Methods inherited from class org.apache.cocoon.xml.AbstractXMLPipe
characters, comment, endCDATA, endDocument, endDTD, endElement, endEntity, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startCDATA, startDocument, startDTD, startElement, startEntity, startPrefixMapping
 
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.xml.sax.ContentHandler
characters, endDocument, endElement, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startElement, startPrefixMapping
 
Methods inherited from interface org.xml.sax.ext.LexicalHandler
comment, endCDATA, endDTD, endEntity, startCDATA, startDTD, startEntity
 
Methods inherited from interface org.apache.cocoon.xml.XMLProducer
setConsumer
 

Constructor Detail

XMLMillSerializer_214

public XMLMillSerializer_214()
Method Detail

configure

public void configure(org.apache.avalon.framework.configuration.Configuration conf)
               throws org.apache.avalon.framework.configuration.ConfigurationException
Set the configurations for this serializer.

This method is used by Cocoon to pass the configuration options so a JAXPTtransform instance (created when a document needs to be generated) knows these options.

Specified by:
configure in interface org.apache.avalon.framework.configuration.Configurable
Parameters:
conf - Configuration instance representing the configuration options defined in the sitemap.
Throws:
org.apache.avalon.framework.configuration.ConfigurationException - thrown when an error occurs during initial configuration.
Since:
1.60

getMimeType

public java.lang.String getMimeType()
Return the MIME type.

This method is used by Cocoon.

Overrides:
getMimeType in class org.apache.cocoon.serialization.AbstractSerializer
Returns:
String representing the mime type for this serialize.
Since:
1.60

setOutputStream

public void setOutputStream(java.io.OutputStream out)
Create the XMLMill driver Set the OutputStream where the XML should be serialized.

This method is used by Cocoon.

Overrides:
setOutputStream in class org.apache.cocoon.serialization.AbstractSerializer
Parameters:
out - Set the OutputStream where the XML should be serialized.
Since:
1.60

getKey

public java.io.Serializable getKey()
Generate the unique key.

This method is used by Cocoon. This key must be unique inside the space of this component. This method must be invoked before the generateValidity() method.

Specified by:
getKey in interface org.apache.cocoon.caching.CacheableProcessingComponent
Returns:
The generated key or 0 if the component is currently not cacheable.

getValidity

public org.apache.excalibur.source.SourceValidity getValidity()
Generate the validity object.

This method is used by Cocoon.

Before this method can be invoked the generateKey() method must be invoked.
Specified by:
getValidity in interface org.apache.cocoon.caching.CacheableProcessingComponent
Returns:
The generated validity object or null if the component is currently not cacheable.

recycle

public void recycle()
Recycle serializer by removing references.

This method is used by Cocoon.

Overrides:
recycle in class org.apache.cocoon.serialization.AbstractSerializer

shouldSetContentLength

public boolean shouldSetContentLength()
Test if the component wants to set the content length.

This method is used by Cocoon.

Overrides:
shouldSetContentLength in class org.apache.cocoon.serialization.AbstractSerializer
Returns:
boolean representing if contentlength should be set.

service

public void service(org.apache.avalon.framework.service.ServiceManager manager)
             throws org.apache.avalon.framework.service.ServiceException
Set the component manager for this serializer.

This method is used by Cocoon.

Specified by:
service in interface org.apache.avalon.framework.service.Serviceable
Parameters:
manager - The component manager to use.
Throws:
org.apache.avalon.framework.service.ServiceException - The exception thrown.