On Mar 25, 2010, at 3:52 AM, Jean-Louis MONTEIRO wrote:


Hi,

Some month ago, i used a Spring feature called DynamicRoutingDatasource in
order to split data on database servers.

Here is a short description
http://blog.springsource.com/2007/01/23/dynamic-datasource-routing/
http://blog.springsource.com/2007/01/23/dynamic-datasource-routing/ .

I will need to implement such a feature in OpenEJB for my company.
So, i wonder if we could make that feature available in the Apache OpenEJB
distribution.

That all seems really trivial.  I don't see the harm in implementing it.

Seems like it would take all of one hour to create a DataSource wrapper that looked up "openejb:Resource/<ID>" and delegated to it where ID could be supplied via some class that the user supplied -- that way they take responsibility for the thread local and how/where it is set in their application code (a ThreadLocal<String> is all they'd need). Say some Router interface used by the RoutingDataSource implementation. RoutingDataSource can be defined in the service- jar.xml and have a "Router" property which can be set by the user to the class name of their impl. (doesn't have to be "Router" and "RoutingDataSource", could be any name. I kind of like just plain "DynamicDataSource").

I'd prefer to put off any creation of a larger application context kind of thing for the fact that "what datasource do you really want" can get really simple, so let's start there. Spring has a context concept, OSGi has one as well, and guess what JDCI has one too (a bunch actually). Anyway, I'd prefer not to create our own just yet as we have a lot of standards-based work to do real soon in this area. Seems like whatever we do would be obsoleted almost immediately.

The basic idea of DataSources being a tad more dynamic is good though. We can do simple now and potentially tie it into other context-providing APIs later -- could support them all eventually if we keep the DataSource simple enough.


-David

Reply via email to