org.springframework.beans.factory.xml
Class XmlBeanDefinitionReader

public class XmlBeanDefinitionReader
extends AbstractBeanDefinitionReader
Bean definition reader for XML bean definitions. Delegates the actual XML parsing to an implementation of the XmlBeanDefinitionParser interface. Typically applied to a DefaultListableBeanFactory.

This class loads a DOM document and applies the bean definition parser to it. The parser will register each bean definition with the given bean factory, relying on the latter's implementation of the BeanDefinitionRegistry interface.

Since26.11.2003
VersionNot specified.
AuthorJuergen Hoeller
Wiki javadoc Use textile entry format.
Add your comments here.
Fields inherited from org.springframework.beans.factory.supportAbstractBeanDefinitionReader
Constructor Summary
XmlBeanDefinitionReader( BeanDefinitionRegistry beanFactory )
Create new XmlBeanDefinitionReader for the given bean factory.
Method Summary
protected DocumentBuilder createDocumentBuilder( DocumentBuilderFactory factory )
Create a JAXP DocumentBuilder that this bean definition reader will use for parsing XML documents.
protected DocumentBuilderFactory createDocumentBuilderFactory()
Create a JAXP DocumentBuilderFactory that this bean definition reader will use for parsing XML documents.
protected int doLoadBeanDefinitions( InputSource inputSource, Resource resource )
Actually load bean definitions from the specified XML file.
int loadBeanDefinitions( Resource resource )
Load bean definitions from the specified XML file.
int loadBeanDefinitions( EncodedResource encodedResource )
Load bean definitions from the specified XML file.
int loadBeanDefinitions( InputSource inputSource )
Load bean definitions from the specified XML file.
int loadBeanDefinitions( InputSource inputSource, String resourceDescription )
Load bean definitions from the specified XML file.
int registerBeanDefinitions( Document doc, Resource resource )
Register the bean definitions contained in the given DOM document.
void setEntityResolver( EntityResolver entityResolver )
Set a SAX entity resolver to be used for parsing.
void setErrorHandler( ErrorHandler errorHandler )
Set an implementation of the org.xml.sax.ErrorHandler interface for custom handling of XML parsing errors and warnings.
void setNamespaceAware( boolean namespaceAware )
Set whether or not the XML parser should be XML namespace aware.
void setParserClass( Class parserClass )
Set the XmlBeanDefinitionParser implementation to use, responsible for the actual parsing of XML bean definitions.
void setValidating( boolean validating )
Set if the XML parser should validate the document and thus enforce a DTD.
XmlBeanDefinitionReader
public XmlBeanDefinitionReader ( BeanDefinitionRegistry beanFactory )
Create new XmlBeanDefinitionReader for the given bean factory.
Parameters
TypeNameDescription
BeanDefinitionRegistry beanFactory No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
createDocumentBuilder
protected DocumentBuilder createDocumentBuilder ( DocumentBuilderFactory factory )
Create a JAXP DocumentBuilder that this bean definition reader will use for parsing XML documents. Can be overridden in subclasses, adding further initialization of the builder.
Parameters
TypeNameDescription
DocumentBuilderFactory factory the JAXP DocumentBuilderFactory that the DocumentBuilder should be created with
Exceptions
ParserConfigurationException if thrown by JAXP methods
Wiki javadoc Use textile entry format.
Add your comments here.
createDocumentBuilderFactory
protected DocumentBuilderFactory createDocumentBuilderFactory ( )
Create a JAXP DocumentBuilderFactory that this bean definition reader will use for parsing XML documents. Can be overridden in subclasses, adding further initialization of the factory.
Exceptions
ParserConfigurationException if thrown by JAXP methods
Wiki javadoc Use textile entry format.
Add your comments here.
doLoadBeanDefinitions
protected int doLoadBeanDefinitions ( InputSource inputSource, Resource resource )
Actually load bean definitions from the specified XML file.
Parameters
TypeNameDescription
InputSource inputSource the SAX InputSource to read from
Resource resource the resource descriptor for the XML file
Exceptions
BeansException No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
loadBeanDefinitions
public int loadBeanDefinitions ( Resource resource )
Load bean definitions from the specified XML file.
Implements method in BeanDefinitionReader
Parameters
TypeNameDescription
Resource resource the resource descriptor for the XML file
Exceptions
BeansException No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
loadBeanDefinitions
public int loadBeanDefinitions ( EncodedResource encodedResource )
Load bean definitions from the specified XML file.
Parameters
TypeNameDescription
EncodedResource encodedResource the resource descriptor for the XML file, allowing to specify an encoding to use for parsing the file
Exceptions
BeansException No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
loadBeanDefinitions
public int loadBeanDefinitions ( InputSource inputSource )
Load bean definitions from the specified XML file.
Parameters
TypeNameDescription
InputSource inputSource the SAX InputSource to read from
Exceptions
BeansException No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
loadBeanDefinitions
public int loadBeanDefinitions ( InputSource inputSource, String resourceDescription )
Load bean definitions from the specified XML file.
Parameters
TypeNameDescription
InputSource inputSource the SAX InputSource to read from
String resourceDescription a description of the resource (can be null or empty)
Exceptions
BeansException No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
registerBeanDefinitions
public int registerBeanDefinitions ( Document doc, Resource resource )
Register the bean definitions contained in the given DOM document. Called by loadBeanDefinitions.

Creates a new instance of the parser class and invokes registerBeanDefinitions on it.

Parameters
TypeNameDescription
Document doc the DOM document
Resource resource the resource descriptor (for context information)
Exceptions
BeansException in case of parser instantiation failure
Wiki javadoc Use textile entry format.
Add your comments here.
setEntityResolver
public void setEntityResolver ( EntityResolver entityResolver )
Set a SAX entity resolver to be used for parsing. By default, BeansDtdResolver will be used. Can be overridden for custom entity resolution, for example relative to some specific base path.
Parameters
TypeNameDescription
EntityResolver entityResolver No description provided.
Returns void No description provided.
See also
Wiki javadoc Use textile entry format.
Add your comments here.
setErrorHandler
public void setErrorHandler ( ErrorHandler errorHandler )
Set an implementation of the org.xml.sax.ErrorHandler interface for custom handling of XML parsing errors and warnings.

If not set, a default SimpleSaxErrorHandler is used that simply logs warnings using the logger instance of the view class, and rethrows errors to discontinue the XML transformation.

Parameters
TypeNameDescription
ErrorHandler errorHandler No description provided.
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
setNamespaceAware
public void setNamespaceAware ( boolean namespaceAware )
Set whether or not the XML parser should be XML namespace aware. Default is "false".
Parameters
TypeNameDescription
boolean namespaceAware No description provided.
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
setParserClass
public void setParserClass ( Class parserClass )
Set the XmlBeanDefinitionParser implementation to use, responsible for the actual parsing of XML bean definitions. Default is DefaultXmlBeanDefinitionParser.
Parameters
TypeNameDescription
Class parserClass No description provided.
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
setValidating
public void setValidating ( boolean validating )
Set if the XML parser should validate the document and thus enforce a DTD. Default is "true".
Parameters
TypeNameDescription
boolean validating No description provided.
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.