Class SimpleInstantiationStrategy
java.lang.Object
org.springframework.beans.factory.support.SimpleInstantiationStrategy
- All Implemented Interfaces:
InstantiationStrategy
- Direct Known Subclasses:
CglibSubclassingInstantiationStrategy
Simple object instantiation strategy for use in a BeanFactory.
Does not support Method Injection, although it provides hooks for subclasses to override to add Method Injection support, for example by overriding methods.
- Since:
- 1.1
- Author:
- Rod Johnson, Juergen Hoeller
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Method
Return the factory method currently being invoked ornull
if none.instantiate
(RootBeanDefinition bd, String beanName, BeanFactory owner) Return an instance of the bean with the given name in this factory.instantiate
(RootBeanDefinition bd, String beanName, BeanFactory owner, Object factoryBean, Method factoryMethod, Object... args) Return an instance of the bean with the given name in this factory, creating it via the given factory method.instantiate
(RootBeanDefinition bd, String beanName, BeanFactory owner, Constructor<?> ctor, Object... args) Return an instance of the bean with the given name in this factory, creating it via the given constructor.protected Object
instantiateWithMethodInjection
(RootBeanDefinition bd, String beanName, BeanFactory owner) Subclasses can override this method, which is implemented to throw UnsupportedOperationException, if they can instantiate an object with the Method Injection specified in the given RootBeanDefinition.protected Object
instantiateWithMethodInjection
(RootBeanDefinition bd, String beanName, BeanFactory owner, Constructor<?> ctor, Object... args) Subclasses can override this method, which is implemented to throw UnsupportedOperationException, if they can instantiate an object with the Method Injection specified in the given RootBeanDefinition.
-
Constructor Details
-
SimpleInstantiationStrategy
public SimpleInstantiationStrategy()
-
-
Method Details
-
getCurrentlyInvokedFactoryMethod
Return the factory method currently being invoked ornull
if none.Allows factory method implementations to determine whether the current caller is the container itself as opposed to user code.
-
instantiate
Description copied from interface:InstantiationStrategy
Return an instance of the bean with the given name in this factory.- Specified by:
instantiate
in interfaceInstantiationStrategy
- Parameters:
bd
- the bean definitionbeanName
- the name of the bean when it is created in this context. The name can benull
if we are autowiring a bean which doesn't belong to the factory.owner
- the owning BeanFactory- Returns:
- a bean instance for this bean definition
-
instantiateWithMethodInjection
protected Object instantiateWithMethodInjection(RootBeanDefinition bd, @Nullable String beanName, BeanFactory owner) Subclasses can override this method, which is implemented to throw UnsupportedOperationException, if they can instantiate an object with the Method Injection specified in the given RootBeanDefinition. Instantiation should use a no-arg constructor. -
instantiate
public Object instantiate(RootBeanDefinition bd, @Nullable String beanName, BeanFactory owner, Constructor<?> ctor, Object... args) Description copied from interface:InstantiationStrategy
Return an instance of the bean with the given name in this factory, creating it via the given constructor.- Specified by:
instantiate
in interfaceInstantiationStrategy
- Parameters:
bd
- the bean definitionbeanName
- the name of the bean when it is created in this context. The name can benull
if we are autowiring a bean which doesn't belong to the factory.owner
- the owning BeanFactoryctor
- the constructor to useargs
- the constructor arguments to apply- Returns:
- a bean instance for this bean definition
-
instantiateWithMethodInjection
protected Object instantiateWithMethodInjection(RootBeanDefinition bd, @Nullable String beanName, BeanFactory owner, @Nullable Constructor<?> ctor, Object... args) Subclasses can override this method, which is implemented to throw UnsupportedOperationException, if they can instantiate an object with the Method Injection specified in the given RootBeanDefinition. Instantiation should use the given constructor and parameters. -
instantiate
public Object instantiate(RootBeanDefinition bd, @Nullable String beanName, BeanFactory owner, @Nullable Object factoryBean, Method factoryMethod, Object... args) Description copied from interface:InstantiationStrategy
Return an instance of the bean with the given name in this factory, creating it via the given factory method.- Specified by:
instantiate
in interfaceInstantiationStrategy
- Parameters:
bd
- the bean definitionbeanName
- the name of the bean when it is created in this context. The name can benull
if we are autowiring a bean which doesn't belong to the factory.owner
- the owning BeanFactoryfactoryBean
- the factory bean instance to call the factory method on, ornull
in case of a static factory methodfactoryMethod
- the factory method to useargs
- the factory method arguments to apply- Returns:
- a bean instance for this bean definition
-