public class DefaultBeanFactory extends Object implements BeanFactory
The default implementation of the BeanFactory
interface.
This class creates beans of arbitrary types using reflection. Each time the
createBean()
method is invoked, a new bean instance is
created. A default bean class is not supported.
An instance of this factory class will be set as the default bean factory for
the BeanHelper
class. This means that if not bean
factory is specified in a BeanDeclaration
, this
default instance will be used.
Modifier and Type | Field and Description |
---|---|
static DefaultBeanFactory |
INSTANCE
Stores the default instance of this class.
|
Constructor and Description |
---|
DefaultBeanFactory() |
Modifier and Type | Method and Description |
---|---|
Object |
createBean(Class<?> beanClass,
BeanDeclaration data,
Object parameter)
Creates a new bean instance.
|
protected Object |
createBeanInstance(Class<?> beanClass,
BeanDeclaration data)
Creates the bean instance.
|
Class<?> |
getDefaultBeanClass()
Returns the default bean class used by this factory.
|
protected void |
initBeanInstance(Object bean,
BeanDeclaration data)
Initializes the newly created bean instance.
|
public static final DefaultBeanFactory INSTANCE
public Object createBean(Class<?> beanClass, BeanDeclaration data, Object parameter) throws Exception
createBeanInstance()
and
initBeanInstance()
for creating and initializing the bean.
This makes it easier for derived classes that need to change specific
functionality of the base class.createBean
in interface BeanFactory
beanClass
- the class of the bean, from which an instance is to be
createddata
- the bean declaration objectparameter
- an additional parameter (ignored by this implementation)Exception
- if an error occurspublic Class<?> getDefaultBeanClass()
getDefaultBeanClass
in interface BeanFactory
protected Object createBeanInstance(Class<?> beanClass, BeanDeclaration data) throws Exception
createBean()
. It uses reflection to create a new instance
of the specified class.beanClass
- the class of the bean to be createddata
- the bean declarationException
- if an error occursprotected void initBeanInstance(Object bean, BeanDeclaration data) throws Exception
createBean()
. It calls the
initBean()
of BeanHelper
for performing the initialization.bean
- the newly created bean instancedata
- the bean declaration objectException
- if an error occursCopyright © 2001–2013 The Apache Software Foundation. All rights reserved.