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.
Summary
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
void
|
afterPropertiesSet()
Eagerly create the singleton instance, if necessary.
|
abstract
T
|
createInstance()
Template method that subclasses must override to construct
the object returned by this factory.
|
void
|
destroy()
Destroy the singleton instance, if any.
|
void
|
destroyInstance(T instance)
Callback for destroying a singleton instance.
|
BeanFactory
|
getBeanFactory()
Return the BeanFactory that this bean runs in.
|
TypeConverter
|
getBeanTypeConverter()
Obtain a bean type converter from the BeanFactory that this bean
runs in.
|
Class[]
|
getEarlySingletonInterfaces()
Return an array of interfaces that a singleton object exposed by this
FactoryBean is supposed to implement, for use with an 'early singleton
proxy' that will be exposed in case of a circular reference.
|
final
T
|
getObject()
Expose the singleton instance or create a new prototype instance.
|
abstract
Class<?>
|
getObjectType()
This abstract method declaration mirrors the method in the FactoryBean
interface, for a consistent offering of abstract template methods.
|
boolean
|
isSingleton()
Is the object managed by this factory a singleton? That is,
will getObject() always return the same object
(a reference that can be cached)?
NOTE: If a FactoryBean indicates to hold a singleton object,
the object returned from getObject() might get cached
by the owning BeanFactory.
|
void
|
setBeanClassLoader(ClassLoader classLoader)
Callback that supplies the bean class loader to
a bean instance.
|
void
|
setBeanFactory(BeanFactory beanFactory)
Callback that supplies the owning factory to a bean instance.
|
void
|
setSingleton(boolean singleton)
Set if a singleton should be created, or a new object on each request
otherwise.
|
|
From class
java.lang.Object
Object
|
clone()
|
boolean
|
equals(Object arg0)
|
void
|
finalize()
|
final
Class<?>
|
getClass()
|
int
|
hashCode()
|
final
void
|
notify()
|
final
void
|
notifyAll()
|
String
|
toString()
|
final
void
|
wait()
|
final
void
|
wait(long arg0, int arg1)
|
final
void
|
wait(long arg0)
|
|
From interface
org.springframework.beans.factory.BeanClassLoaderAware
|
From interface
org.springframework.beans.factory.BeanFactoryAware
|
From interface
org.springframework.beans.factory.DisposableBean
abstract
void
|
destroy()
Invoked by a BeanFactory on destruction of a singleton.
|
|
From interface
org.springframework.beans.factory.FactoryBean
abstract
T
|
getObject()
Return an instance (possibly shared or independent) of the object
managed by this factory.
|
abstract
Class<?>
|
getObjectType()
Return the type of object that this FactoryBean creates,
or null if not known in advance.
|
abstract
boolean
|
isSingleton()
Is the object managed by this factory a singleton? That is,
will getObject() always return the same object
(a reference that can be cached)?
NOTE: If a FactoryBean indicates to hold a singleton object,
the object returned from getObject() might get cached
by the owning BeanFactory.
|
|
From interface
org.springframework.beans.factory.InitializingBean
abstract
void
|
afterPropertiesSet()
Invoked by a BeanFactory after it has set all bean properties supplied
(and satisfied BeanFactoryAware and ApplicationContextAware).
|
|
Public Constructors
public
ProviderCreatingFactoryBean
()
Public Methods
public
void
afterPropertiesSet
()
Eagerly create the singleton instance, if necessary.
public
Class
getObjectType
()
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)
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
()
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