org.springframework.beans.factory.xml
Class XmlBeanDefinitionReader

java.lang.Object
  extended byorg.springframework.beans.factory.support.AbstractBeanDefinitionReader
      extended byorg.springframework.beans.factory.xml.XmlBeanDefinitionReader
All Implemented Interfaces:
BeanDefinitionReader

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.

Since:
26.11.2003
Author:
Juergen Hoeller
See Also:
setParserClass(java.lang.Class), XmlBeanDefinitionParser, DefaultXmlBeanDefinitionParser, BeanDefinitionRegistry, DefaultListableBeanFactory

Field Summary
 
Fields inherited from class org.springframework.beans.factory.support.AbstractBeanDefinitionReader
logger
 
Constructor Summary
XmlBeanDefinitionReader(BeanDefinitionRegistry beanFactory)
          Create new XmlBeanDefinitionReader for the given bean factory.
 
Method Summary
 int loadBeanDefinitions(Resource resource)
          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 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.
 
Methods inherited from class org.springframework.beans.factory.support.AbstractBeanDefinitionReader
getBeanClassLoader, getBeanFactory, setBeanClassLoader
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlBeanDefinitionReader

public XmlBeanDefinitionReader(BeanDefinitionRegistry beanFactory)
Create new XmlBeanDefinitionReader for the given bean factory.

Method Detail

setValidating

public void setValidating(boolean validating)
Set if the XML parser should validate the document and thus enforce a DTD.


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.

See Also:
BeansDtdResolver

setParserClass

public void setParserClass(Class parserClass)
Set the XmlBeanDefinitionParser implementation to use, responsible for the actual parsing of XML bean definitions. Default is DefaultXmlBeanDefinitionParser.

See Also:
XmlBeanDefinitionParser, DefaultXmlBeanDefinitionParser

loadBeanDefinitions

public int loadBeanDefinitions(Resource resource)
                        throws BeansException
Load bean definitions from the specified XML file.

Parameters:
resource - the resource descriptor for the XML file
Returns:
the number of bean definitions found
Throws:
BeansException - in case of loading or parsing errors

registerBeanDefinitions

public int registerBeanDefinitions(Document doc,
                                   Resource resource)
                            throws BeansException
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:
doc - the DOM document
resource - the resource descriptor (for context information)
Throws:
BeansException - in case of parsing errors
See Also:
loadBeanDefinitions(org.springframework.core.io.Resource), setParserClass(java.lang.Class), XmlBeanDefinitionParser.registerBeanDefinitions(org.springframework.beans.factory.support.BeanDefinitionReader, org.w3c.dom.Document, org.springframework.core.io.Resource)


Copyright (C) 2003-2004 The Spring Framework Project.