站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > Spring Framework 2.0.5 API 文档英文版

XmlBeanFactory (Spring Framework API 2.0) - Spring Framework 2.0.5 API 文档英文版

The Spring Framework

org.springframework.beans.factory.xml
Class XmlBeanFactory

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

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_2_0.dtd" for details on options and configuration style.

For advanced needs, consider using a DefaultListableBeanFactory with an XmlBeanDefinitionReader. The latter allows for reading from multiple XML resources and is highly configurable in its actual XML parsing behavior.

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

Field Summary
 
Fields inherited from class org.springframework.beans.factory.support.DefaultSingletonBeanRegistry
logger
 
Fields inherited from interface org.springframework.beans.factory.config.AutowireCapableBeanFactory
AUTOWIRE_AUTODETECT, AUTOWIRE_BY_NAME, AUTOWIRE_BY_TYPE, AUTOWIRE_CONSTRUCTOR, AUTOWIRE_NO
 
Fields inherited from interface org.springframework.beans.factory.config.ConfigurableBeanFactory
SCOPE_PROTOTYPE, SCOPE_SINGLETON
 
Constructor Summary
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.
 
Method Summary
 
Methods inherited from class org.springframework.beans.factory.support.DefaultListableBeanFactory
containsBeanDefinition, copyConfigurationFrom, findAutowireCandidates, getBeanDefinition, getBeanDefinitionCount, getBeanDefinitionNames, getBeanNamesForType, getBeanNamesForType, getBeansOfType, getBeansOfType, preInstantiateSingletons, registerBeanDefinition, setAllowBeanDefinitionOverriding, setAllowEagerClassLoading, toString
 
Methods inherited from class org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory
applyBeanPostProcessorsAfterInitialization, applyBeanPostProcessorsBeforeInitialization, applyBeanPostProcessorsBeforeInstantiation, applyBeanPropertyValues, applyPropertyValues, autowire, autowireBeanProperties, autowireByName, autowireByType, autowireConstructor, checkDependencies, configureBean, createBean, createBean, createBeanInstance, determineConstructorFromBeanPostProcessors, filterPropertyDescriptorsForDependencyCheck, findMatchingBeans, getInstantiationStrategy, getTypeForFactoryBean, getTypeForFactoryMethod, ignoreDependencyInterface, ignoreDependencyType, initializeBean, initializeBean, instantiateBean, instantiateUsingFactoryMethod, invokeCustomInitMethod, invokeInitMethods, isExcludedFromDependencyCheck, populateBean, postProcessObjectFromFactoryBean, predictBeanType, removeSingleton, setAllowCircularReferences, setAllowRawInjectionDespiteWrapping, setInstantiationStrategy, unsatisfiedNonSimpleProperties
 
Methods inherited from class org.springframework.beans.factory.support.AbstractBeanFactory
addBeanPostProcessor, addPropertyEditorRegistrar, afterPrototypeCreation, beforePrototypeCreation, checkMergedBeanDefinition, containsBean, containsLocalBean, destroyBean, destroyBean, destroyScopedBean, getAliases, getBean, getBean, getBean, getBean, getBeanClassLoader, getBeanPostProcessorCount, getBeanPostProcessors, getCustomEditors, getMergedBeanDefinition, getMergedBeanDefinition, getMergedBeanDefinition, getMergedBeanDefinition, getObjectForBeanInstance, getParentBeanFactory, getPropertyEditorRegistrars, getRegisteredScope, getRegisteredScopeNames, getType, getTypeConverter, getTypeForFactoryBean, hasDestructionAwareBeanPostProcessors, hasInstantiationAwareBeanPostProcessors, initBeanWrapper, isAlias, isBeanClassMatch, isBeanNameInUse, isCacheBeanMetadata, isCurrentlyInCreation, isFactoryBean, isPrototype, isPrototypeCurrentlyInCreation, isSingleton, isTypeMatch, originalBeanName, registerAlias, registerCustomEditor, registerCustomEditors, registerDisposableBeanIfNecessary, registerScope, requiresDestruction, resolveBeanClass, setBeanClassLoader, setCacheBeanMetadata, setParentBeanFactory, transformedBeanName
 
Methods inherited from class org.springframework.beans.factory.support.DefaultSingletonBeanRegistry
addSingleton, afterSingletonCreation, beforeSingletonCreation, containsSingleton, destroyBean, destroySingleton, destroySingletons, getDependentBeans, getSingleton, getSingleton, getSingletonCount, getSingletonMutex, getSingletonNames, hasDependentBean, isSingletonCurrentlyInCreation, registerDependentBean, registerDisposableBean, registerSingleton
 
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
ignoreDependencyInterface, ignoreDependencyType
 
Methods inherited from interface org.springframework.beans.factory.config.AutowireCapableBeanFactory
applyBeanPostProcessorsAfterInitialization, applyBeanPostProcessorsBeforeInitialization, applyBeanPropertyValues, autowire, autowireBeanProperties, configureBean, createBean, initializeBean
 
Methods inherited from interface org.springframework.beans.factory.config.ConfigurableBeanFactory
addBeanPostProcessor, addPropertyEditorRegistrar, destroyBean, destroyScopedBean, destroySingletons, getBeanClassLoader, getBeanPostProcessorCount, getRegisteredScope, getRegisteredScopeNames, getTypeConverter, isCacheBeanMetadata, isCurrentlyInCreation, registerAlias, registerCustomEditor, registerScope, setBeanClassLoader, setCacheBeanMetadata, setParentBeanFactory
 
Methods inherited from interface org.springframework.beans.factory.HierarchicalBeanFactory
containsLocalBean, getParentBeanFactory
 
Methods inherited from interface org.springframework.beans.factory.config.SingletonBeanRegistry
containsSingleton, getSingleton, getSingletonCount, getSingletonNames, registerSingleton
 
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(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

The Spring Framework

Copyright © 2002-2007 The Spring Framework.