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

public Interface InstantiationStrategy

Known Direct Implementers
org.springframework.beans.factory.support.SimpleInstantiationStrategy
Imports
java.lang.reflect.Constructor, .Method, org.springframework.beans.BeansException, org.springframework.beans.factory.BeanFactory, org.springframework.lang.Nullable

Interface responsible for creating instances corresponding to a root bean definition.

This is pulled out into a strategy as various approaches are possible, including using CGLIB to create subclasses on the fly to support Method Injection.

Authors
Rod Johnson, Juergen Hoeller
Since
1.1

Method Summary

Modifier and TypeMethod and Description
public default Class<?>
getActualBeanClass(RootBeanDefinition bd, String beanName, BeanFactory owner)

Determine the actual class for the given bean definition, as instantiated at runtime.

public Object

Returns:

a bean instance for this bean definition
instantiate
(RootBeanDefinition
the bean definition
bd
,
String
the name of the bean when it is created in this context. The name can be null if we are autowiring a bean which doesn't belong to the factory.
beanName
,
BeanFactory
the owning BeanFactory
owner
)

Return an instance of the bean with the given name in this factory.

public Object

Returns:

a bean instance for this bean definition
instantiate
(RootBeanDefinition
the bean definition
bd
,
String
the name of the bean when it is created in this context. The name can be null if we are autowiring a bean which doesn't belong to the factory.
beanName
,
BeanFactory
the owning BeanFactory
owner
,
Constructor<?>
the constructor to use
ctor
,
Object...
the constructor arguments to apply
args
)

Return an instance of the bean with the given name in this factory, creating it via the given constructor.

public Object

Returns:

a bean instance for this bean definition
instantiate
(RootBeanDefinition
the bean definition
bd
,
String
the name of the bean when it is created in this context. The name can be null if we are autowiring a bean which doesn't belong to the factory.
beanName
,
BeanFactory
the owning BeanFactory
owner
,
Object
the factory bean instance to call the factory method on, or null in case of a static factory method
factoryBean
,
Method
the factory method to use
factoryMethod
,
Object...
the factory method arguments to apply
args
)

Return an instance of the bean with the given name in this factory, creating it via the given factory method.

Method Detail

getActualBeanClassback to summary
public default Class<?> getActualBeanClass(RootBeanDefinition bd, String beanName, BeanFactory owner)

Determine the actual class for the given bean definition, as instantiated at runtime.

Since
6.0
instantiateback to summary
public Object instantiate(RootBeanDefinition bd, String beanName, BeanFactory owner) throws BeansException

Return an instance of the bean with the given name in this factory.

Parameters
bd:RootBeanDefinition

the bean definition

beanName:String

the name of the bean when it is created in this context. The name can be null if we are autowiring a bean which doesn't belong to the factory.

owner:BeanFactory

the owning BeanFactory

Returns:Object

a bean instance for this bean definition

Exceptions
BeansException:
if the instantiation attempt failed
instantiateback to summary
public Object instantiate(RootBeanDefinition bd, String beanName, BeanFactory owner, Constructor<?> ctor, Object... args) throws BeansException

Return an instance of the bean with the given name in this factory, creating it via the given constructor.

Parameters
bd:RootBeanDefinition

the bean definition

beanName:String

the name of the bean when it is created in this context. The name can be null if we are autowiring a bean which doesn't belong to the factory.

owner:BeanFactory

the owning BeanFactory

ctor:Constructor<?>

the constructor to use

args:Object[]

the constructor arguments to apply

Returns:Object

a bean instance for this bean definition

Exceptions
BeansException:
if the instantiation attempt failed
instantiateback to summary
public Object instantiate(RootBeanDefinition bd, String beanName, BeanFactory owner, Object factoryBean, Method factoryMethod, Object... args) throws BeansException

Return an instance of the bean with the given name in this factory, creating it via the given factory method.

Parameters
bd:RootBeanDefinition

the bean definition

beanName:String

the name of the bean when it is created in this context. The name can be null if we are autowiring a bean which doesn't belong to the factory.

owner:BeanFactory

the owning BeanFactory

factoryBean:Object

the factory bean instance to call the factory method on, or null in case of a static factory method

factoryMethod:Method

the factory method to use

args:Object[]

the factory method arguments to apply

Returns:Object

a bean instance for this bean definition

Exceptions
BeansException:
if the instantiation attempt failed