16

It's my understanding that in Spring, all objects are treated by default as singletons. If singleton is set to false, then a new object will be served at each request.

But what if I wanted to pool objects? Say set a range from a min of 1 to a max of 10 instances? Is this possible using Spring?

Cuga
  • 17,668
  • 31
  • 111
  • 166
  • 2
    I wouldn't see how it would be any different then using it in the Summer, Fall or Winter http://hiyoooo.com – RedWolves May 21 '09 at 13:56

1 Answers1

16

Pooling can be applied to any POJO with spring.

See here for more information.

toolkit
  • 49,809
  • 17
  • 109
  • 135
  • 2
    +1 I think the real work here is being done by commons-pool, but this sounds like a good way to enable it – matt b May 21 '09 at 14:39
  • 1
    This is the sort of thing that makes Spring cool - take an off-the-shelf, best-of-breed open source library, and wrap it so that you can use it the same IoC way as everything else. Sweet. – skaffman May 21 '09 at 14:59
  • 4
    FYI, [link for the current](https://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#aop-ts-pool). – Jin Kwon Mar 20 '18 at 09:16