5. Tools
• Spring Source Tools IDE /Eclipse
• Apache Maven
• Perl
• Bash Cygwin (Windows)
• Spring Batch legacy code that currently
supports 1.6 spec but needs to upgrade to 1.9
spec
6. Spring Batch Project
• Start with the simplest hello-world project
• Build more complexity on top
11. Tokenizer
• <!-- Tokenizer - Converts a delimited string
into a Set of Fields -->
• <bean name="defaultTokenizer"
class="org.springframework.batch.item.file.tr
ansform.DelimitedLineTokenizer"/>
12. Field Set Mapper
• <bean name="pbtItemFieldSetMapper"
class="aspire.mapper.PBTItemFieldSetMapper
" />
14. Flat File Item Reader
• <bean name="pbtItemReader"
class="org.springframework.batch.item.file.FlatFileIte
mReader">
• <property name="lineMapper"
ref="pbtItemLineMapper"/>
• <!-- use spring integrations for the following, but for
now filename is hard coded -->
• <property name="resource" value="classpath:pbt-
input-4.txt"/>
• </bean>
25. Sample output…
• Abbreviated Input
• 12:47:43,019 DEBUG main PBTItemFieldSetMapper:19 - [1, AGENCY1, ….., …….., 61, RA3, R, 45677,
7, 6, 5, 4, 3, 2, 1, 0, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1,…….., 7, SMITH, JOE, F, 123456, *, 742 ANY STREET,, *,
*, ANY CITY, OH, ……, US, *, A, ………….., *, *, *, *, *, *, *, *, *, N, *, 0]
• Abbreviated Output
• 12:47:43,019 DEBUG main PBTItemProcessor:21 - after processing [SystemID = 1 AccountID =
AGENCY1 PlanNumber ……… BenefitType = RA3 PayCode = R PaySource1 = 45677 PaySource2 = 7
PaySource3 = 6 PaySource4 = 5 PaySource5 = 4 PaySource6 = 3 PaySource7 = 2 PaySource8 = 1
PaySource9 = 0 Deduction1 = 10 Deduction2 = 9 Deduction3 = 8 Deduction4 = 7 Deduction5 = 6
Deduction6 = 5 Deduction7 = 4 Deduction8 = 3 Deduction9 = 2 Deduction10 = 1
……….Check2ndStreetAddress = * Check3rdStreetAddress = ……CheckIRSCountryCode = US
CheckProvince = * PaymentDestinationType = A ………… FinancialInstitutionPostalCode = *
FinancialInstitutionIRSCountryCode = * TaxWithholdingElection = N
TaxableMaritalStatusElectionCode = * TaxableAllowanceElection = 0]
• 12:47:43,019 DEBUG main PBTFooterCallback:44 - write...callback...
• 12:47:43,019 DEBUG main PBTFooterCallback:65 - 8
• ….
• 12:47:43,035 DEBUG main PBTFooterCallback:31 - FooterCallback....
• 12:47:43,035 INFO main SimpleJobLauncher:111 - Job: [FlowJob: [name=pbgcPBTIncomingJob]]
completed with the following parameters: [{}] and the following status: [COMPLETED]
26. Counting the bytes
• Fires up cygwin
• user@PC123456> /cygdrive/c/dev/spring-
batch/batch-dir/Spring-Batch-Hello-Wor
ld/target
– $ head -n1 output-pbt-4.det | wc -c
– 669
27. Be aware of newlines char
• Bash/gnu wc utility
• userID@PC123456 /cygdrive/c/dev/spring-
batch/batch-dir/Spring-Batch-Hello-World/target
– $ head -n1 output-pbt-4.det | perl -ne 'print
substr($_,667,2);' | od -c
– 0000000 r n
– 0000002
• So technically we only 667 bytes instead of 669
as reported by wc