Re: Cayenne + Spring?

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Sat Dec 18 2004 - 13:16:31 EST

  • Next message: Sax: "Re: Cayenne for SIM-like game"

    Hi James,

    > Are many people using Cayenne and Spring together?

    I know that many are waiting till the "official" integration, but if
    someone implemented their own Spring factories for Cayenne stack,
    please send us a note with your examples. Just yesterday I started
    doing the research of the steps needed for such integration, so I have
    the same question as James.

    > Each Service can reference multiple DAOs, and each Web Controller can
    > reference many Services.
    >
    > The DAOs, Services and Controllers will by default be singletons in
    > Spring, and I'd rather keep them that way. Therefore I can't
    > explicitly set a DataContext on them within Spring's application
    > context - they would be shared by all threads.
    >
    > Is there a good Spring-friendly way to bind a DataContext to each
    > thread as it enters my DAOs code? Or perhaps maintain a pool of
    > DataContext objects to be used by the DAOs?

    Pool is not a good idea! DataContext itself is lightweight, so creating
    one on the fly is not a problem. Its value (in addition to storing
    uncommitted state between requests) is that it caches only objects
    relevant to a given user session, so there is a high probability of
    cache reuse. A cached DataContext will simply hog extra memory and
    won't add much value over the shared cache provided by DataDomain.

    Now how you do it in Spring, I have no idea... There gotta be an easy
    way to access user session before you pass control to DAO. Spring
    couldn't possibly be that popular if all it does is serving stateless
    applications.. I just don't know what it is. Do you store any other
    state in the session? How do you access it from controller?

    Andrus



    This archive was generated by hypermail 2.0.0 : Sat Dec 18 2004 - 13:16:37 EST