FileWriterPattern

FileWriterPattern 패턴은 파일에 텍스트 데이터를 쓰는 데 사용됩니다.

클래스 지원

TextFileWriter 클래스는 지정된 파일을 열고 문자열 데이터를 쓰는 로직을 제공합니다. 지정된 특성에 따라, 파일을 추가 또는 겹쳐쓰기 모드로 엽니다. 작업 다시 시작 중 파일은 항상 추가 모드에서 열립니다.

JobStepContext에서 TextFileWriter 파일 이름을 동적으로 설정하는 다음의 두 방법이 있습니다.
  • 눈금 계산으로 정의된 잘 알려진 단일 job-level 특성을 사용합니다. 다음 예에서:
       JobStepContext ctx = JobStepContextMgr.getContext();
       Properties jobProps = ctx.getJobLevelProperties();
       jobProps.set(TextFileWriter.
       FILENAME_JOBSTEPCONTEXT_DEFAULT_PROPERTY_NAME, "/my/fileName");
    TextFileWriter 초기화 전에 "/my/fileName" 값을 설정하면 이 값은 TextFileWriter 파일 이름으로 사용됩니다.
  • 자신의 사용자 정의 특성을 사용하며, BDS writer-level xJCL 특성으로 정의됩니다. 두 기록기가 있고 각각 다른 파일 이름이 필요한 경우 이 메소드를 사용합니다.
    이 메소드에서 com.ibm.websphere.batch.devframework.datastreams.patterns.TextFileWriter.FILENAME.xjcl.custom.property.name이라는 BDS-레벨 xJCL 특성을 사용하여 JobStepContext 특성 이름을 식별합니다. 예를 들어 다음과 같습니다.
    xJCL
          <bds>
            <logical-name>outputStream</logical-name>
    
    <impl-class>com.ibm.websphere.batch.devframework.datastreams.patterns.TextFileWriter</impl-class>
    
            <props>
              <prop name="PATTERN_IMPL_CLASS" value="mypkg.MyWriter"/>
              <prop name="FILENAME" value="/my/staticFileName.txt"/>    <!--
    This will take affect if the dynamic config isn't set. -->
              <prop name="AppendJobIdToFileName" value="true"/>           <!--
    Existing options are still usable with dynamically-determined filenames -->
              <prop name="debug" value="true"/>
              <prop
    name="com.ibm.websphere.batch.devframework.datastreams.patterns.TextFileWriter.FILENAME.xjcl.custom.property.name"
      value="my.bds.specific.property.name"/>
            </props>
          </bds>
        </batch-data-streams>
      </job-step>
    첫 번째 메소드에서 TextFileWriter 초기화 전에 job-level 특성을 설정합니다. 예를 들어 다음과 같습니다.
       JobStepContext ctx = JobStepContextMgr.getContext();
       Properties jobProps = ctx.getJobLevelProperties();
       jobProps.set("my.bds.specific.property.name", "/my/fileName");

필수 특성

다음 특성은 패턴에 필요합니다.

표 1. 필수 특성. 테이블은 패턴에 필요한 각 특성의 이름과 값을 포함합니다.
특성 이름
PATTERN_IMPL_CLASS FileWriterPattern 인터페이스를 구현하는 클래스
FILENAME 입력 파일에 대한 전체 경로

선택적 특성

다음 특성은 패턴에 대해 선택사항입니다.

표 2. 선택적 특성. 테이블은 패턴에 대한 선택적 각 특성의 이름, 값 및 설명을 포함합니다.
특성 이름 설명
디버그 true 또는 false(기본값은 false) 이 일괄처리 데이터 스트림에 대한 자세한 추적을 사용으로 설정합니다.
EnablePerformanceMeasurement true 또는 false(기본값은 false) GenericXDBatchStep을 사용 중인 경우, 일괄처리 데이터 스트림과 processRecord 메소드에서 소요된 전체 시간을 계산합니다.
EnableDetailedPerformanceMeasurement true 또는 false(기본값은 false) 일괄처리 데이터 스트림의 각 메소드에서 소요된 시간의 자세한 추가 분석을 제공합니다.
file.encoding 파일의 인코딩 예를 들어, 8859_1
AppendJobldToFileName true 또는 false(기본값은 false) 파일을 로드하기 전에 JobID를 파일 이름에 추가합니다.
append true 또는 false(기본값은 true) 파일을 추가 모드로 열 것인지 여부를 판별합니다.
중요사항: 다시 시작 중 파일은 항상 추가 모드로 열립니다.

인터페이스 정의

public interface FileWriterPattern { 
  
	/**  
	 * Invoked during step setup phase  
	 * @param props  
	 */  
	public void initialize(Properties props);  
	  
	/**  
	 * This method should write the given record  
	 * object to the bufferedwriter.  
	 * @param out  
	 * @param record  
	 * @throws IOException  
	 */  
	public void writeRecord(BufferedWriter out, Object record) throws IOException;  
	  
	/**  
	 * This method is invoked only once just after the bufferedwriter  
	 * is opened. It should be used to write any header information  
	 * @param out  
	 * @throws IOException  
	 */  
	public void writeHeader(BufferedWriter out) throws IOException;  

        /**
	 * This method can be optionally called during process step to explicity 
	 * initialize and write the header. 
	 * @param header
	 * @throws IOException 
	 */
	public void writeHeader(BufferedWriter out, Object header) throws IOException;

}  

xJCL 샘플

<batch-data-streams>
<bds>
<logical-name>outputStream</logical-name>
<props>
     <prop name="PATTERN_IMPL_CLASS" value="com.ibm.websphere.batch.samples.tests.bds.EchoWriter"/>
     <prop name="file.encoding" value="8859_1"/>
     <prop name="FILENAME" value="/opt/txlist.txt" />
     <prop name="debug" value="true"/>
</props>
<impl-class>com.ibm.websphere.batch.devframework.datastreams.patterns.TextFileWriter</impl-class>
</bds>
</batch-data-streams>

주제 유형을 표시하는 아이콘 참조 주제



시간소인 아이콘 마지막 업데이트 날짜: last_date
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=rgrid_btchpttrn6
파일 이름:rgrid_btchpttrn6.html