Results 1 to 3 of 3

Thread: Object Pooling/Caching for IoC?

  1. #1
    Join Date
    May 2006
    Posts
    15

    Default Object Pooling/Caching for IoC?

    Hi

    One of the objects that will be wired together for our application will be caching some non-volatile database data. Since this rarely changes instead of having Spring create new objects and do the database reads over and over for every request, it would be great if it would cache the objects and preferrably manage a pool of these objects. Then when a request comes in, an existing object could be reused during the wiring process and returned instead of instantiating a new object.

    Does Spring have this capability as part of the IoC functionality? If yes, how is this configured? It would be great if there could be a minimum number of objects in the pool as well as a maximum number.

    Thank you for your help.

    Thanks.

    David

  2. #2
    Join Date
    May 2006
    Posts
    15

    Default Additional Info

    The objects to be managed are not connected to a database. These objects use java wrappers which have JNI calls to external functionality. The instantiation of the external functionality is quite expensive. I am hoping that a cache of these objects with the JNI reference up and running can be kept around so that when a request comes in the existing objects can be used. This will save substantial time. The external resource can process multiple independent calls without a problem. It really seems to be an issue of how to get both IoC with Spring and the object pooling during the wiring process.

    I hope this additional info helps.

    David

  3. #3
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    Spring creates by default singleton object - that is they are created only once and the same instance reused. It also supports prototype beans - that is beans which are created each time they are retrieved.
    Spring 2.0 adds scoping which allows the user to plug in custom lifespan of the beans - for example out of the box http session is supported which means that a bean is a singleton inside the same http session but a new instance will be created in a different http session.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •