org.compass.core.converter.xsem
Class PoolXmlContentConverterWrapper

java.lang.Object
  extended by org.compass.core.converter.xsem.PoolXmlContentConverterWrapper
All Implemented Interfaces:
CompassConfigurable, XmlContentConverter

public class PoolXmlContentConverterWrapper
extends Object
implements XmlContentConverter, CompassConfigurable

An XmlContentConverter implementation that wraps the actual XmlContentConverter configured (based on the settings) and creates and configures a pool of XmlContentConverters for both toXml(org.compass.core.xml.XmlObject) and fromXml(String, java.io.Reader).

The pool has a maximum capacity, to limit overhead. If all instances in the pool are in use and another is required, it shall block until one becomes available.

Author:
kimchy

Constructor Summary
PoolXmlContentConverterWrapper()
           
 
Method Summary
 void configure(CompassSettings settings)
          Configures the pool used from CompassEnvironment.Converter.XmlContent#MIN_POOL_SIZE and CompassEnvironment.Converter.XmlContent#MAX_POOL_SIZE.
 AliasedXmlObject fromXml(String alias, Reader xml)
          Converts a raw xml and an alias into an AliasedXmlObject by using the pool of XmlContentConverters implementation.
 String toXml(XmlObject xmlObject)
          Converts the XmlObject into raw xml by using the pool of XmlContentConverters implementation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PoolXmlContentConverterWrapper

public PoolXmlContentConverterWrapper()
Method Detail

configure

public void configure(CompassSettings settings)
               throws CompassException
Configures the pool used from CompassEnvironment.Converter.XmlContent#MIN_POOL_SIZE and CompassEnvironment.Converter.XmlContent#MAX_POOL_SIZE.

Specified by:
configure in interface CompassConfigurable
Parameters:
settings - The settings for the configured object
Throws:
CompassException

toXml

public String toXml(XmlObject xmlObject)
             throws ConversionException
Converts the XmlObject into raw xml by using the pool of XmlContentConverters implementation.

Specified by:
toXml in interface XmlContentConverter
Parameters:
xmlObject - The xml object to convert to an xml string
Returns:
An xml string representation of the xml object
Throws:
ConversionException - Failed to convert the xml object to an xml string
See Also:
XmlContentConverter.toXml(org.compass.core.xml.XmlObject)

fromXml

public AliasedXmlObject fromXml(String alias,
                                Reader xml)
                         throws ConversionException
Converts a raw xml and an alias into an AliasedXmlObject by using the pool of XmlContentConverters implementation.

Specified by:
fromXml in interface XmlContentConverter
Parameters:
alias - The alias the aliases xml object is associated with
xml - The xml string that will be converted into an aliases xml object
Returns:
The aliases xml object that is the restult of the xml parsed
Throws:
ConversionException
See Also:
XmlContentConverter.fromXml(String, java.io.Reader)


Copyright (c) 2004-2008 The Compass Project.