Top Description Methods
org.springframework.beans.factory.support

public Interface BeanDefinitionReader

Known Direct Implementers
org.springframework.beans.factory.support.AbstractBeanDefinitionReader
Imports
org.springframework.beans.factory.BeanDefinitionStoreException, org.springframework.core.io.Resource, .ResourceLoader, org.springframework.lang.Nullable

Simple interface for bean definition readers that specifies load methods with Resource and String location parameters.

Concrete bean definition readers can of course add additional load and register methods for bean definitions, specific to their bean definition format.

Note that a bean definition reader does not have to implement this interface. It only serves as a suggestion for bean definition readers that want to follow standard naming conventions.

Author
Juergen Hoeller
Since
1.1
See Also
org.springframework.core.io.Resource

Method Summary

Modifier and TypeMethod and Description
public ClassLoader
getBeanClassLoader()

Return the class loader to use for bean classes.

public BeanNameGenerator
getBeanNameGenerator()

Return the BeanNameGenerator to use for anonymous beans (without explicit bean name specified).

public BeanDefinitionRegistry
getRegistry()

Return the bean factory to register the bean definitions with.

public ResourceLoader
getResourceLoader()

Return the ResourceLoader to use for resource locations.

public int

Returns:

the number of bean definitions found
loadBeanDefinitions
(Resource
the resource descriptor
resource
)

Load bean definitions from the specified resource.

public int

Returns:

the number of bean definitions found
loadBeanDefinitions
(Resource...
the resource descriptors
resources
)

Load bean definitions from the specified resources.

public int

Returns:

the number of bean definitions found
loadBeanDefinitions
(String
the resource location, to be loaded with the ResourceLoader (or ResourcePatternResolver) of this bean definition reader
location
)

Load bean definitions from the specified resource location.

public int

Returns:

the number of bean definitions found
loadBeanDefinitions
(String...
the resource locations, to be loaded with the ResourceLoader (or ResourcePatternResolver) of this bean definition reader
locations
)

Load bean definitions from the specified resource locations.

Method Detail

getBeanClassLoaderback to summary
public ClassLoader getBeanClassLoader()

Return the class loader to use for bean classes.

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

Annotations
@Nullable
getBeanNameGeneratorback to summary
public BeanNameGenerator getBeanNameGenerator()

Return the BeanNameGenerator to use for anonymous beans (without explicit bean name specified).

getRegistryback to summary
public BeanDefinitionRegistry getRegistry()

Return the bean factory to register the bean definitions with.

The factory is exposed through the BeanDefinitionRegistry interface, encapsulating the methods that are relevant for bean definition handling.

getResourceLoaderback to summary
public ResourceLoader getResourceLoader()

Return the ResourceLoader to use for resource locations.

Can be checked for the ResourcePatternResolver interface and cast accordingly, for loading multiple resources for a given resource pattern.

A null return 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 explicit ResourceLoader handling.

Annotations
@Nullable
See Also
loadBeanDefinitions(String), org.springframework.core.io.support.ResourcePatternResolver
loadBeanDefinitionsback to summary
public int loadBeanDefinitions(Resource resource) throws BeanDefinitionStoreException

Load bean definitions from the specified resource.

Parameters
resource:Resource

the resource descriptor

Returns:int

the number of bean definitions found

Exceptions
BeanDefinitionStoreException:
in case of loading or parsing errors
loadBeanDefinitionsback to summary
public int loadBeanDefinitions(Resource... resources) throws BeanDefinitionStoreException

Load bean definitions from the specified resources.

Parameters
resources:Resource[]

the resource descriptors

Returns:int

the number of bean definitions found

Exceptions
BeanDefinitionStoreException:
in case of loading or parsing errors
loadBeanDefinitionsback to summary
public int loadBeanDefinitions(String location) 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:String

the resource location, to be loaded with the ResourceLoader (or ResourcePatternResolver) of this bean definition reader

Returns:int

the number of bean definitions found

Exceptions
BeanDefinitionStoreException:
in case of loading or parsing errors
See Also
getResourceLoader(), loadBeanDefinitions(org.springframework.core.io.Resource), loadBeanDefinitions(org.springframework.core.io.Resource[])
loadBeanDefinitionsback to summary
public int loadBeanDefinitions(String... locations) throws BeanDefinitionStoreException

Load bean definitions from the specified resource locations.

Parameters
locations:String[]

the resource locations, to be loaded with the ResourceLoader (or ResourcePatternResolver) of this bean definition reader

Returns:int

the number of bean definitions found

Exceptions
BeanDefinitionStoreException:
in case of loading or parsing errors