org.springframework.beans.factory.xml
Class XmlBeanFactory

java.lang.Object
  extended byorg.springframework.beans.factory.support.AbstractBeanFactory
      extended byorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory
          extended byorg.springframework.beans.factory.support.DefaultListableBeanFactory
              extended byorg.springframework.beans.factory.xml.XmlBeanFactory
All Implemented Interfaces:
AutowireCapableBeanFactory, BeanDefinitionRegistry, BeanFactory, ConfigurableBeanFactory, ConfigurableListableBeanFactory, HierarchicalBeanFactory, ListableBeanFactory

public class XmlBeanFactory
extends DefaultListableBeanFactory

Convenience extension of DefaultListableBeanFactory that reads bean definitions from an XML document. Delegates to XmlBeanDefinitionReader underneath; effectively equivalent to using an XmlBeanDefinitionReader with 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. See "spring-beans.dtd" for details on options and configuration style.

Since:
15 April 2001
Author:
Rod Johnson, Juergen Hoeller
See Also:
DefaultListableBeanFactory, XmlBeanDefinitionReader

Field Summary
 
Fields inherited from class org.springframework.beans.factory.support.AbstractBeanFactory
logger
 
Fields inherited from interface org.springframework.beans.factory.BeanFactory
FACTORY_BEAN_PREFIX
 
Fields inherited from interface org.springframework.beans.factory.config.AutowireCapableBeanFactory
AUTOWIRE_AUTODETECT, AUTOWIRE_BY_NAME, AUTOWIRE_BY_TYPE, AUTOWIRE_CONSTRUCTOR
 
Constructor Summary
XmlBeanFactory(InputStream is)
          Deprecated. Use XmlBeanFactory(Resource) instead, if necessary with an InputStreamResource parameter.
XmlBeanFactory(Resource resource)
          Create a new XmlBeanFactory with the given resource, 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, findMatchingBeans, getBeanDefinition, getBeanDefinitionCount, getBeanDefinitionNames, getBeanDefinitionNames, getBeansOfType, getBeansOfType, preInstantiateSingletons, registerBeanDefinition, setAllowBeanDefinitionOverriding, toString
 
Methods inherited from class org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory
applyBeanPostProcessorsAfterInitialization, applyBeanPostProcessorsAfterInitialization, applyBeanPostProcessorsBeforeInitialization, applyBeanPostProcessorsBeforeInitialization, applyBeanPropertyValues, autowire, autowireBeanProperties, autowireByName, autowireByType, autowireConstructor, createBean, createBean, dependencyCheck, getIgnoredDependencyTypes, ignoreDependencyType, instantiateUsingFactoryMethod, invokeCustomInitMethod, invokeInitMethods, populateBean, resolveValueIfNecessary, setInstantiationStrategy, unsatisfiedObjectProperties
 
Methods inherited from class org.springframework.beans.factory.support.AbstractBeanFactory
addBeanPostProcessor, addSingleton, checkMergedBeanDefinition, containsBean, containsSingleton, createBeanWrapper, destroyBean, destroySingletons, getAliases, getBean, getBean, getBean, getBean, getBeanPostProcessors, getCustomEditors, getMergedBeanDefinition, getMergedBeanDefinition, getObjectForSharedInstance, getParentBeanFactory, getSingletonCount, getSingletonNames, getType, hasDestructionAwareBeanPostProcessors, initBeanWrapper, invokeCustomDestroyMethod, isFactoryBean, isFactoryDereference, isSingleton, registerAlias, registerCustomEditor, registerDependentBean, registerDisposableBean, registerDisposableBeanIfNecessary, registerSingleton, removeSingleton, setParentBeanFactory, transformedBeanName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.springframework.beans.factory.config.ConfigurableListableBeanFactory
ignoreDependencyType
 
Methods inherited from interface org.springframework.beans.factory.BeanFactory
containsBean, getAliases, getBean, getBean, getType, isSingleton
 
Methods inherited from interface org.springframework.beans.factory.config.AutowireCapableBeanFactory
applyBeanPostProcessorsAfterInitialization, applyBeanPostProcessorsBeforeInitialization, applyBeanPropertyValues, autowire, autowireBeanProperties
 
Methods inherited from interface org.springframework.beans.factory.config.ConfigurableBeanFactory
addBeanPostProcessor, containsSingleton, destroySingletons, registerAlias, registerCustomEditor, registerSingleton, setParentBeanFactory
 
Methods inherited from interface org.springframework.beans.factory.HierarchicalBeanFactory
getParentBeanFactory
 
Methods inherited from interface org.springframework.beans.factory.support.BeanDefinitionRegistry
getAliases, registerAlias
 

Constructor Detail

XmlBeanFactory

public XmlBeanFactory(Resource resource)
               throws 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 BeansException
Deprecated. Use XmlBeanFactory(Resource) instead, if necessary with an InputStreamResource parameter.

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 only kept for backwards compatibility and will be removed in a future version.

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

XmlBeanFactory

public XmlBeanFactory(Resource resource,
                      BeanFactory parentBeanFactory)
               throws 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


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