Class AbstractBeanDefinitionReader
- All Implemented Interfaces:
- BeanDefinitionReader,- EnvironmentCapable
- Direct Known Subclasses:
- GroovyBeanDefinitionReader,- PropertiesBeanDefinitionReader,- XmlBeanDefinitionReader
BeanDefinitionReader interface.
 Provides common properties like the bean factory to work on and the class loader to use for loading bean classes.
- Since:
- 11.12.2003
- Author:
- Juergen Hoeller, Chris Beams
- See Also:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected final org.apache.commons.logging.LogLogger available to subclasses.
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedCreate a new AbstractBeanDefinitionReader for the given bean factory.
- 
Method SummaryModifier and TypeMethodDescriptionReturn the class loader to use for bean classes.Return theBeanNameGeneratorto use for anonymous beans (without explicit bean name specified).Return theEnvironmentassociated with this component.final BeanDefinitionRegistryReturn the bean factory to register the bean definitions with.Return theResourceLoaderto use for resource locations.intloadBeanDefinitions(String location) Load bean definitions from the specified resource location.intloadBeanDefinitions(String... locations) Load bean definitions from the specified resource locations.intloadBeanDefinitions(String location, @Nullable Set<Resource> actualResources) Load bean definitions from the specified resource location.intloadBeanDefinitions(Resource... resources) Load bean definitions from the specified resources.voidsetBeanClassLoader(@Nullable ClassLoader beanClassLoader) Set the ClassLoader to use for bean classes.voidsetBeanNameGenerator(@Nullable BeanNameGenerator beanNameGenerator) Set the BeanNameGenerator to use for anonymous beans (without explicit bean name specified).voidsetEnvironment(Environment environment) Set the Environment to use when reading bean definitions.voidsetResourceLoader(@Nullable ResourceLoader resourceLoader) Set the ResourceLoader to use for resource locations.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.beans.factory.support.BeanDefinitionReaderloadBeanDefinitions
- 
Field Details- 
loggerprotected final org.apache.commons.logging.Log loggerLogger available to subclasses.
 
- 
- 
Constructor Details- 
AbstractBeanDefinitionReaderCreate a new AbstractBeanDefinitionReader for the given bean factory.If the passed-in bean factory does not only implement the BeanDefinitionRegistry interface but also the ResourceLoader interface, it will be used as default ResourceLoader as well. This will usually be the case for ApplicationContextimplementations.If given a plain BeanDefinitionRegistry, the default ResourceLoader will be a PathMatchingResourcePatternResolver.If the passed-in bean factory also implements EnvironmentCapableits environment will be used by this reader. Otherwise, the reader will initialize and use aStandardEnvironment. All ApplicationContext implementations are EnvironmentCapable, while normal BeanFactory implementations are not.- Parameters:
- registry- the BeanFactory to load bean definitions into, in the form of a BeanDefinitionRegistry
- See Also:
 
 
- 
- 
Method Details- 
getRegistryDescription copied from interface:BeanDefinitionReaderReturn the bean factory to register the bean definitions with.The factory is exposed through the BeanDefinitionRegistryinterface, encapsulating the methods that are relevant for bean definition handling.- Specified by:
- getRegistryin interface- BeanDefinitionReader
 
- 
setResourceLoaderSet the ResourceLoader to use for resource locations. If specifying a ResourcePatternResolver, the bean definition reader will be capable of resolving resource patterns to Resource arrays.Default is PathMatchingResourcePatternResolver, also capable of resource pattern resolving through the ResourcePatternResolver interface. Setting this to nullsuggests that absolute resource loading is not available for this bean definition reader.- See Also:
 
- 
getResourceLoaderDescription copied from interface:BeanDefinitionReaderReturn theResourceLoaderto use for resource locations.Can be checked for the ResourcePatternResolverinterface and cast accordingly, for loading multiple resources for a given resource pattern.A nullreturn value suggests that absolute resource loading is not available for this bean definition reader.This is mainly meant to be used for importing further resources from within a bean definition resource, for example via the "import" tag in XML bean definitions. It is recommended, however, to apply such imports relative to the defining resource; only explicit full resource locations will trigger absolute path based resource loading. There is also a loadBeanDefinitions(String)method available, for loading bean definitions from a resource location (or location pattern). This is a convenience to avoid explicitResourceLoaderhandling.- Specified by:
- getResourceLoaderin interface- BeanDefinitionReader
- See Also:
 
- 
setBeanClassLoaderSet the ClassLoader to use for bean classes.Default is null, which suggests to not load bean classes eagerly but rather to just register bean definitions with class names, with the corresponding Classes to be resolved later (or never).- See Also:
 
- 
getBeanClassLoaderDescription copied from interface:BeanDefinitionReaderReturn the class loader to use for bean classes.nullsuggests to not load bean classes eagerly but rather to just register bean definitions with class names, with the corresponding classes to be resolved later (or never).- Specified by:
- getBeanClassLoaderin interface- BeanDefinitionReader
 
- 
setEnvironmentSet the Environment to use when reading bean definitions. Most often used for evaluating profile information to determine which bean definitions should be read and which should be omitted.
- 
getEnvironmentDescription copied from interface:EnvironmentCapableReturn theEnvironmentassociated with this component.- Specified by:
- getEnvironmentin interface- EnvironmentCapable
 
- 
setBeanNameGeneratorSet the BeanNameGenerator to use for anonymous beans (without explicit bean name specified).Default is a DefaultBeanNameGenerator.
- 
getBeanNameGeneratorDescription copied from interface:BeanDefinitionReaderReturn theBeanNameGeneratorto use for anonymous beans (without explicit bean name specified).- Specified by:
- getBeanNameGeneratorin interface- BeanDefinitionReader
 
- 
loadBeanDefinitionsDescription copied from interface:BeanDefinitionReaderLoad bean definitions from the specified resources.- Specified by:
- loadBeanDefinitionsin interface- BeanDefinitionReader
- Parameters:
- resources- the resource descriptors
- Returns:
- the number of bean definitions found
- Throws:
- BeanDefinitionStoreException- in case of loading or parsing errors
 
- 
loadBeanDefinitionsDescription copied from interface:BeanDefinitionReaderLoad bean definitions from the specified resource location.The location can also be a location pattern, provided that the ResourceLoaderof this bean definition reader is aResourcePatternResolver.- Specified by:
- loadBeanDefinitionsin interface- BeanDefinitionReader
- Parameters:
- location- the resource location, to be loaded with the- ResourceLoader(or- ResourcePatternResolver) of this bean definition reader
- Returns:
- the number of bean definitions found
- Throws:
- BeanDefinitionStoreException- in case of loading or parsing errors
- See Also:
 
- 
loadBeanDefinitionspublic int loadBeanDefinitions(String location, @Nullable Set<Resource> actualResources) throws BeanDefinitionStoreException Load bean definitions from the specified resource location.The location can also be a location pattern, provided that the ResourceLoader of this bean definition reader is a ResourcePatternResolver. - Parameters:
- location- the resource location, to be loaded with the ResourceLoader (or ResourcePatternResolver) of this bean definition reader
- actualResources- a Set to be filled with the actual Resource objects that have been resolved during the loading process. May be- nullto indicate that the caller is not interested in those Resource objects.
- Returns:
- the number of bean definitions found
- Throws:
- BeanDefinitionStoreException- in case of loading or parsing errors
- See Also:
 
- 
loadBeanDefinitionsDescription copied from interface:BeanDefinitionReaderLoad bean definitions from the specified resource locations.- Specified by:
- loadBeanDefinitionsin interface- BeanDefinitionReader
- Parameters:
- locations- the resource locations, to be loaded with the- ResourceLoader(or- ResourcePatternResolver) of this bean definition reader
- Returns:
- the number of bean definitions found
- Throws:
- BeanDefinitionStoreException- in case of loading or parsing errors
 
 
-