Pattern READ

  • 배치 작업 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>

    <!--
        * 배치작업 : 배치 Pattern read 샘플
        * 배치스텝
            - JSmpPatternRead100 : 배치 Pattern read 샘플
             - AAA로 시작하는 패턴 (매칭길이 4)
             - BBB로 시작하는 패턴 (매칭길이 4)
             - AAA, BBB가 아닌 다른 패턴 (매칭길이 5)
     -->
    <job id="sample-pattern" xmlns="http://www.springframework.org/schema/batch">
        <step id="sample-pattern-100" parent="parentStep" >
            <tasklet>
                <chunk reader="r-sample-pattern-100" processor="SmpPatternReadChunk" writer="SmpPatternReadChunk" />
            </tasklet>
        </step>
    </job>

    <!--
        * 샘플용직원정보를 Pattern Matching으로 read하기 위한 bean 설정
     -->
    <bean id="r-sample-pattern-100" parent="PatternMatching" scope="step">
        <property name="resource" value="file:///data1/prod/bxcm/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>
                <!--
                    마지막 패턴 처리 (필요할 경우 작성)
                    pattern을 *으로 설정하려면 matchLength를 설정한 길이보다 크게 정의하여야 한다.
                 -->
                <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>
  • 배치 소스코드 Sample

@Service("SmpPatternReadChunk")
@Scope("step")
@BxmCategory(logicalName = "PATTERN READ 샘플")
public class SmpPatternReadChunk implements ItemProcessor<IOmmObject, IOmmObject> {
    final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Override
    public IOmmObject process(IOmmObject in) throws Exception {
        if (in instanceof SmpPatternReadChunk01Dto) {
            logger.info("patternA : [{}]", in);
        } else if (in instanceof SmpPatternReadChunk02Dto) {
            logger.info("patternB : [{}]", in);
        } else {
            logger.error("Invalid pattern type... [{}]", in);
        }

        return in;
    }
}
SWLab Bankware Global
  • 전체
  • BXM
  • BXCM
  • BXCP
  • BXI
제품 선택 시 더 정확한 매뉴얼 가이드를 제공해드립니다.

Copyright© Bankwareglobal All Rights Reserved.