开发者

Any way to inject/choose datasource at runtime?

I have a MySQL database with many databases, each named for a specific customer.

A webapp is deployed per customer. The name of the webapp determines the underlying database name. When the webapp starts up, I have a modified Spring PropertyPlaceholderConfigurer to grab the ServletContext if it can and determine the name. I then dereference this in my datasource setup. Works beautifully. The exact same code can be deployed to all customers and they find their database without issue (also a DNS name to locate the MySQL host).

I'd like to switch to GlassFish or JBoss AS 6 and still do the same thing with straight JEE6 API/annotations.

Is there a way to do this? I'm not worried about security -- the datasets are large enough to justify their own machines and webapps and since the database model is tied to the code, they need to be kept in sync. Since not every customer ne开发者_如何学Pythoneds to have the latest code for the task at hand, they revision at different rates.

I like the convenience of JEE6 consolidating a lot what Spring used to have and then some but I hate having to deal with application servers and their idiocy but cobbling together Spring isn't fun either.


I'd like to switch to GlassFish or JBoss AS 6 and still do the same thing with straight JEE6 API/annotations.

I'm afraid this won't be possible. To my knowledge, with a container-managed entity manager, you won't be able to configure its underlying datasource at runtime.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜