ByteWriterPattern

This pattern is used to write byte data to a file.

Supporting classes

  • FileByteWriter

Required properties

Table 1. Required properties
Property name Value
PATTERN_IMPL_CLASS Class implementing ByteWriterPattern interface
FILENAME Complete path to the input file

Optional properties

Table 2. Optional properties
Property name Value Description

debug

true or false (default is false)

Enables detailed tracing on this batch datastream.

EnablePerformanceMeasurement

true or false (default is false)

Calculates the total time spent in the batch data-streams and the processRecord method, if you are using the GenericXDBatchStep.

EnableDetailedPerformanceMeasurement

true or false (default is false)

Provides a more detailed breakdown of time spent in each method of the batch data-streams.

file.encoding

Encoding of the file

For example, 8859_1

AppendJobldToFileName

true or false (default is false)

Appends the JobID to the file name before loading the file.

Interface definition

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 example

<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>