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, Stephane Nicoll
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic MethodReturn the factory method currently being invoked ornullif 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.static <T> TinstantiateWithFactoryMethod(Method method, Supplier<T> instanceSupplier) Invoke the giveninstanceSupplierwith the factory method exposed as being invoked.protected ObjectinstantiateWithMethodInjection(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 ObjectinstantiateWithMethodInjection(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.static voidDeprecated, for removal: This API element is subject to removal in a future version.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.beans.factory.support.InstantiationStrategygetActualBeanClass
- 
Constructor Details- 
SimpleInstantiationStrategypublic SimpleInstantiationStrategy()
 
- 
- 
Method Details- 
getCurrentlyInvokedFactoryMethodReturn the factory method currently being invoked ornullif none.Allows factory method implementations to determine whether the current caller is the container itself as opposed to user code. 
- 
setCurrentlyInvokedFactoryMethod@Deprecated(since="6.2", forRemoval=true) public static void setCurrentlyInvokedFactoryMethod(@Nullable Method method) Deprecated, for removal: This API element is subject to removal in a future version.in favor ofinstantiateWithFactoryMethod(Method, Supplier)Set the factory method currently being invoked ornullto remove the current value, if any.- Parameters:
- method- the factory method currently being invoked or- null
- Since:
- 6.0
 
- 
instantiateWithFactoryMethodInvoke the giveninstanceSupplierwith the factory method exposed as being invoked.- Type Parameters:
- T- the type of the instance
- Parameters:
- method- the factory method to expose
- instanceSupplier- the instance supplier
- Returns:
- the result of the instance supplier
- Since:
- 6.2
 
- 
instantiateDescription copied from interface:InstantiationStrategyReturn an instance of the bean with the given name in this factory.- Specified by:
- instantiatein interface- InstantiationStrategy
- Parameters:
- bd- the bean definition
- beanName- the name of the bean when it is created in this context. The name can be- nullif we are autowiring a bean which doesn't belong to the factory.
- owner- the owning BeanFactory
- Returns:
- a bean instance for this bean definition
 
- 
instantiateWithMethodInjectionprotected 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.
- 
instantiatepublic Object instantiate(RootBeanDefinition bd, @Nullable String beanName, BeanFactory owner, Constructor<?> ctor, Object... args) Description copied from interface:InstantiationStrategyReturn an instance of the bean with the given name in this factory, creating it via the given constructor.- Specified by:
- instantiatein interface- InstantiationStrategy
- Parameters:
- bd- the bean definition
- beanName- the name of the bean when it is created in this context. The name can be- nullif we are autowiring a bean which doesn't belong to the factory.
- owner- the owning BeanFactory
- ctor- the constructor to use
- args- the constructor arguments to apply
- Returns:
- a bean instance for this bean definition
 
- 
instantiateWithMethodInjectionprotected 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.
- 
instantiatepublic Object instantiate(RootBeanDefinition bd, @Nullable String beanName, BeanFactory owner, @Nullable Object factoryBean, Method factoryMethod, Object... args) Description copied from interface:InstantiationStrategyReturn an instance of the bean with the given name in this factory, creating it via the given factory method.- Specified by:
- instantiatein interface- InstantiationStrategy
- Parameters:
- bd- the bean definition
- beanName- the name of the bean when it is created in this context. The name can be- nullif we are autowiring a bean which doesn't belong to the factory.
- owner- the owning BeanFactory
- factoryBean- the factory bean instance to call the factory method on, or- nullin case of a static factory method
- factoryMethod- the factory method to use
- args- the factory method arguments to apply
- Returns:
- a bean instance for this bean definition
 
 
- 
instantiateWithFactoryMethod(Method, Supplier)