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

Since:
15 April 2001
Version:
$Id: XmlBeanFactory.java,v 1.25 2004/03/18 02:46:12 trisberg Exp $
Author:
Rod Johnson, Juergen Hoeller

Field Summary
 
Fields inherited from class org.springframework.beans.factory.support.AbstractBeanFactory
FACTORY_BEAN_PREFIX, logger
 
Fields inherited from interface org.springframework.beans.factory.config.AutowireCapableBeanFactory
AUTOWIRE_AUTODETECT, AUTOWIRE_BY_NAME, AUTOWIRE_BY_TYPE, AUTOWIRE_CONSTRUCTOR
 
Constructor Summary
XmlBeanFactory(java.io.InputStream is)
          Create a new XmlBeanFactory with the given InputStream, which must be parsable using DOM.
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, getDependingBeanNames, preInstantiateSingletons, registerBeanDefinition, setAllowBeanDefinitionOverriding, toString
 
Methods inherited from class org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory
applyBeanPostProcessorsAfterInitialization, applyBeanPostProcessorsBeforeInitialization, applyPropertyValues, autowire, autowireBeanProperties, autowireByName, autowireByType, autowireConstructor, createBean, dependencyCheck, destroyBean, destroySingletons, invokeCustomDestroyMethod, invokeInitMethods, populateBean, resolveManagedList, resolveManagedMap, resolveManagedSet, resolveReference, resolveValueIfNecessary, unsatisfiedObjectProperties
 
Methods inherited from class org.springframework.beans.factory.support.AbstractBeanFactory
addBeanPostProcessor, addSingleton, containsBean, destroySingleton, getAliases, getBean, getBean, getBeanPostProcessors, getCustomEditors, getIgnoredDependencyTypes, getMergedBeanDefinition, getMergedBeanDefinition, getObjectForSharedInstance, getParentBeanFactory, getSingletonNames, ignoreDependencyType, initBeanWrapper, isFactoryDereference, isSingleton, registerAlias, registerCustomEditor, registerSingleton, 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.BeanFactory
containsBean, getAliases, getBean, getBean, isSingleton
 
Methods inherited from interface org.springframework.beans.factory.config.ConfigurableBeanFactory
addBeanPostProcessor, destroySingletons, ignoreDependencyType, registerAlias, registerCustomEditor, registerSingleton, setParentBeanFactory
 
Methods inherited from interface org.springframework.beans.factory.HierarchicalBeanFactory
getParentBeanFactory
 
Methods inherited from interface org.springframework.beans.factory.config.AutowireCapableBeanFactory
applyBeanPostProcessorsAfterInitialization, applyBeanPostProcessorsBeforeInitialization, autowire, autowireBeanProperties
 
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(java.io.InputStream is)
               throws 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 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.