Using the JCA local ECI resource adapter with COMMAREA

To use COMMAREA with the JCA local ECI resource adapter, the input and output records must be instances of classes that implement javax.resource.cci.Record and javax.resource.cci.Streamable.

This example shows how to build an input and output record for use by the local ECI resource adapter using the read() and write() methods on the Streamable interface:
RecordImpl in = new RecordImpl();
					byte[] commarea = "COMMAREA contents".getBytes();
					ByteArrayInputStream inStream = new ByteArrayInputStream(commarea);
					in.read(inStream);
					RecordImpl out = new RecordImpl();

					interaction.execute(is, in, out);

					ByteArrayOutputStream outStream = new ByteArrayOutputStream();
					out.write(outStream);
					commarea = outStream.toByteArray();

To retrieve a byte array from the output record, use the write method on the Streamable interface using a java.io.ByteArrayOutputStream object. The toByteArray() method on ByteArrayOutputStream provides the output data from the COMMAREA in the form of a byte array.

To provide more function for your specific JEE components, you can write implementations of the Record interface that allow you to set the contents of the record using the constructor. In this way you avoid use of the java.io.ByteArrayInputStream used in the example.

Rational Application Developer provides the J2C tooling that allows you to build implementations of the Record interface from specific native language structures such as COBOL copybooks, with in-built support for data marshalling between Java and non-Java data types.