While working with the caches and with our own internal content mapping project I have noticed a slight disconnect between how OCM handles sessions and how jackrabbit seems to want to handle them. With the OCM one tends to have a long lived object content manager that is potentially used by multiple threads. This would mean that the session would be re-used across multiple reader and writer threads. See http://markmail.org/message/f5lbenhnmdc2vxhx for details on threading and sessions.

I think this points to the need to have sessions opened and closed much like in the hibernate model. To accomplish this I think we should create a ObjectContentManagerFactory which can create the managers so that each thread can get its own copy. When creating a manager the factory could use a session factory much like the one that spring has for JCR (org.springmodules.jcr.JcrSessionFactory). This would allow sessions to be pooled or created as needed and then be passed to ObjectContentManagers. The factory could also preload the mapping classes and other configuration items (like say the cache implementation factory?). The threads could share a cache (if the implementation is EhCache or something intelligent) or the cache could just be a simple hashmap and the assumption would be that the managers are short lived and the cache is there to eliminate the infinite load issue.

WDYT?

-paddy

Reply via email to