ByteWriterPattern
ByteWriterPattern 패턴은 파일에 바이트 데이터를 쓰는 데 사용됩니다.
클래스 지원
FileByteWriter 클래스는 지정된 파일을 열고 바이트를 쓰는 로직을 제공합니다. 지정된 특성에 따라, 기존 컨텐츠를 추가하거나 겹쳐쓸 수 있습니다. 다시 시작 중 파일은 항상 추가 모드로 열립니다.
필수 특성
패턴에 다음 특성이 필요합니다.
특성 이름 | 값 |
---|---|
PATTERN_IMPL_CLASS | ByteWriterPattern 인터페이스를 구현하는 클래스 |
FILENAME | 입력 파일에 대한 전체 경로 |
선택적 특성
다음 특성은 패턴에 대해 선택사항입니다.
특성 이름 | 값 | 설명 |
---|---|---|
디버그 | 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 ByteWriterPattern {
/**
* Invoked during the step setup phase
* @param props
*/
public void initialize(Properties props);
/**
* Writes the given object onto the given outputstream. Any processing
* that needs to be done before writing can be added here
* @param out
* @param record
* @throws IOException
*/
public void writeRecord(BufferedOutputStream out, Object record) throws IOException;
/**
* Write header information if any
* @param out
* @throws IOException
*/
public void writeHeader(BufferedOutputStream out) throws IOException;
/**
* This method can be optionally called during process step to explicity
* initialize and write the header.
* @param header
*/
public void writeHeader(BufferedOutputStream 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.FileByteWriter</impl-class>
</bds>
</batch-data-streams>