VARIABLE TO VARIABLE
-
배치 작업 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>
<!--
* 배치작업 : VARIABLE TO VARIABLE 샘플
* 배치스텝
- JSmpVariableToVariable100 : VARIABLE TO VARIABLE 샘플 샘플 초기화 처리
- JSmpVariableToVariable200 : 파일에서 문자열을 Read하여 문자열로 Write 처리
-->
<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>
<!--
* 샘플용직원정보 문자열로 1라인씩 Read 하기위한 bean 설정
-->
<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>
<!--
* 샘플용직원정보를 문자열로 1라인씩 Write 하기위한 bean 설정
-->
<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>
-
배치 소스코드 Sample
@BxmBean("MSmpVariableToVariableBtch")
@Scope("step")
@BxmCategory(logicalName = "VARIABLE TO VARIABLE 샘플")
public class MSmpVariableToVariableBtch implements ItemProcessor<String, String> {
final Logger logger = LoggerFactory.getLogger(this.getClass());
/**
* process
* - 처리 대상 데이터를 건 별로 업무요건에 따라 처리하는 역할을 수행한다.
*/
@Override
@BxmCategory(logicalName = "process : 샘플용 직원정보 처리")
public String process(String in) throws Exception {
/********************************************************************
* Variable 유형은 직접 문자열을 읽거나 혹은 문자열을 쓸때 사용하는 유형이다.
* - 파일 read : 1라인씩 read하여 process로 전달
* - 파일 write : process에서 return한 문자열을 1라인씩 write
********************************************************************/
MSmpVariableToVariableBtch01Dto inDto = new MSmpVariableToVariableBtch01Dto();
MSmpVariableToVariableBtch01Dto outDto;
inDto.setFeduEmpNo(Integer.parseInt(in.substring(0, 4)));
inDto.setFeduEmpNm(in.substring(4));
/**
* 개별 업무로직 수행
* ...
* ...
*/
outDto = inDto;
/**
* OMM을 문자열로 변환
*/
String out = String.format("%4d%10s", outDto.getFeduEmpNo(), outDto.getFeduEmpNm());
return out;
}
}