The basic idea behind AbstractRoutingDataSource is that a routing DataSource acts as an intermediary, while the 'real' DataSource can be determined dynamically at runtime based upon a lookup key.
If I need to implement a search functionality and I dont know which DataSource to use prior to compilation, how do I assign the look-up key for a particular schema at run-time?
I am running the example posted here.
http://blog.springsource.org/2007/01/23/dynamic-datasource-routing/
In this example, the "routing" DataSource is supplied to the Catalog so that it can dynamically get connections from the 3 different databases at runtime based on the current customer's type. The CustomerType is set manually and the list of Items in that Schema is extracted.
Suppose, I want to perform a search operation based on an item's price (and I have no idea about the schema of the Item), how do I implement that? how do I determine the schema in which the Item is present using AbstractRoutingDataSource?