|
From: Rainer S. <Rai...@ab...> - 2004-11-02 14:31:00
|
Aloha! I tried to use CommonsPoolTargetSource without success - calling beanFactory.getBean() always returns the same instance. I looked into CommonsPoolTargetSourceTests and as far as I can see it's not tested wether the pool is returning new objects or is working at all. Inspecting the objects returned by getBean() in testFunctionality() with a debugger shows both calls return the same SideEffectBean instance. Is this feature broken or am I missing something? Cheers, Rainer |
|
From: Dave B. <viv...@ya...> - 2004-11-02 23:02:28
|
See old forum post: https://sourceforge.net/forum/message.php?msg_id=2705933 -----Original Message----- From: spr...@li... [mailto:spr...@li...] On Behalf Of Rainer Schmitz Sent: Tuesday, November 02, 2004 9:31 To: spr...@li... Subject: [Springframework-developer] CommonsPoolTargetSource broken? Aloha! I tried to use CommonsPoolTargetSource without success - calling beanFactory.getBean() always returns the same instance. I looked into CommonsPoolTargetSourceTests and as far as I can see it's not tested wether the pool is returning new objects or is working at all. Inspecting the objects returned by getBean() in testFunctionality() with a debugger shows both calls return the same SideEffectBean instance. Is this feature broken or am I missing something? Cheers, Rainer ------------------------------------------------------- This SF.Net email is sponsored by: Sybase ASE Linux Express Edition - download now for FREE LinuxWorld Reader's Choice Award Winner for best database on Linux. http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer |
|
From: Rod J. <ro...@in...> - 2004-11-03 10:55:24
|
Rainer
Why do you say "without success"? Getting back the same object isn't necessarily an error.
This is actually hard to test. Returning the same instance in successive calls is perfectly legitimate as long as there
is no blocking. Perhaps I should strengthen the tests using two threads, but of course the behaviour will still depend
on the underlying pool instance.
If you look at the Commons PoolTargetSource implementation, getTarget() is as follows:
public Object getTarget() throws Exception {
return this.pool.borrowObject();
}
Thus it defers whether it's the same or another object to the pool implementation: Spring isn't caching the object.
Rgds
Rod
Rainer Schmitz wrote:
> Aloha!
>
> I tried to use CommonsPoolTargetSource without success - calling
> beanFactory.getBean() always returns the same instance.
>
> I looked into CommonsPoolTargetSourceTests and as far as I can see it's
> not tested wether the pool is returning new objects or is working at
> all. Inspecting the objects returned by getBean() in testFunctionality()
> with a debugger shows both calls return the same SideEffectBean instance.
>
> Is this feature broken or am I missing something?
>
> Cheers,
> Rainer
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by:
> Sybase ASE Linux Express Edition - download now for FREE
> LinuxWorld Reader's Choice Award Winner for best database on Linux.
> http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click
> _______________________________________________
> Springframework-developer mailing list
> Spr...@li...
> https://lists.sourceforge.net/lists/listinfo/springframework-developer
>
--
____________________________________________________
Rod Johnson
Interface21 - Spring Services from the Source
http://www.springframework.com
Founder, Spring Framework:
http://www.springframework.org
Author, "Expert One-on-One J2EE Development Without EJB"
(May 2004, with Juergen Hoeller).
http://www.amazon.com/exec/obidos/ASIN/0764558315/
Author, "Expert One-on-One J2EE Design and Development"
(October 2002).
http://www.amazon.com/exec/obidos/tg/detail/-/0764543857/
____________________________________________________
Interface21 Limited
Registered Office Summit House, 2-2a Highfield Road, Dartford, Kent DA1 2JY
Registered in England and Wales No. 5187766
____________________________________________________
|
|
From: Rainer S. <Rai...@ab...> - 2004-11-03 16:49:43
|
Rod Johnson wrote: > Rainer > > Why do you say "without success"? Getting back the same object isn't > necessarily an error. I misunderstood the intention of CommonsPoolTargetSource. I missed the line "acquiring and releasing a target object from the pool for each method invocation". So I expected to get an object from pool, do some work with it, and finally release it again. In this case of course I should get a new object when calling getTarget() before releasing the old one. My fault, sorry. Thanks for the clarification, Rainer |