org.springframework.beans.factory.support
Class AbstractBeanDefinitionReader

java.lang.Object
  extended byorg.springframework.beans.factory.support.AbstractBeanDefinitionReader
All Implemented Interfaces:
BeanDefinitionReader
Direct Known Subclasses:
PropertiesBeanDefinitionReader, XmlBeanDefinitionReader

public abstract class AbstractBeanDefinitionReader
extends Object
implements BeanDefinitionReader

Abstract base class for bean definition readers which implement the 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
See Also:
BeanDefinitionReaderUtils

Field Summary
protected  Log logger
           
 
Constructor Summary
protected AbstractBeanDefinitionReader(BeanDefinitionRegistry beanFactory)
          Create a new AbstractBeanDefinitionReader for the given factory.
 
Method Summary
 ClassLoader getBeanClassLoader()
          Return the class loader to use for bean classes.
 BeanDefinitionRegistry getBeanFactory()
          Return the bean factory to register the bean definitions with.
 ResourceLoader getResourceLoader()
          Return the resource loader to use for resource locations.
 int loadBeanDefinitions(Resource[] resources)
          Load bean definitions from the specified resources.
 void setBeanClassLoader(ClassLoader beanClassLoader)
          Set the ClassLoader to use for bean classes.
 void setResourceLoader(ResourceLoader resourceLoader)
          Set the ResourceLoader to use for resource locations.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.springframework.beans.factory.support.BeanDefinitionReader
loadBeanDefinitions
 

Field Detail

logger

protected final Log logger
Constructor Detail

AbstractBeanDefinitionReader

protected AbstractBeanDefinitionReader(BeanDefinitionRegistry beanFactory)
Create a new AbstractBeanDefinitionReader for the given factory.

Parameters:
beanFactory - the bean factory to work on
Method Detail

getBeanFactory

public BeanDefinitionRegistry getBeanFactory()
Description copied from interface: BeanDefinitionReader
Return the bean factory to register the bean definitions with.

Specified by:
getBeanFactory in interface BeanDefinitionReader

setBeanClassLoader

public void setBeanClassLoader(ClassLoader beanClassLoader)
Set the ClassLoader to use for bean classes. Default is the thread context class loader.

Setting this to null suggests to not load bean classes but just register bean definitions with class names, for example when just registering beans in a registry but not actually instantiating them in a factory.

See Also:
Thread.getContextClassLoader()

getBeanClassLoader

public ClassLoader getBeanClassLoader()
Description copied from interface: BeanDefinitionReader
Return the class loader to use for bean classes.

Null suggests to not load bean classes but just register bean definitions with class names, for example when just registering beans in a registry but not actually instantiating them in a factory.

Specified by:
getBeanClassLoader in interface BeanDefinitionReader

setResourceLoader

public void setResourceLoader(ResourceLoader resourceLoader)
Set the ResourceLoader to use for resource locations. Default is DefaultResourceLoader.

Can also be a ResourcePatternResolver, additionally capable of resolving resource patterns to Resource arrays.

Setting this to null suggests that absolute resource loading is not available for this bean definition reader.

See Also:
DefaultResourceLoader, ResourcePatternResolver

getResourceLoader

public ResourceLoader getResourceLoader()
Description copied from interface: BeanDefinitionReader
Return the resource loader to use for resource locations. Can be checked for the ResourcePatternResolver interface and cast accordingly, for loading multiple resources for a given resource pattern.

Null 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 resource loading.

Specified by:
getResourceLoader in interface BeanDefinitionReader
See Also:
ResourcePatternResolver

loadBeanDefinitions

public int loadBeanDefinitions(Resource[] resources)
                        throws BeansException
Description copied from interface: BeanDefinitionReader
Load bean definitions from the specified resources.

Specified by:
loadBeanDefinitions in interface BeanDefinitionReader
Parameters:
resources - the resource descriptors
Returns:
the number of bean definitions found
Throws:
BeansException - in case of loading or parsing errors


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