> And the question is:
> How to build the context to move the existing Spring configuration to the
> Tomcat context to get all datasources with JNDI.
> The problem is, that it must be possible to set a variable amount of
> databases. I can't set the number of databases to a fixed amount.
>
Building the Resources for the beans named parentDataSource, firstDataSource
> and secondDataSource is like configuring a single database.
> But How can I create a JNDI lookable resource like the bean named
> dataSource containing a map of all available database resources?
>

>From your original post, in which you stated "This is my working Spring
datasource.xml:"

<bean id="dataSource" class="com.ax.dashboard.
datasource.AxRoutingDataSource">
<property name="targetDataSources">
<map key-type="java.lang.String">
<entry key="first" value-ref="firstDatasource" />
<entry key="second" value-ref="secondDataSource" />
</map>
</property>
<property name="defaultTargetDataSource" ref="firstDatasource" />
</bean>

In spring you are building a map of data sources that are also defined in
spring. Why not build a map of data sources that are defined in context.xml
and spring looks them up? You say that you need variable amounts of
databases, but the code you posted and said "this worked" doesn't support
this - to add a new datasource you would have to update spring config. If
you really need variable databases, then some custom code to load a custom
configuration of such data sources might be the way to go. Then just use a
resource element in context to get tomcat to load that for the instance.

Chris

Reply via email to