org.springframework.beans.factory.xml
Class XmlBeanFactory

org.springframework.beans.factory.support.AbstractBeanFactory
  |
  +--org.springframework.beans.factory.support.DefaultListableBeanFactory
        |
        +--org.springframework.beans.factory.xml.XmlBeanFactory

public class XmlBeanFactory
extends DefaultListableBeanFactory

Convenience extension of DefaultListableBeanFactory that reads bean definitions from an XML document. Delegates to DefaultXmlBeanDefinitionReader underneath; effectively equivalent to using a DefaultXmlBeanDefinitionReader for 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 DefaultListableBeanFactory superclass, and relies on the latter's implementation of the BeanFactory interface. It supports singletons, prototypes and references to either of these kinds of bean.

Author:
Rod Johnson, Juergen Hoeller
Version: $Id: XmlBeanFactory.java,v 1.24 2004/01/14 17:09:13 jhoeller Exp $
Since: 15 April 2001

Fields inherited from class org.springframework.beans.factory.support.AbstractBeanFactory
FACTORY_BEAN_PREFIX

Constructor Summary
XmlBeanFactory(Resource resource)
          Create a new XmlBeanFactory with the given resource, which must be parsable using DOM.
XmlBeanFactory(InputStream is)
          Create a new XmlBeanFactory with the given InputStream, which must be parsable using DOM.
XmlBeanFactory(Resource resource, BeanFactory parentBeanFactory)
          Create a new XmlBeanFactory with the given input stream, which must be parsable using DOM.

Methods inherited from class org.springframework.beans.factory.support.DefaultListableBeanFactory
containsBeanDefinition, getBeanDefinition, getBeanDefinitionCount, getBeanDefinitionNames, getBeanDefinitionNames, getBeansOfType, preInstantiateSingletons, registerBeanDefinition, setAllowBeanDefinitionOverriding, toString

Methods inherited from class org.springframework.beans.factory.support.AbstractBeanFactory
addBeanPostProcessor, applyBeanPostProcessorsAfterInitialization, applyBeanPostProcessorsBeforeInitialization, autowire, autowireBeanProperties, containsBean, destroySingletons, getAliases, getBean, getBean, getBeanPostProcessors, getConstructorArgumentValues, getCustomEditors, getIgnoredDependencyTypes, getMergedBeanDefinition, getParentBeanFactory, getPropertyValues, getSingletonNames, ignoreDependencyType, isSingleton, registerAlias, registerCustomEditor, registerSingleton, setParentBeanFactory

Constructor Detail

XmlBeanFactory

public XmlBeanFactory(Resource resource)
throws org.springframework.beans.BeansException
Create a new XmlBeanFactory with the given resource, which must be parsable using DOM.
Parameters:
resource - XML resource to load bean definitions from
Throws:
BeansException - in case of loading or parsing errors

XmlBeanFactory

public XmlBeanFactory(InputStream is)
throws org.springframework.beans.BeansException
Create a new XmlBeanFactory with the given InputStream, which must be parsable using DOM.

It's preferable to use a Resource argument instead of an InputStream, to retain location information. This constructor is mainly kept for backward compatibility.

Parameters:
is - XML InputStream to load bean definitions from
Throws:
BeansException - in case of loading or parsing errors
See Also:
#XmlBeanFactory(Resource)

XmlBeanFactory

public XmlBeanFactory(Resource resource, BeanFactory parentBeanFactory)
throws org.springframework.beans.BeansException
Create a new XmlBeanFactory with the given input stream, which must be parsable using DOM.
Parameters:
resource - XML resource to load bean definitions from
parentBeanFactory - parent bean factory
Throws:
BeansException - in case of loading or parsing errors

Association Links

to Class org.springframework.beans.factory.xml.XmlBeanDefinitionReader