|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.beans.factory.config.AbstractFactoryBean
Simple template superclass for FactoryBean implementations thats allows for creating a singleton or a prototype, depending on a flag.
If the "singleton" flag is "true" (the default), this class will
create once on initialization and subsequently return the singleton
instance. Else, this class will create a new instance each time.
Subclasses are responsible for implementing the abstract
createInstance
template method to actually create objects.
Field Summary | |
protected org.apache.commons.logging.Log |
logger
|
Constructor Summary | |
AbstractFactoryBean()
|
Method Summary | |
void |
afterPropertiesSet()
Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware). |
protected abstract java.lang.Object |
createInstance()
Template method that subclasses must override to construct the object returned by this factory. |
java.lang.Object |
getObject()
Return an instance (possibly shared or independent) of the object managed by this factory. |
boolean |
isSingleton()
Is the bean managed by this factory a singleton or a prototype? |
void |
setSingleton(boolean singleton)
Set if a singleton should be created, or a new object on each request else. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.springframework.beans.factory.FactoryBean |
getObjectType |
Field Detail |
protected final org.apache.commons.logging.Log logger
Constructor Detail |
public AbstractFactoryBean()
Method Detail |
public final void setSingleton(boolean singleton)
public final boolean isSingleton()
FactoryBean
The singleton status of the FactoryBean itself will generally be provided by the owning BeanFactory.
isSingleton
in interface FactoryBean
public final void afterPropertiesSet() throws java.lang.Exception
InitializingBean
This method allows the bean instance to perform initialization only possible when all bean properties have been set and to throw an exception in the event of misconfiguration.
afterPropertiesSet
in interface InitializingBean
java.lang.Exception
- in the event of misconfiguration (such
as failure to set an essential property) or if initialization fails.public final java.lang.Object getObject() throws java.lang.Exception
FactoryBean
getObject
in interface FactoryBean
java.lang.Exception
- in case of creation errorsprotected abstract java.lang.Object createInstance() throws java.lang.Exception
Invoked on initialization of this FactoryBean in case of a singleton; else, on each getObject() call.
java.lang.Exception
- if an exception occured during object creationgetObject()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |