org.springframework.beans.factory.FactoryBean implementation that
returns a value which is a JSR-330 jakarta.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 jakarta.inject.Provider, as an
alternative to JSR-330's @Inject annotation-driven approach.
jakarta.inject.Provider , ObjectFactoryCreatingFactoryBean
| Modifier and Type | Class and Description |
|---|---|
| private static class | ProviderCreatingFactoryBean.TargetBeanProvider
Independent inner class - for serialization purposes. |
| Modifier and Type | Field and Description |
|---|---|
| private String |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | afterPropertiesSet()
Overrides org. Implements org. |
| protected Provider | createInstance()
Implements abstract org. |
| public Class | getObjectType()
Implements abstract org. Implements org. |
| public void |
| targetBeanName | back to summary |
|---|---|
| private String targetBeanName
| |
| ProviderCreatingFactoryBean | back to summary |
|---|---|
| public ProviderCreatingFactoryBean() | |
| afterPropertiesSet | back to summary |
|---|---|
| public void afterPropertiesSet() throws Exception Overrides org. Implements org. Doc from org. Eagerly create the singleton instance, if necessary.
| |
| createInstance | back to summary |
|---|---|
| protected Provider Implements abstract org. Doc from org. Template method that subclasses must override to construct the object returned by this factory. Invoked on initialization of this FactoryBean in case of
a singleton; else, on each | |
| getObjectType | back to summary |
|---|---|
| public Class Implements abstract org. Implements org. Doc from org. This abstract method declaration mirrors the method in the FactoryBean interface, for a consistent offering of abstract template methods.
| |
| setTargetBeanName | back to summary |
|---|---|
| public void setTargetBeanName(String targetBeanName) 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). | |
| Modifier and Type | Field and Description |
|---|---|
| private final BeanFactory | |
| private final String |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public Object | get()
Implements jakarta. T.
|
| beanFactory | back to summary |
|---|---|
| private final BeanFactory beanFactory | |
| targetBeanName | back to summary |
|---|---|
| private final String targetBeanName | |
| TargetBeanProvider | back to summary |
|---|---|
| public TargetBeanProvider(BeanFactory beanFactory, String targetBeanName) | |
| get | back to summary |
|---|---|
| public Object get() throws BeansException Implements jakarta. Doc from jakarta. Provides a fully-constructed and injected instance of | |