org.apache.cocoon.serialization
Class FOPSerializer

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.cocoon.xml.AbstractXMLProducer
          extended by org.apache.cocoon.xml.AbstractXMLPipe
              extended by org.apache.cocoon.serialization.AbstractSerializer
                  extended by org.apache.cocoon.serialization.FOPSerializer
All Implemented Interfaces:
URIResolver, Poolable, Recyclable, Disposable, Component, Configurable, LogEnabled, Serviceable, CacheableProcessingComponent, Serializer, SitemapOutputComponent, XMLPipe, XMLProducer, XMLConsumer, ContentHandler, LexicalHandler

public class FOPSerializer
extends AbstractSerializer
implements Configurable, CacheableProcessingComponent, Serviceable, URIResolver, Disposable

FOP 0.93 (and newer) based serializer.

Version:
$Id: FOPSerializer.html 1304258 2012-03-23 10:09:27Z ilgrosso $

Nested Class Summary
static class FOPSerializer.ReleaseSourceInputStream
          An InputStream which releases the Cocoon/Avalon source from which the InputStream has been retrieved when the stream is closed.
 
Field Summary
protected  org.apache.fop.apps.Fop fop
          The FOP instance.
protected  org.apache.fop.apps.FopFactory fopfactory
          Factory to create fop objects
protected  ServiceManager manager
          Manager to get URLFactory from.
protected  String mimetype
          The current mime-type.
protected  SourceResolver resolver
           
protected  boolean setContentLength
          Should we set the content length ?
 
Fields inherited from class org.apache.cocoon.serialization.AbstractSerializer
output
 
Fields inherited from class org.apache.cocoon.xml.AbstractXMLProducer
contentHandler, EMPTY_CONTENT_HANDLER, lexicalHandler, xmlConsumer
 
Fields inherited from interface org.apache.cocoon.serialization.Serializer
ROLE
 
Constructor Summary
FOPSerializer()
           
 
Method Summary
 void configure(Configuration conf)
          Set the configurations for this serializer.
 void dispose()
           
 Serializable getKey()
          Generate the unique key.
 String getMimeType()
          Return the MIME type.
 SourceValidity getValidity()
          Generate the validity object.
 void recycle()
          Recycle serializer by removing references
 Source resolve(String href, String base)
           
 void service(ServiceManager manager)
          Set the component manager for this serializer.
 void setOutputStream(OutputStream out)
          Create the FOP 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, getLogger, 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.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
 

Field Detail

resolver

protected SourceResolver resolver

fopfactory

protected org.apache.fop.apps.FopFactory fopfactory
Factory to create fop objects


fop

protected org.apache.fop.apps.Fop fop
The FOP instance.


mimetype

protected String mimetype
The current mime-type.


setContentLength

protected boolean setContentLength
Should we set the content length ?


manager

protected ServiceManager manager
Manager to get URLFactory from.

Constructor Detail

FOPSerializer

public FOPSerializer()
Method Detail

service

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

Specified by:
service in interface Serviceable
Throws:
ServiceException

configure

public void configure(Configuration conf)
               throws ConfigurationException
Set the configurations for this serializer.

Specified by:
configure in interface Configurable
Throws:
ConfigurationException

recycle

public void recycle()
Recycle serializer by removing references

Specified by:
recycle in interface Recyclable
Overrides:
recycle in class AbstractSerializer

dispose

public void dispose()
Specified by:
dispose in interface Disposable

getMimeType

public String getMimeType()
Return the MIME type.

Specified by:
getMimeType in interface SitemapOutputComponent
Overrides:
getMimeType in class AbstractSerializer
See Also:
AbstractProcessingPipeline.setMimeTypeForSerializer(org.apache.cocoon.environment.Environment), AbstractProcessingPipeline.setMimeTypeForReader(org.apache.cocoon.environment.Environment)

setOutputStream

public void setOutputStream(OutputStream out)
                     throws IOException
Create the FOP driver Set the OutputStream where the XML should be serialized.

Specified by:
setOutputStream in interface SitemapOutputComponent
Overrides:
setOutputStream in class AbstractSerializer
Throws:
IOException

getKey

public Serializable getKey()
Generate the unique key. 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 CacheableProcessingComponent
Returns:
The generated key or 0 if the component is currently not cacheable.

getValidity

public SourceValidity getValidity()
Generate the validity object. Before this method can be invoked the generateKey() method must be invoked.

Specified by:
getValidity in interface CacheableProcessingComponent
Returns:
The generated validity object or null if the component is currently not cacheable.

shouldSetContentLength

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

Specified by:
shouldSetContentLength in interface SitemapOutputComponent
Overrides:
shouldSetContentLength in class AbstractSerializer

resolve

public Source resolve(String href,
                      String base)
               throws TransformerException
Specified by:
resolve in interface URIResolver
Throws:
TransformerException


Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.