VARIABLE TO VARIABLE
-
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="MSmpVariableToVariable*Btch"/>
</base-package>
</job-component>
<!--
* Batch job : VARIABLE TO VARIABLE sample
* Batch step
- JSmpVariableToVariable100 : VARIABLE TO VARIABLE sample initialization process
- JSmpVariableToVariable200 : Read strings from file and Write as strings
-->
<job id="JSmpVariableToVariable" xmlns="http://www.bankwareglobal.com/schema/batchex">
<step id="JSmpVariableToVariable100" next="JSmpVariableToVariable200" parent="parentStep">
<tasklet ref="MSmpVariableToVariableInitBtch"/>
</step>
<step id="JSmpVariableToVariable200" parent="parentStep">
<tasklet>
<chunk reader="RJSmpVariableToVariable200" processor="MSmpVariableToVariableBtch" writer="WJSmpVariableToVariable200"/>
</tasklet>
</step>
</job>
<!--
* Bean configuration to read sample employee information line by line as a string
-->
<bean id="RJSmpVariableToVariable200" parent="RVariable" scope="step">
<property name="name" value="RBSmpVariableToVariable200" />
<property name="resource" value="file:///data1/prod/bxm400/dat/rvariable_file_#{jobParameters['oDate']}.txt" />
<property name="encoding" value="UTF-8" />
</bean>
<!--
* Bean configuration to write sample employee information line by line as a string
-->
<bean id="WJSmpVariableToVariable200" parent="WVariable" scope="step">
<property name="name" value="WBSmpVariableToVariable200" />
<property name="resource" value="file:///data1/prod/bxm400/dat/wvariable_file_#{jobParameters['oDate']}.txt" />
<property name="encoding" value="UTF-8" />
</bean>
</beans>
-
Batch source code Sample
@BxmBean("MSmpVariableToVariableBtch")
@Scope("step")
@BxmCategory(logicalName = "VARIABLE TO VARIABLE sample")
public class MSmpVariableToVariableBtch implements ItemProcessor<String, String> {
final Logger logger = LoggerFactory.getLogger(this.getClass());
/**
* process
* - Processes each target record according to business requirements.
*/
@Override
@BxmCategory(logicalName = "process : processing sample employee information")
public String process(String in) throws Exception {
/********************************************************************
* The Variable type is used when directly reading or writing strings.
* - File read : Reads line by line and passes it to process
* - File write : Writes line by line the string returned from process
********************************************************************/
MSmpVariableToVariableBtch01Dto inDto = new MSmpVariableToVariableBtch01Dto();
MSmpVariableToVariableBtch01Dto outDto;
inDto.setFeduEmpNo(Integer.parseInt(in.substring(0, 4)));
inDto.setFeduEmpNm(in.substring(4));
/**
* Execute individual business logic
* ...
* ...
*/
outDto = inDto;
/**
* Convert OMM to a string
*/
String out = String.format("%4d%10s", outDto.getFeduEmpNo(), outDto.getFeduEmpNm());
return out;
}
}