Actually my main requirement was a connection pool and you can use Commons DBCP easily for that. Lastly, I intend to partition my data so it can scale linearly to N rdbms instances, so I've setup 2 datasources to start off for my dao to use (there is of course no JTA-type cross-datasource transactions but I don't need that). Here's the config:
<bean id="dsSearchIndex1" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="com.google.appengine.api.rdbms.AppEngineDriver"/>
<property name="url" value="jdbc:google:rdbms://xxxx.com:web-prod:searchindex-1/ctssearchidx?allowMultiQueries=true"/>
<property name="username" value="xxxx"/>
<property name="password" value="xxxx"/>
</bean>
<bean id="tmSearchIndex1" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dsSearchIndex1"></property>
</bean>
<tx:annotation-driven mode="aspectj" transaction-manager="dsSearchIndex1" />
<bean id="dsSearchIndex2" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="com.google.appengine.api.rdbms.AppEngineDriver"/>
<property name="url" value="jdbc:google:rdbms://xxxx.com:web-prod:searchindex-2/ctssearchidx"/>
<property name="username" value="xxxx"/>
<property name="password" value="xxxx"/>
</bean>
<bean id="tmSearchIndex2" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dsSearchIndex2"></property>
</bean>
<tx:annotation-driven mode="aspectj" transaction-manager="dsSearchIndex2" />
<bean id="daoSearchIndex" class="com.xxxx.searchindex.SearchIndexDaoImpl">
<property name="dsSearchIndex1" ref="dsSearchIndex1"/>
<property name="dsSearchIndex2" ref="dsSearchIndex2"/>
</bean>
(However the SDK only supports 1 db locally, accessing any of these datasources in your dev environment will connect you to the one mysql db you've specified in your plugin config)
No comments:
Post a Comment