public class

ProviderCreatingFactoryBean

extends AbstractFactoryBean<T>
java.lang.Object
   ↳ org.springframework.beans.factory.config.AbstractFactoryBean<T>
     ↳ org.springframework.beans.factory.config.ProviderCreatingFactoryBean

Class Overview

A FactoryBean implementation that returns a value which is a JSR-330 javax.inject.Provider that in turn returns a bean sourced from a 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.

See Also

Summary

[Expand]
Inherited Fields
From class org.springframework.beans.factory.config.AbstractFactoryBean
Public Constructors
ProviderCreatingFactoryBean()
Public Methods
void afterPropertiesSet()
Eagerly create the singleton instance, if necessary.
Class getObjectType()
This abstract method declaration mirrors the method in the FactoryBean interface, for a consistent offering of abstract template methods.
void setTargetBeanName(String targetBeanName)
Set the name of the target bean.
Protected Methods
Provider createInstance()
Template method that subclasses must override to construct the object returned by this factory.
[Expand]
Inherited Methods
From class org.springframework.beans.factory.config.AbstractFactoryBean
From class java.lang.Object
From interface org.springframework.beans.factory.BeanClassLoaderAware
From interface org.springframework.beans.factory.BeanFactoryAware
From interface org.springframework.beans.factory.DisposableBean
From interface org.springframework.beans.factory.FactoryBean
From interface org.springframework.beans.factory.InitializingBean

Public Constructors

public ProviderCreatingFactoryBean ()

Also: SpringBeans

Public Methods

public void afterPropertiesSet ()

Also: SpringBeans

Eagerly create the singleton instance, if necessary.

Throws
Exception

public Class getObjectType ()

Also: SpringBeans

This abstract method declaration mirrors the method in the FactoryBean interface, for a consistent offering of abstract template methods.

Returns
  • the type of object that this FactoryBean creates, or null if not known at the time of the call

public void setTargetBeanName (String targetBeanName)

Also: SpringBeans

Set the name of the target bean.

The target does not have to be a non-singleton bean, but realisticially 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).

Protected Methods

protected Provider createInstance ()

Also: SpringBeans

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 getObject() call.

Returns
  • the object returned by this factory