org.springframework.beans.factory.xml
Class XmlBeanDefinitionReader

org.springframework.beans.factory.support.AbstractBeanDefinitionReader
  |
  +--org.springframework.beans.factory.xml.XmlBeanDefinitionReader

public class XmlBeanDefinitionReader
extends AbstractBeanDefinitionReader

Bean definition reader for Spring's default XML bean definition format. Typically applied to a DefaultListableBeanFactory.

The structure, element and attribute names of the required XML document are hard-coded in this class. (Of course a transform could be run if necessary to produce this format). "beans" doesn't need to be the root element of the XML document: This class will parse all bean definition elements in the XML file.

This class registers each bean definition with the given bean factory superclass, and relies on the latter's implementation of the BeanDefinitionRegistry interface. It supports singletons, prototypes, and references to either of these kinds of bean.

Author:
Juergen Hoeller
Version: $Id: XmlBeanDefinitionReader.java,v 1.7 2004/01/29 23:27:53 jhoeller Exp $
Since: 26.11.2003
See Also: setParserClass(java.lang.Class)

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

Method Summary
 voidloadBeanDefinitions(Resource resource)
          Load bean definitions from the specified XML file.
 voidregisterBeanDefinitions(Document doc, Resource resource)
          Register the bean definitions contained in the given DOM document.
 voidsetEntityResolver(EntityResolver entityResolver)
          Set a SAX entity resolver to be used for parsing.
 voidsetParserClass(Class parserClass)
          Set the XmlBeanDefinitionParser implementation to use.
 voidsetValidating(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

Constructor Detail

XmlBeanDefinitionReader

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

loadBeanDefinitions

public void loadBeanDefinitions(Resource resource)
throws org.springframework.beans.BeansException
Load bean definitions from the specified XML file.
Parameters:
resource - the resource descriptor for the XML file
Throws:
BeansException - in case of loading or parsing errors

registerBeanDefinitions

public void registerBeanDefinitions(Document doc, Resource resource)
throws org.springframework.beans.BeansException
Register the bean definitions contained in the given DOM document. All calls go through this.
Parameters:
doc - the DOM document
Throws:
BeansException - in case of parsing errors

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, e.g. relative to some specific base path.
See Also:
BeansDtdResolver

setParserClass

public void setParserClass(Class parserClass)
Set the XmlBeanDefinitionParser implementation to use. Default is DefaultXmlBeanDefinitionParser.
See Also:
XmlBeanDefinitionParser, DefaultXmlBeanDefinitionParser

setValidating

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

Association Links

to Class org.xml.sax.EntityResolver

to Class java.lang.Class