You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hivemind.apache.org by John Coleman <jo...@ntlworld.com> on 2005/11/16 15:49:32 UTC

pooling data context and sharing with singletons

I am trying to create a nicely decoupled service layer for accessing cayenne. In the cayenne tapestry examples, the session class has DataContext declarations that pages use, which are unnaceptable dependancy for me. So I want to move all the cayenne out into hivemind.

What I would like is a public service (like an EJBs a home interface) that contains all operations for an entity, the CRUD and various queries for example.

This would break down into individual services that would implement sets of related methods, CRUD would be an example, which hivemind would inject. I would like these classes to be singletons (or pooled), but to be injected with a DataContext that is pooled but unique to each thread. I should not be instantiating a new DC for each service call, and nor should I share a DC over threads.

Is there a way of having one DC per http session without linking the classes? I was hoping the idea above would go some way towards achieving this?

You might have something like this:

public UserManagerService
 has CayenneUserQueriesService
 has CayenneUserCRUDService
 exposes methods of services

private CayenneUserQuerysService
 has DataContext (pooled, for a thread)
 impliments UserInterface
 implements cayenne access methods using DataContext

How would I wire that in HM? Each call to a UserInterface method would need to be using the respective DC for its thread, so injection during contruction would not work, right?

TIA
John