0

Apache Commons seems to be the decent Object Pool implementation out there. Or any other framework that could support the cause

How Can I save its state of the pool during shutdown; may be serialize its objects to a external form json, xml ..? and reload during next startup ?

Njax3SmmM2x2a0Zf7Hpd
  • 1,354
  • 4
  • 22
  • 44
  • 2
    Saving is not part of a Pooling framework's job. The main job is reusing resource/time intensive objects without creating them. If you want this feature however you can write your own implementation. – shazin Jun 08 '14 at 09:31
  • 1
    I added a [test-case](https://code.google.com/p/yapool/source/browse/trunk/yapool/yapool-core/src/test/java/nl/fw/yapool/statefull/TestSaveRestore.java) to Yapool (also an Object Pool implementation) which shows resources can be saved/restored. But you are on your own when it comes to persisting and loading these resources (e.g. to XML/json file). – vanOekel Jun 13 '14 at 14:19
  • @vanOekel wow this is exactly what I was looking for. can you write this as an answer, so I can reward you. – Njax3SmmM2x2a0Zf7Hpd Jun 14 '14 at 04:27

1 Answers1

1

It is possible to capture objects in a pool when the pool is closed and put these objects back in the pool when a pool is opened with Yapool. I added a test-case to Yapool that shows how this could be done.

Persisting these objects "between pools" is not part of Yapool. But you can, for example, store them in a file and load them before a pool is opened.

Update: added another test-case which shows a more proper implementation and also shows a corner-case.

vanOekel
  • 6,358
  • 1
  • 21
  • 56