|
From: <jue...@we...> - 2003-11-04 15:22:54
|
Effectively, FactoryBean.isSingleton just gives a hint whether getObject =
will return a cached singleton or a new instance on each call. =
Currently, this is just evaluated for getBeansOfType checks. The =
singleton flag of the bean definition on the other hand determines how =
the bean factory treats the FactoryBean itself.
If the FactoryBean is not a singleton, each reference to it will create =
a new FactoryBean in the bean factory. That instance can in turn return =
an internally cached singleton on getObject or a new object on each =
call. Obviously, a non-singleton FactoryBean that returns a singleton =
object does not make much sense.
So if you implement FactoryBean.isSingleton =3D false and =
correspondingly create a new instance on each getObject call to your =
FactoryBean, bean references will always get a new object. Making the =
FactoryBean itself a singleton too is orthogonal to this; you will =
almost always have it as singleton.
So there are two independent singleton statuses involved:
- the one of the FactoryBean: Should the bean factory create a new =
FactoryBean on each reference?
- the one of the object created by the FactoryBean: Does the FactoryBean =
create a new object on each getObject call?
Juergen
-----Original Message-----
From: spr...@li...
[mailto:spr...@li...]On Behalf
Of Cameron Braid
Sent: Tuesday, November 04, 2003 4:06 PM
To: spr...@li...
Subject: [[W3-SPAM]] - [Springframework-developer] Question about Bean
Factories - the Singleton attribute/property - Email found in subject
I am implementing a bean factory that is not a singleton.
There are two places where I can specify this property :
1) in the <bean singleton=3D"true|false|"> tag
2) in the boolean FactoryBean.isSingleton()
The doco states :
The singleton status of the FactoryBean itself will
* generally be provided by the owning BeanFactory.
Please explain how this works.
If I implement isSingleton =3D false, then someone configures <bean ...=20
singleton=3D"true" > what will happen ?
Thanks,
Cameron
--=20
Any damn fool can write code that a computer can understand...
The trick is to write code that humans can understand.
[Martin Fowler =
http://www.martinfowler.com/distributedComputing/refactoring.pdf]
-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive? Does it
help you create better code? SHARE THE LOVE, and help us help
YOU! Click Here: http://sourceforge.net/donate/
_______________________________________________
Springframework-developer mailing list
Spr...@li...
https://lists.sourceforge.net/lists/listinfo/springframework-developer
|