Java Reference
In-Depth Information
job configuration to assemble these elements wraps up the configuration. Listing 11-23 shows the
configuration for this job.
Listing 11-23. Configuration for geocodingJob in geocodingJob.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns=" http://www.springframework.org/schema/batch"
xmlns:beans=" http://www.springframework.org/schema/beans"
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-3.0.xsd
http://www.springframework.org/schema/batch
http://www.springframework.org/schema/batch/spring-batch-2.1.xsd">
<beans:import resource="../launch-context.xml"/>
<beans:bean id="customerReader"
class="org.springframework.batch.item.database.JdbcCursorItemReader">
<beans:property name="dataSource" ref="dataSource"/>
<beans:property name="sql"
value="select * from customers where longitude is null or latitude is null"/>
<beans:property name="rowMapper" ref="customerRowMapper"/>
</beans:bean>
<beans:bean id="customerRowMapper"
class="com.apress.springbatch.chapter11.jdbc.CustomerRowMapper"/>
<beans:bean id="geocoder"
class="com.apress.springbatch.chapter11.processor.GeocodingItemProcessor">
<beans:property name="url" value="http://tinygeocoder.com/create-api.php"/>
</beans:bean>
<beans:bean id="customerImportWriter"
class="org.springframework.batch.item.database.JdbcBatchItemWriter">
<beans:property name="dataSource" ref="dataSource"/>
<beans:property name="sql" value="update customers set longitude = :longitude,
latitude = :latitude where id = :id"/>
<beans:property name="itemSqlParameterSourceProvider">
<beans:bean class="org.springframework.batch.item.database.
BeanPropertyItemSqlParameterSourceProvider"/>
</beans:property>
</beans:bean>
<job id="geocodingJob">
<step id="step1">
<tasklet>
<chunk reader="customerReader" processor="geocoder" writer="customerImportWriter"
commit-interval="1"/>
</tasklet>
</step>
</job>
</beans:beans>
Search WWH ::




Custom Search