Skip to content

Commit ef00a5e

Browse files
author
trisberg
committed
BATCH-63: renamed <task> and <chunk> to <simple-task> and <process-task>
1 parent 41dec7a commit ef00a5e

File tree

9 files changed

+94
-53
lines changed

9 files changed

+94
-53
lines changed

spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/StepParser.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,16 @@ public Collection<RuntimeBeanReference> parse(Element element, ParserContext par
7070
String stepRef = element.getAttribute("name");
7171

7272
@SuppressWarnings("unchecked")
73-
List<Element> taskElements = (List<Element>) DomUtils.getChildElementsByTagName(element, "task");
73+
List<Element> simpleTaskElements = (List<Element>) DomUtils.getChildElementsByTagName(element, "simple-task");
7474
@SuppressWarnings("unchecked")
75-
List<Element> chunkElements = (List<Element>) DomUtils.getChildElementsByTagName(element, "chunk");
76-
if (taskElements.size() > 0) {
77-
Object task = parseTask(taskElements.get(0), parserContext);
75+
List<Element> processTaskElements = (List<Element>) DomUtils.getChildElementsByTagName(element, "process-task");
76+
if (simpleTaskElements.size() > 0) {
77+
Object task = parseSimpleTask(simpleTaskElements.get(0), parserContext);
7878
stateBuilder.addConstructorArgValue(stepRef);
7979
stateBuilder.addConstructorArgValue(task);
8080
}
81-
else if (chunkElements.size() > 0) {
82-
Object task = parseChunk(chunkElements.get(0), parserContext);
81+
else if (processTaskElements.size() > 0) {
82+
Object task = parseProcessTask(processTaskElements.get(0), parserContext);
8383
stateBuilder.addConstructorArgValue(stepRef);
8484
stateBuilder.addConstructorArgValue(task);
8585
}
@@ -196,7 +196,7 @@ public static RuntimeBeanReference getStateTransitionReference(ParserContext par
196196
* @param parserContext
197197
* @return the TaskletStep bean
198198
*/
199-
protected RootBeanDefinition parseChunk(Element element, ParserContext parserContext) {
199+
protected RootBeanDefinition parseProcessTask(Element element, ParserContext parserContext) {
200200

201201
RootBeanDefinition bd;
202202

@@ -237,7 +237,7 @@ protected RootBeanDefinition parseChunk(Element element, ParserContext parserCon
237237
RuntimeBeanReference tx = new RuntimeBeanReference(transactionManager);
238238
bd.getPropertyValues().addPropertyValue("transactionManager", tx);
239239

240-
String commitInterval = element.getAttribute("chunk-size");
240+
String commitInterval = element.getAttribute("commit-interval");
241241
if (StringUtils.hasText(commitInterval)) {
242242
bd.getPropertyValues().addPropertyValue("commitInterval", commitInterval);
243243
}
@@ -374,7 +374,7 @@ private void handleStreamsElement(Element element, RootBeanDefinition bd, Parser
374374
* @param parserContext
375375
* @return the TaskletStep bean
376376
*/
377-
protected RootBeanDefinition parseTask(Element element, ParserContext parserContext) {
377+
protected RootBeanDefinition parseSimpleTask(Element element, ParserContext parserContext) {
378378

379379
RootBeanDefinition bd = new RootBeanDefinition("org.springframework.batch.core.step.tasklet.TaskletStep", null, null);
380380

spring-batch-core/src/main/resources/org/springframework/batch/core/configuration/xml/spring-batch-2.0.xsd

Lines changed: 73 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -202,20 +202,8 @@
202202
<xsd:extension base="nextType">
203203
<xsd:sequence>
204204
<xsd:choice>
205-
<xsd:element name="chunk" minOccurs="0" maxOccurs="1">
206-
<xsd:complexType>
207-
<xsd:complexContent>
208-
<xsd:extension base="chunkType"/>
209-
</xsd:complexContent>
210-
</xsd:complexType>
211-
</xsd:element>
212-
<xsd:element name="task" minOccurs="0" maxOccurs="1">
213-
<xsd:complexType>
214-
<xsd:complexContent>
215-
<xsd:extension base="taskType"/>
216-
</xsd:complexContent>
217-
</xsd:complexType>
218-
</xsd:element>
205+
<xsd:element name="process-task" type="processTaskType" minOccurs="0" maxOccurs="1"/>
206+
<xsd:element name="simple-task" type="simpleTaskType" minOccurs="0" maxOccurs="1"/>
219207
</xsd:choice>
220208
<xsd:group ref="transitions"/>
221209
</xsd:sequence>
@@ -232,7 +220,7 @@
232220
</xsd:complexContent>
233221
</xsd:complexType>
234222

235-
<xsd:complexType name="taskType">
223+
<xsd:complexType name="simpleTaskType">
236224
<xsd:complexContent>
237225
<xsd:extension base="stepDefType">
238226
<xsd:attribute name="tasklet" type="xsd:string" use="required">
@@ -246,7 +234,7 @@
246234
</xsd:complexContent>
247235
</xsd:complexType>
248236

249-
<xsd:complexType name="chunkType">
237+
<xsd:complexType name="processTaskType">
250238
<xsd:complexContent>
251239
<xsd:extension base="stepDefType">
252240
<xsd:sequence>
@@ -259,13 +247,20 @@
259247
</xsd:annotation>
260248
<xsd:complexType>
261249
<xsd:sequence>
262-
<xsd:element name="listener" minOccurs="1" maxOccurs="unbounded">
263-
<xsd:complexType>
264-
<xsd:attribute name="id" type="xsd:ID"/>
265-
<xsd:attribute name="ref" type="xsd:string"/>
266-
<xsd:attribute name="class" type="xsd:string"/>
267-
</xsd:complexType>
268-
</xsd:element>
250+
<xsd:element name="listener" type="listenerType" minOccurs="1" maxOccurs="unbounded"/>
251+
</xsd:sequence>
252+
</xsd:complexType>
253+
</xsd:element>
254+
<xsd:element name="retryListeners" minOccurs="0" maxOccurs="1">
255+
<xsd:annotation>
256+
<xsd:documentation><![CDATA[
257+
List of all listeners for the step definition
258+
]]>
259+
</xsd:documentation>
260+
</xsd:annotation>
261+
<xsd:complexType>
262+
<xsd:sequence>
263+
<xsd:element name="listener" type="listenerType" minOccurs="1" maxOccurs="unbounded"/>
269264
</xsd:sequence>
270265
</xsd:complexType>
271266
</xsd:element>
@@ -286,6 +281,18 @@
286281
</xsd:sequence>
287282
</xsd:complexType>
288283
</xsd:element>
284+
<xsd:element name="transaction-attributes" minOccurs="0" maxOccurs="1">
285+
<xsd:annotation>
286+
<xsd:documentation><![CDATA[
287+
The transaction attributes to be used for the transaction used during the execution
288+
of the task within the step.
289+
]]>
290+
</xsd:documentation>
291+
</xsd:annotation>
292+
<xsd:simpleType>
293+
<xsd:restriction base="xsd:string"/>
294+
</xsd:simpleType>
295+
</xsd:element>
289296
<xsd:element name="skippable-exception-classes" minOccurs="0" maxOccurs="1">
290297
<xsd:annotation>
291298
<xsd:documentation><![CDATA[
@@ -320,7 +327,7 @@
320327
</xsd:simpleType>
321328
</xsd:element>
322329
</xsd:sequence>
323-
<xsd:attribute name="chunk-size" type="xsd:integer" use="required">
330+
<xsd:attribute name="commit-interval" type="xsd:integer" use="required">
324331
<xsd:annotation>
325332
<xsd:documentation><![CDATA[
326333
The number of items that will be processed before commit is called for the transaction.
@@ -370,6 +377,35 @@
370377
]]></xsd:documentation>
371378
</xsd:annotation>
372379
</xsd:attribute>
380+
<xsd:attribute name="cache-capacity" type="xsd:integer" use="optional">
381+
<xsd:annotation>
382+
<xsd:documentation><![CDATA[
383+
The capacity of the cache in the retry policy.
384+
]]></xsd:documentation>
385+
</xsd:annotation>
386+
</xsd:attribute>
387+
<xsd:attribute name="is-reader-transactional-queue" type="xsd:boolean" default="false" use="optional">
388+
<xsd:annotation>
389+
<xsd:documentation><![CDATA[
390+
Whether the reader is a transactional queue. If it is then items read should not be cached
391+
in the event of a rollback since they will be returned to the queue.
392+
]]></xsd:documentation>
393+
</xsd:annotation>
394+
</xsd:attribute>
395+
<xsd:attribute name="task-executor" type="xsd:string" use="optional">
396+
<xsd:annotation>
397+
<xsd:documentation
398+
source="java:org.springframework.core.task.TaskExecutor"><![CDATA[
399+
The task executor responsible for executing the task..
400+
]]></xsd:documentation>
401+
<xsd:appinfo>
402+
<tool:annotation kind="ref">
403+
<tool:expected-type
404+
type="org.springframework.core.task.TaskExecutor" />
405+
</tool:annotation>
406+
</xsd:appinfo>
407+
</xsd:annotation>
408+
</xsd:attribute>
373409
</xsd:extension>
374410
</xsd:complexContent>
375411
</xsd:complexType>
@@ -397,6 +433,18 @@
397433
</xsd:complexContent>
398434
</xsd:complexType>
399435

436+
<xsd:complexType name="listenerType">
437+
<xsd:attribute name="id" type="xsd:ID"/>
438+
<xsd:attribute name="ref" type="xsd:string"/>
439+
<xsd:attribute name="class" type="xsd:string"/>
440+
</xsd:complexType>
441+
442+
<xsd:complexType name="jobExecutionListenerType">
443+
<xsd:attribute name="before-method" type="xsd:string"></xsd:attribute>
444+
<xsd:attribute name="after-method" type="xsd:string"></xsd:attribute>
445+
<xsd:attribute name="ref" type="xsd:string" use="required"></xsd:attribute>
446+
</xsd:complexType>
447+
400448
<xsd:group name="transitions">
401449
<xsd:sequence>
402450
<xsd:choice minOccurs="0" maxOccurs="unbounded" >
@@ -510,7 +558,7 @@
510558
if the bean name of the desired TransactionManager is not 'transactionManager'.
511559
]]></xsd:documentation>
512560
<xsd:appinfo>
513-
`<tool:annotation kind="ref">
561+
<tool:annotation kind="ref">
514562
<tool:expected-type
515563
type="org.springframework.transaction.PlatformTransactionManager" />
516564
</tool:annotation>
@@ -519,10 +567,4 @@
519567
</xsd:attribute>
520568
</xsd:attributeGroup>
521569

522-
523-
<xsd:complexType name="jobExecutionListenerType">
524-
<xsd:attribute name="before-method" type="xsd:string"></xsd:attribute>
525-
<xsd:attribute name="after-method" type="xsd:string"></xsd:attribute>
526-
<xsd:attribute name="ref" type="xsd:string" use="required"></xsd:attribute>
527-
</xsd:complexType>
528570
</xsd:schema>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
*/
4545
@ContextConfiguration
4646
@RunWith(SpringJUnit4ClassRunner.class)
47-
public class StepWithSimpleChunkJobParserTests {
47+
public class StepWithBasicProcessTaskJobParserTests {
4848

4949
@Autowired
5050
private Job job;
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import org.springframework.batch.core.Job;
2727
import org.springframework.batch.core.JobExecution;
2828
import org.springframework.batch.core.JobParameters;
29-
import org.springframework.batch.core.StepExecutionListener;
3029
import org.springframework.batch.core.StepListener;
3130
import org.springframework.batch.core.repository.JobRepository;
3231
import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean;
@@ -45,7 +44,7 @@
4544
*/
4645
@ContextConfiguration
4746
@RunWith(SpringJUnit4ClassRunner.class)
48-
public class StepWithFaultTolerantChunkJobParserTests {
47+
public class StepWithFaultTolerantProcessTaskJobParserTests {
4948

5049
@Autowired
5150
private Job job;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
*/
4040
@ContextConfiguration
4141
@RunWith(SpringJUnit4ClassRunner.class)
42-
public class StepWithTaskJobParserTests {
42+
public class StepWithSimpleTaskJobParserTests {
4343

4444
@Autowired
4545
private Job job;

spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/JobExecutionListenerParserTests-context.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<job id="job">
1010
<step name="step1">
11-
<task tasklet="tasklet"/>
11+
<simple-task tasklet="tasklet"/>
1212
</step>
1313
<listeners>
1414
<listener after-method="afterJob" ref="testListener"/>
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88

99
<job id="job">
1010
<step name="ft-step">
11-
<chunk reader="reader" processor="processor" writer="writer"
12-
fault-tolerant="false" chunk-size="10">
11+
<process-task reader="reader" processor="processor" writer="writer"
12+
fault-tolerant="false" commit-interval="10">
1313
<listeners>
1414
<listener class="org.springframework.batch.core.configuration.xml.TestListener"/>
1515
<listener ref="listener"/>
1616
</listeners>
1717
<streams>
1818
<stream ref="reader"/>
1919
</streams>
20-
</chunk>
20+
</process-task>
2121
</step>
2222
</job>
2323

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88

99
<job id="job">
1010
<step name="ft-step">
11-
<chunk reader="reader" processor="processor" writer="writer"
12-
fault-tolerant="true" chunk-size="10" skip-limit="20" retry-limit="3">
11+
<process-task reader="reader" processor="processor" writer="writer"
12+
fault-tolerant="true" commit-interval="10" skip-limit="20" retry-limit="3">
1313
<listeners>
1414
<listener class="org.springframework.batch.core.configuration.xml.TestListener"/>
1515
<listener ref="listener"/>
1616
</listeners>
1717
<streams>
1818
<stream ref="reader"/>
1919
</streams>
20-
</chunk>
20+
</process-task>
2121
</step>
2222
</job>
2323

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88

99
<job id="job">
1010
<step name="step1">
11-
<task tasklet="tasklet"/>
11+
<simple-task tasklet="tasklet"/>
1212
<next on="*" to="step2" />
1313
</step>
1414
<step name="step2">
15-
<task tasklet="tasklet"/>
15+
<simple-task tasklet="tasklet"/>
1616
</step>
1717
</job>
1818

0 commit comments

Comments
 (0)