RESOLVED - BATCH-863: introduce LineMapper interface to encapsulate string-to-item mapping

use DefaultLineMapper instead of PassThrough in customerFilterJob
This commit is contained in:
robokaso
2008-10-08 09:02:55 +00:00
parent aa87a9708d
commit 72623e1d05
3 changed files with 9 additions and 18 deletions

View File

@@ -47,10 +47,6 @@ public class CompositeCustomerUpdateLineTokenizer extends StepExecutionListenerS
//line starts with A,U, or D, so it must be a customer operation.
return customerTokenizer.process(line);
}
else if(line.charAt(0) == 'S'){
//header record, ignore
return null;
}
else{
//If the line doesn't start with any of the characters above, it must obviously be invalid.
throw new IllegalArgumentException("Invalid line encountered for tokenizing: " + line);

View File

@@ -13,8 +13,8 @@ import org.springframework.batch.item.ItemProcessor;
*/
public class CustomerUpdateProcessor implements ItemProcessor<CustomerUpdate, CustomerUpdate>{
CustomerDao customerDao;
InvalidCustomerLogger invalidCustomerLogger;
private CustomerDao customerDao;
private InvalidCustomerLogger invalidCustomerLogger;
public CustomerUpdate process(CustomerUpdate item) throws Exception {

View File

@@ -10,17 +10,7 @@
<list>
<bean name="uploadCustomer" parent="skipLimitStep">
<property name="itemReader" ref="customerFileUploadReader" />
<property name="itemProcessor">
<bean class="org.springframework.batch.item.support.CompositeItemProcessor" >
<property name="itemProcessors">
<list>
<ref bean="customerTokenizer"/>
<ref bean="customerMapper" />
<ref bean="customerUpdateProcessor" />
</list>
</property>
</bean>
</property>
<property name="itemProcessor" ref="customerUpdateProcessor" />
<property name="itemWriter" >
<bean class="org.springframework.batch.sample.domain.trade.CustomerUpdateWriter" >
<property name="customerDao" ref="customerDao" />
@@ -35,8 +25,13 @@
<bean name="customerFileUploadReader" class="org.springframework.batch.item.file.FlatFileItemReader" >
<property name="resource" ref="customerFileResource" />
<property name="lineMapper">
<bean class="org.springframework.batch.item.file.mapping.PassThroughLineMapper" />
<bean class="org.springframework.batch.item.file.mapping.DefaultLineMapper" >
<property name="lineTokenizer" ref="customerTokenizer" />
<property name="fieldSetMapper" ref="customerMapper" />
</bean>
</property>
<!-- skip the header -->
<property name="linesToSkip" value="1" />
</bean>
<bean name="customerMapper" class="org.springframework.batch.sample.domain.trade.CustomerUpdateFieldSetMapper" />