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 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.

Since:
26.11.2003
Author:
Juergen Hoeller
See Also:
setParserClass(java.lang.Class)

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(org.w3c.dom.Document doc, Resource resource)
          Register the bean definitions contained in the given DOM document.
 void setEntityResolver(org.xml.sax.EntityResolver entityResolver)
          Set a SAX entity resolver to be used for parsing.
 void setParserClass(java.lang.Class parserClass)
          Set the XmlBeanDefinitionParser implementation to use.
 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(org.xml.sax.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(java.lang.Class parserClass)
Set the XmlBeanDefinitionParser implementation to use. 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(org.w3c.dom.Document doc,
                                   Resource resource)
                            throws BeansException
Register the bean definitions contained in the given DOM document. All calls go through this.

Parameters:
doc - the DOM document
resource - the resource descriptor (for context information)
Throws:
BeansException - in case of parsing errors


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