Skip to main content

Is it possible to have a "dynamic" @PersistenceContext?

1 reply [Last post]
edilmar
Offline
Joined: 2003-11-13
Points: 0

Hi,

I have a webapp using GlassFish3.1.1 + JSF2.1 + RichFaces4.3.2 + CDI/Weld + CODI + JPA2 + Hibernate4.2.2 + Firebird.
I use also JTA (database connection injection from GlassFish).

I need to install many clients with separate databases in a cloud server. My actual solution is to deploy 1 webapp per client.
Each webapp consumes +/- 300 Mb of RAM. Then, if I have a cloud server with 2 Gb, I get to deploy 5 webapps.

I would like to deploy just one webapp, and, after "an analysis of the user to log on", to use the database of his enterprise.
Then, I would have much more clients than actual 5.

My solution can't use some kind of multitenancy, because each client must have a separate database, it's a major pre-requisite.

My big problem is @PersistenceContext(unitName="XXX"), because XXX is defined statically, I don't get to change XXX after "an analysis of the user to log on".

Is there some way to do this?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
edilmar
Offline
Joined: 2003-11-13
Points: 0