1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springframework.batch.sample.domain.person;
18
19 import java.util.ArrayList;
20 import java.util.List;
21
22 import org.springframework.batch.item.ItemReader;
23 import org.springframework.batch.item.ItemWriter;
24 import org.springframework.batch.sample.domain.order.Address;
25
26
27
28
29
30
31
32
33 public class PersonService {
34
35 private static final int GENERATION_LIMIT = 10;
36
37 private int generatedCounter = 0;
38
39 private int processedCounter = 0;
40
41 public Person getData() {
42 if (generatedCounter >= GENERATION_LIMIT)
43 return null;
44
45 Person person = new Person();
46 Address address = new Address();
47 Child child = new Child();
48 List<Child> children = new ArrayList<Child>(1);
49
50 children.add(child);
51
52 person.setFirstName("John" + generatedCounter);
53 person.setAge(20 + generatedCounter);
54 address.setCity("Johnsville" + generatedCounter);
55 child.setName("Little Johny" + generatedCounter);
56
57 person.setAddress(address);
58 person.setChildren(children);
59
60 generatedCounter++;
61
62 return person;
63 }
64
65
66
67
68
69 public void processPerson(String name, String city) {
70 processedCounter++;
71 }
72
73 public int getReturnedCount() {
74 return generatedCounter;
75 }
76
77 public int getReceivedCount() {
78 return processedCounter;
79 }
80 }