-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathspringjobs
83 lines (82 loc) · 3.8 KB
/
springjobs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?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"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util" xmlns:batch="http://www.springframework.org/schema/batch"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-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/util http://www.springframework.org/schema/util/spring-util-2.0.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-2.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<import resource="jdbcTemplate.xml" />
<!-- 1) USE ANNOTATIONS TO CONFIGURE SPRING BEANS -->
<context:component-scan base-package="com.bnp.ivision.common" />
<!-- 2) TRANSACTION MANAGER AND JOB EXECUTOR -->
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="jobExecutor" class="com.bnp.ivision.common.job.DomusExecutor" />
<!-- 3) JOB REPOSITORY - WE USE IN-MEMORY REPOSITORY FOR OUR EXAMPLE -->
<bean id="jobRepository"
class="org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean">
<property name="transactionManager" ref="transactionManager" />
</bean>
<!-- 4) LAUNCH JOBS FROM A REPOSITORY -->
<bean id="jobLauncher"
class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
<property name="jobRepository" ref="jobRepository" />
</bean>
<!--
5) Define the job and its steps. In our case used one step. Configure
its readers and writers
-->
<batch:job id="domus">
<batch:step id="step1">
<batch:tasklet>
<batch:chunk reader="DomusCursorItemReader" processor="DomusProcessor"
writer="DomusCursorItemWriter" commit-interval="1000">
</batch:chunk>
</batch:tasklet>
</batch:step>
<batch:listeners>
<batch:listener ref="appJobListener" />
</batch:listeners>
</batch:job>
<!-- 6) LISTENER -->
<bean id="appJobListener"
class="com.bnp.ivision.common.listeners.AppJobExecutionListener">
</bean>
<!-- 7) READER -->
<bean id="DomusCursorItemReader"
class="com.bnp.ivision.common.readers.domus.DomusCursorItemReader">
<property name="dataSource" ref="dataSource" />
<property name="procedureName" value="" />
<property name="rowMapper">
<bean class="org.springframework.jdbc.core.BeanPropertyRowMapper">
<property name="mappedClass"
value="com.bnp.ivision.common.dataobjects.domus.DomusBean"></property>
</bean>
</property>
</bean>
<!-- 8) PROCESSOR -->
<bean id="DomusProcessor" class="com.bnp.ivision.common.processors.domus.DomusProcessor" />
<!--9) WRITER-->
<bean id="domusWriter" class="org.springframework.batch.item.file.FlatFileItemWriter">
<property name="resource" value="file:${OUTPUT_FILE}" />
<property name="lineAggregator">
<bean
class="org.springframework.batch.item.file.transform.DelimitedLineAggregator">
<property name="delimiter" value="-" />
</bean>
</property>
<property name="footerCallback" ref="DomusCursorItemWriter" />
<property name="headerCallback" ref="DomusCursorItemWriter" />
</bean>
<bean id="DomusCursorItemWriter"
class="com.bnp.ivision.common.writers.domus.DomusCursorItemWriter">
<property name="delegate" ref="domusWriter" />
</bean>
</beans>