Pattern READ
-
Batch Job Xml Sample
<?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:batch-int="http://www.springframework.org/schema/batch-integration"
xsi:schemaLocation="http://www.bankwareglobal.com/schema/batchex http://www.bankwareglobal.com/schema/batchex/spring-
batch-ex.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/batch-integration http://www.springframework.org/schema/batch-integration/
spring-batch-integration.xsd">
<import resource="classpath:JobConfig.xml"/>
<job-component xmlns="http://www.bankwareglobal.com/schema/batchex" id="jobcomp" with-dependon="true">
<base-package name="bxm.dft.smp.batch.bean">
<include name="MSmpPatternReadBtch*"/>
</base-package>
</job-component>
<!--
* Batch job: Batch Pattern read sample
* Batch step
- JSmpPatternRead100: Batch Pattern read sample
- Pattern starting with AAA (matching length 4)
- Pattern starting with BBB (matching length 4)
- Pattern other than AAA and BBB (matching length 5)
-->
<job id="JSmpPatternRead" xmlns="http://www.bankwareglobal.com/schema/batchex">
<step id="JSmpPatternRead100" parent="parentStep" >
<tasklet>
<chunk reader="RJSmpPatternRead100" processor="MSmpPatternReadBtch" writer="MSmpPatternReadBtch" />
</tasklet>
</step>
</job>
<!--
* Bean configuration for reading sample employee information by Pattern Matching
-->
<bean id="RJSmpPatternRead100" parent="PatternMatching" scope="step">
<property name="resource" value="file:///data1/prod/bxm400/dat/pattern_input.txt"/>
<property name="encoding" value="UTF-8" />
<property name="patternItemMapper">
<list>
<bean parent="patternType">
<property name="targetType" value="bxm.dft.smp.batch.bean.dto.MSmpPatternReadBtch01Dto" />
<property name="pattern" value="AAA*" />
<property name="matchLength" value="4" />
</bean>
<bean parent="patternType">
<property name="targetType" value="bxm.dft.smp.batch.bean.dto.MSmpPatternReadBtch02Dto" />
<property name="pattern" value="BBB*" />
<property name="matchLength" value="4" />
</bean>
<!--
Last pattern processing (write if necessary)
To set the pattern as *, matchLength must be defined larger than the set length.
-->
<bean parent="patternType">
<property name="targetType" value="bxm.dft.smp.batch.bean.dto.MSmpPatternReadBtch03Dto" />
<property name="pattern" value="*" />
<property name="matchLength" value="5" />
</bean>
</list>
</property>
</bean>
</beans>
-
Batch Source Code Sample
@BxmBean("MSmpPatternReadBtch")
@Scope("step")
@BxmCategory(logicalName = "PATTERN READ sample")
public class MSmpPatternReadBtch implements ItemProcessor<IOmmObject, IOmmObject> {
final Logger logger = LoggerFactory.getLogger(this.getClass());
@Override
public IOmmObject process(IOmmObject in) throws Exception {
if (in instanceof MSmpPatternReadBtch01Dto) {
logger.info("patternA : [{}]", in);
} else if (in instanceof MSmpPatternReadBtch02Dto) {
logger.info("patternB : [{}]", in);
} else {
logger.error("Invalid pattern type... [{}]", in);
}
return in;
}
}