spring-framework / org.springframework.beans.factory.config / ProviderCreatingFactoryBean

ProviderCreatingFactoryBean

open class ProviderCreatingFactoryBean : AbstractFactoryBean<Provider<Any>>

A org.springframework.beans.factory.FactoryBean implementation that returns a value which is a JSR-330 javax.inject.Provider that in turn returns a bean sourced from a org.springframework.beans.factory.BeanFactory.

This is basically a JSR-330 compliant variant of Spring's good old ObjectFactoryCreatingFactoryBean. It can be used for traditional external dependency injection configuration that targets a property or constructor argument of type javax.inject.Provider, as an alternative to JSR-330's @Inject annotation-driven approach.

Author
Juergen Hoeller

Since
3.0.2

See Also
javax.inject.ProviderObjectFactoryCreatingFactoryBean

Constructors

<init>

ProviderCreatingFactoryBean()

A org.springframework.beans.factory.FactoryBean implementation that returns a value which is a JSR-330 javax.inject.Provider that in turn returns a bean sourced from a org.springframework.beans.factory.BeanFactory.

This is basically a JSR-330 compliant variant of Spring's good old ObjectFactoryCreatingFactoryBean. It can be used for traditional external dependency injection configuration that targets a property or constructor argument of type javax.inject.Provider, as an alternative to JSR-330's @Inject annotation-driven approach.

Functions

afterPropertiesSet

open fun afterPropertiesSet(): Unit

getObjectType

open fun getObjectType(): Class<*>

setTargetBeanName

open fun setTargetBeanName(targetBeanName: String): Unit

Set the name of the target bean.

The target does not have to be a non-singleton bean, but realistically always will be (because if the target bean were a singleton, then said singleton bean could simply be injected straight into the dependent object, thus obviating the need for the extra level of indirection afforded by this factory approach).