[BATCH-503] Fix TX definition in samples. Also add multi-environment support in samples (mysql and derby as examples)

This commit is contained in:
dsyer
2008-03-25 06:57:55 +00:00
parent 5c840a6960
commit 3b72c04bef
20 changed files with 205 additions and 168 deletions

View File

@@ -1,23 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd">
<!-- Initialise the database before every test case: -->
<import resource="data-source-context-init.xml" />
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<import resource="data-source-context-init.xml" />
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${batch.jdbc.driver}" />
<property name="url" value="${batch.jdbc.url}" />
<property name="username" value="${batch.jdbc.user}" />
<property name="password" value="${batch.jdbc.password}" />
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="mappingLocations" value="classpath*:/*.hbm.xml" />
<property name="hibernateProperties">
@@ -29,44 +24,53 @@
</value>
</property>
</bean>
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager"
lazy-init="true">
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager" lazy-init="true">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<!-- Set up or detect a System property called "environment" used to construct a properties file on the classpath. The default is "hsql". -->
<bean id="environment" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetClass" value="java.lang.System" />
<property name="targetMethod" value="setProperty" />
<property name="arguments">
<list>
<value>environment</value>
<bean class="java.lang.System" factory-method="getProperty">
<constructor-arg>
<value>environment</value>
</constructor-arg>
<!-- The default value of the environment property -->
<constructor-arg>
<value>hsql</value>
</constructor-arg>
</bean>
</list>
</property>
</bean>
<!-- Use this to set additional properties on beans at run time -->
<bean id="batchProperties"
class="org.springframework.beans.factory.config.PropertyOverrideConfigurer">
<property name="location" value="classpath:batch.properties" />
<bean id="overrideProperties" class="org.springframework.beans.factory.config.PropertyOverrideConfigurer"
depends-on="environment">
<property name="location" value="classpath:batch-${environment}.properties" />
<!-- Allow system properties (-D) to override those from file -->
<property name="localOverride" value="true" />
<property name="properties">
<bean class="java.lang.System"
factory-method="getProperties" />
<bean class="java.lang.System" factory-method="getProperties" />
</property>
<property name="ignoreInvalidKeys" value="true" />
<property name="order" value="2" />
</bean>
<bean id="overrideProperties"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="classpath:batch.properties" />
<property name="systemPropertiesModeName"
value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
<bean id="placeholderProperties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
depends-on="environment">
<property name="location" value="classpath:batch-${environment}.properties" />
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
<property name="ignoreUnresolvablePlaceholders" value="true" />
<property name="order" value="1" />
</bean>
<bean id="lobHandler" class="${batch.lob.handler.class}"/>
<bean id="incrementerParent"
class="${batch.database.incrementer.class}">
<bean id="lobHandler" class="${batch.lob.handler.class}" />
<bean id="incrementerParent" class="${batch.database.incrementer.class}">
<property name="dataSource" ref="dataSource" />
<property name="incrementerName" value="ID" />
</bean>
<!--import resource="alt-data-source-context.xml" /-->
</beans>