eclipse RCP, spring+hibernate, hierarchical contexts, use different session factories
I need to create a session factory for user-specified (and non-spring managed) database connections. These connections are used to create unique session factories for hibernate. Associated with each session factory are layers of DAOs and services that depend on the session factory. The session factory is created from a user-specified connection parameters and uses a long-conversation hibernate session to manage performance. The DAOs and services have different context xml files defining them. There is a global application context defined as well for the entire application that defines some other app-specific singletons.
My application can connect to multiple "project" databases and users can add a new database connection on their own to interact with the project data in it. Each project should contain its own hibernate cache and use long conversations. I know how to do the hibernate part but all the examples I see around spring always define database connections in xml files or property files. For me, the connection information is non-spring managed and is dynamically defined by the user.
For the application I want to create a context for each "project." Each project will have its own session factory and supporting DAO and service objects.
[Global app context - same no matter which project I connect to]
===>[project #1 define my "hibernate session" in a context]
=======>[DAO and service context that references "hibernate session"]
===>[project #2 define another unique "hibernate session" in a context]
=======>[DAO and service context that references "hibernate session"]
Since my DAOs and service context need to use that "hibernate session" and that hibernate session is dependent on the connection info which is managed outside of spring, how do I define my contexts so I can programmatically create a context when a "project" is opened by the user but use non-spring POJOs to manage the connection info?
I have seen the documentation and posts on defining hierarchical contexts and the use of SingletonBeanFactoryLocator. This all seems doable. However, I need to programmatically define a context that sits between the shared global context and one specific that I want to instantiate and depends on my programmatically defined context holding the "hibernate session." The DAO and service context has a "hibernateSession" bean that I have defined and that is referenced by id for setter injection where needed on those DAOs and services.