org.apache.xml.utils
Class XMLReaderManager

java.lang.Object
  extended by org.apache.xml.utils.XMLReaderManager

public class XMLReaderManager
extends java.lang.Object

Creates XMLReader objects and caches them for re-use. This class follows the singleton pattern.


Field Summary
private  java.util.Hashtable m_inUse
          Keeps track of whether an XMLReader object is in use.
private static javax.xml.parsers.SAXParserFactory m_parserFactory
          Parser factory to be used to construct XMLReader objects
private  java.lang.ThreadLocal m_readers
          Cache of XMLReader objects
private static XMLReaderManager m_singletonManager
           
private static java.lang.String NAMESPACE_PREFIXES_FEATURE
           
private static java.lang.String NAMESPACES_FEATURE
           
 
Constructor Summary
private XMLReaderManager()
          Hidden constructor
 
Method Summary
static XMLReaderManager getInstance()
          Retrieves the singleton reader manager
 org.xml.sax.XMLReader getXMLReader()
          Retrieves a cached XMLReader for this thread, or creates a new XMLReader, if the existing reader is in use.
 void releaseXMLReader(org.xml.sax.XMLReader reader)
          Mark the cached XMLReader as available.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAMESPACES_FEATURE

private static final java.lang.String NAMESPACES_FEATURE
See Also:
Constant Field Values

NAMESPACE_PREFIXES_FEATURE

private static final java.lang.String NAMESPACE_PREFIXES_FEATURE
See Also:
Constant Field Values

m_singletonManager

private static final XMLReaderManager m_singletonManager

m_parserFactory

private static javax.xml.parsers.SAXParserFactory m_parserFactory
Parser factory to be used to construct XMLReader objects


m_readers

private java.lang.ThreadLocal m_readers
Cache of XMLReader objects


m_inUse

private java.util.Hashtable m_inUse
Keeps track of whether an XMLReader object is in use.

Constructor Detail

XMLReaderManager

private XMLReaderManager()
Hidden constructor

Method Detail

getInstance

public static XMLReaderManager getInstance()
Retrieves the singleton reader manager


getXMLReader

public org.xml.sax.XMLReader getXMLReader()
                                   throws org.xml.sax.SAXException
Retrieves a cached XMLReader for this thread, or creates a new XMLReader, if the existing reader is in use. When the caller no longer needs the reader, it must release it with a call to releaseXMLReader(org.xml.sax.XMLReader).

Throws:
org.xml.sax.SAXException

releaseXMLReader

public void releaseXMLReader(org.xml.sax.XMLReader reader)
Mark the cached XMLReader as available. If the reader was not actually in the cache, do nothing.

Parameters:
reader - The XMLReader that's being released.