<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:p="http://www.springframework.org/schema/p"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="
		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
		http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
		http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">

	<bean id="parallelJob" parent="simpleJob">
		<property name="steps">
			<list>
				<bean id="staging" parent="simpleStep">
					<property name="commitInterval" value="2" />
					<property name="startLimit" value="100" />
					<property name="streams" ref="fileInputTemplate" />
					<property name="itemReader">
						<bean
							class="org.springframework.batch.item.validator.ValidatingItemReader">
							<property name="itemReader"
								ref="fileInputTemplate" />
							<property name="validator"
								ref="fixedValidator" />
						</bean>
					</property>
					<property name="itemWriter">
						<bean
							class="org.springframework.batch.sample.item.writer.StagingItemWriter">
							<property name="dataSource"
								ref="dataSource" />
							<property name="lobHandler"
								ref="lobHandler" />
							<property name="incrementer">
								<bean parent="incrementerParent">
									<property name="incrementerName"
										value="BATCH_STAGING_SEQ" />
								</bean>
							</property>
						</bean>
					</property>
				</bean>
				<bean id="loading" parent="simpleStep">
					<property name="taskExecutor">
						<bean
							class="org.springframework.core.task.SimpleAsyncTaskExecutor" />
					</property>
					<property name="itemReader">
						<bean
							class="org.springframework.batch.sample.item.reader.StagingItemReader">
							<property name="lobHandler"
								ref="lobHandler" />
							<property name="dataSource"
								ref="dataSource" />
						</bean>
					</property>
					<property name="itemWriter">
						<bean
							class="org.springframework.batch.sample.item.writer.TradeWriter">
							<property name="dao" ref="tradeDao" />
						</bean>
					</property>
				</bean>
			</list>
		</property>
	</bean>

	<!-- INFRASTRUCTURE SETUP -->

	<!-- This input source is injected into the test case to verify the output - not used by the job at all -->
	<bean id="testInputTemplate"
		class="org.springframework.batch.item.file.FlatFileItemReader">
		<property name="resource" ref="fileLocator" />
		<property name="lineTokenizer" ref="fixedFileDescriptor" />
		<property name="fieldSetMapper" ref="fieldSetMapper" />
	</bean>

	<bean id="fileInputTemplate" parent="testInputTemplate"
		autowire-candidate="false">
	</bean>

	<bean id="fixedFileDescriptor"
		class="org.springframework.batch.item.file.transform.FixedLengthTokenizer">
		<property name="names" value="ISIN, Quantity, Price, Customer" />
		<property name="columns" value="1-12, 13-15, 16-20, 21-29" />
	</bean>

	<bean id="fixedValidator"
		class="org.springframework.batch.item.validator.SpringValidator">
		<property name="validator">
			<bean id="tradeValidator"
				class="org.springmodules.validation.valang.ValangValidator">
				<property name="valang">
					<value>
						<![CDATA[
						{ isin : length(?) < 13 : 'ISIN too long' : 'isin_length' : 12}
					]]>
					</value>
				</property>
			</bean>
		</property>
	</bean>

	<bean id="tradeDao"
		class="org.springframework.batch.sample.dao.JdbcTradeDao">
		<property name="jdbcTemplate" ref="jdbcTemplate" />
		<property name="incrementer">
			<bean parent="incrementerParent">
				<property name="incrementerName" value="TRADE_SEQ" />
			</bean>

		</property>
	</bean>

	<bean id="fileLocator"
		class="org.springframework.core.io.ClassPathResource">
		<constructor-arg type="java.lang.String"
			value="data/fixedLengthImportJob/input/20070122.teststream.ImportTradeDataStep.txt" />
	</bean>

	<bean id="fieldSetMapper"
		class="org.springframework.batch.sample.mapping.TradeFieldSetMapper" />

	<aop:config>
		<aop:aspect id="moduleLogging" ref="logAdvice">
			<aop:after
				pointcut="execution( * org.springframework.batch.item.ItemWriter+.write(Object)) and args(item)"
				method="doStronglyTypedLogging" />
		</aop:aspect>
	</aop:config>

</beans>