<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:aop="http://www.springframework.org/schema/aop"
	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">

	<bean id="simpleSample" parent="simpleJob">
		<property name="steps">
			<list>
				<bean id="step1" parent="simpleStep">
					<property name="itemReader" ref="fileItemReader" />
					<property name="itemWriter">
						<bean
							class="org.springframework.batch.sample.tasklet.SimpleTradeWriter">
							<property name="tradeDao" ref="tradeDao" />
						</bean>
					</property>
					<property name="commitInterval" value="2" />
				</bean>
			</list>
		</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>

	<!-- 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="tradeTokenizer" />
		<property name="fieldSetMapper" ref="tradeMapper" />
	</bean>

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

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

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

	<bean id="tradeTokenizer"
		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="tradeLogAdvice"
		class="org.springframework.batch.sample.advice.TradeWriterLogAdvice" />

	<aop:config>
		<aop:aspect id="tradeWriterLogging" ref="tradeLogAdvice">

			<aop:after
				pointcut="execution( * org.springframework.batch.sample.dao.TradeDao+.writeTrade(org.springframework.batch.sample.domain.Trade)) and args(trade)"
				method="doBasicLogging" />

		</aop:aspect>
	</aop:config>

</beans>
