org.enhydra.barracuda.core.util.dom
Class XMLCDeferredParsingDOMFactory

java.lang.Object
  extended byorg.enhydra.barracuda.core.util.dom.XMLCDeferredParsingDOMFactory
All Implemented Interfaces:
DOMFactory

public class XMLCDeferredParsingDOMFactory
extends Object
implements DOMFactory

XMLC deferred parsing implementation of a DOMFactory. This class will load a DOM using XMLCDeferredParsingFactory.

Optionally, one may provide the XMLCDeferredParsingFactory that this DOMFactory backs with context init parameters in the web.xml. In order to do that, the current ServletContext must be set using setServletContext(ServletContext) before adding a DOMFactory object to a DOMLoader object. This can be done either programatically or set via the assembly descriptor with

 <dom-loader factory="org.enhydra.xml.xmlc.deferredparsing.XMLCDeferredParsingFactory">
   <set-property name="servletContext" delegateRuntimeValue="true"/>
 </dom-loader>
 

Once above requirement is met, one can set the following <context-param>'s in the web.xml...

These context init parameters match up exactly with those used by org.enhydra.xml.xmlc.servlet.XMLCContext. Therefore, the configuration used for this class is entirely compatible with XMLCContext.


Field Summary
protected  boolean initialized
          used for flagging whether the xmlcFactory has been initialized and avoiding unnecessary synchronization.
protected static org.apache.log4j.Logger logger
          used for logging
protected  String PARAM_XMLC_REPARSE_DEFAULT_METADATA_PATH
          Definition of xmlcReparseDefaultMetaDataPath parameter
protected  String PARAM_XMLC_REPARSE_PACKAGE_PREFIXES
          Definition of xmlcReparsePackagePrefixes parameter
protected  String PARAM_XMLC_REPARSE_RESOURCE_DIRS
          Definition of xmlcReparseResourceDirs parameter.
protected  javax.servlet.ServletContext servletContext
          optional, used to access context init parameters if set, ignored if null
protected  Object sync
          arbitrary object used to synchronize upon
protected  org.enhydra.xml.xmlc.deferredparsing.XMLCDeferredParsingFactory xmlcFactory
          XMLCFactory instance, stored so that it isn't re-created on every request.
protected  String xmlcReparseDefaultMetaDataPath
          optional, used to access programatically set xmlc reparse default meta data path, ignored if null
protected  String xmlcReparsePackagePrefixes
          optional, used to access programatically set xmlc reparse package prefixes, ignored if null
protected  String xmlcReparseResourceDirs
          optional, used to access programatically set xmlc reparse resource dirs, ignored if null
 
Constructor Summary
XMLCDeferredParsingDOMFactory()
           
 
Method Summary
 Document getInstance(Class clazz)
          Get a new instance of the DOM that is associated with the given class
 Document getInstance(String docPath)
          Load a document directly from file.
 void setServletContext(javax.servlet.ServletContext iservletContext)
          optional method to set the current servlet context.
 void setXMLCReparseDefaultMetaDataPath(String ireparseDefaultMetaDataPath)
          optional method to directly set the xmlc reparse default meta data path.
 void setXMLCReparsePackagePrefixes(String ireparsePackagePrefixes)
          optional method to directly set the xmlc reparse package prefixes.
 void setXMLCReparseResourceDirs(String ireparseResourceDirs)
          optional method to directly set the xmlc resource dirs path.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static final org.apache.log4j.Logger logger
used for logging


PARAM_XMLC_REPARSE_RESOURCE_DIRS

protected final String PARAM_XMLC_REPARSE_RESOURCE_DIRS
Definition of xmlcReparseResourceDirs parameter.

See Also:
Constant Field Values

PARAM_XMLC_REPARSE_PACKAGE_PREFIXES

protected final String PARAM_XMLC_REPARSE_PACKAGE_PREFIXES
Definition of xmlcReparsePackagePrefixes parameter

See Also:
Constant Field Values

PARAM_XMLC_REPARSE_DEFAULT_METADATA_PATH

protected final String PARAM_XMLC_REPARSE_DEFAULT_METADATA_PATH
Definition of xmlcReparseDefaultMetaDataPath parameter

See Also:
Constant Field Values

servletContext

protected javax.servlet.ServletContext servletContext
optional, used to access context init parameters if set, ignored if null

See Also:
setServletContext(ServletContext)

xmlcReparseResourceDirs

protected String xmlcReparseResourceDirs
optional, used to access programatically set xmlc reparse resource dirs, ignored if null

See Also:
setXMLCReparseResourceDirs(String)

xmlcReparsePackagePrefixes

protected String xmlcReparsePackagePrefixes
optional, used to access programatically set xmlc reparse package prefixes, ignored if null

See Also:
setXMLCReparsePackagePrefixes(String)

xmlcReparseDefaultMetaDataPath

protected String xmlcReparseDefaultMetaDataPath
optional, used to access programatically set xmlc reparse default meta data path, ignored if null

See Also:
setXMLCReparseDefaultMetaDataPath(String)

sync

protected final Object sync
arbitrary object used to synchronize upon


initialized

protected boolean initialized
used for flagging whether the xmlcFactory has been initialized and avoiding unnecessary synchronization.


xmlcFactory

protected org.enhydra.xml.xmlc.deferredparsing.XMLCDeferredParsingFactory xmlcFactory
XMLCFactory instance, stored so that it isn't re-created on every request.

Constructor Detail

XMLCDeferredParsingDOMFactory

public XMLCDeferredParsingDOMFactory()
Method Detail

getInstance

public Document getInstance(Class clazz)
                     throws IOException
Get a new instance of the DOM that is associated with the given class

Specified by:
getInstance in interface DOMFactory
Parameters:
clazz - the class to be loaded as a DOM object. In this case, this class should implement XMLObject or the underlying XMLCFactory will not be able to instantiate it.
Returns:
the document that most closely corresponds with the requested class/locale combination
Throws:
IOException

getInstance

public Document getInstance(String docPath)
                     throws IOException
Load a document directly from file. This method allows for skipping the compilation of XMLC classes. In order to be used, the DOMLoader being utilized must support calling this method. Make sure to provide "xmlcReparseResourceDirs", and "xmlcReparseDefaultMetaDataPath" <context-param>'s because the path provide is relative to the provided resource dirs and the xmlc options file must be available in order to load the document file.

Specified by:
getInstance in interface DOMFactory
Parameters:
docPath - path to file relative to provided resource directories
Returns:
the document that most closely corresponds with the requested doc path/locale combination
Throws:
IOException

setServletContext

public void setServletContext(javax.servlet.ServletContext iservletContext)
optional method to set the current servlet context. Must be set before getInstance() is first called in order to be used.

Parameters:
iservletContext - the current servlet context

setXMLCReparseResourceDirs

public void setXMLCReparseResourceDirs(String ireparseResourceDirs)
optional method to directly set the xmlc resource dirs path. Note that, if set, this supercedes the xmlcReparseResourceDirs context param value (described above) obtained from a ServletContext. This must be set before getInstance() is first called in order to be used.

Parameters:
ireparseResourceDirs - a list of additional directories to load the html and meta data files separated by File.separator

setXMLCReparsePackagePrefixes

public void setXMLCReparsePackagePrefixes(String ireparsePackagePrefixes)
optional method to directly set the xmlc reparse package prefixes. Note that, if set, this supercedes the xmlcReparsePackagePrefixes context param value (described above) obtained from a ServletContext. This must be set before getInstance() is first called in order to be used.

Parameters:
ireparsePackagePrefixes - a list of package prefixes to be removed while searching for html and meta data files, relative to the classpath and resource dirs, separated by File.separator

setXMLCReparseDefaultMetaDataPath

public void setXMLCReparseDefaultMetaDataPath(String ireparseDefaultMetaDataPath)
optional method to directly set the xmlc reparse default meta data path. Note that, if set, this supercedes the xmlcReparseDefaultMetaDataPath context param value (described above) obtained from a ServletContext. This must be set before getInstance() is first called in order to be used.

Parameters:
ireparseDefaultMetaDataPath - a path to the default meta data file, relative to the classpath and resource dirs


Copyright © 2003 BarracudaMVC.org All Rights Reserved.