A.9 CCI Interface Classes

Following is a brief description of the classes that implement the CCI interface. Tools normally generate these classes from the definition of the mainframe program external interface, such as, for example, from the COBOL Common Area format of a TP program.

The InteractionSpecImpl class implements the InteractionSpec CCI interface. The InteractionSpecImpl class is used for specifying the name of the target TP program and the direction of argument passing (Code Example A.9).

Code Example A.9 InteractionSpecImpl Class
 package com.aardvark.payroll.impl; import javax.resource.cci.InteractionSpec; public class InteractionSpecImpl implements InteractionSpec {    private String functionName;    private int interactionVerb;    // String with the name of TP program    public void setFunctionName(String functionName) {       this.functionName = functionName;    }    public String getFunctionName() {       return this.functionName;    }    // Interaction verb indicates the direction    // of parameter passing. It is one of    // SYNC_SEND, SYNC_SEND_RECEIVE, and SYNC_RECEIVE.    public void setInteractionVerb(int verb) {       this.interactionVerb = verb;    }    public int getInteractionVerb() {       return this.interactionVerb;    } } 

The RecordImpl class implements the CCI Record interface. Its implementation, shown in Code Example A.10, is used as the superclass for application-specific record classes.

Code Example A.10 RecordImpl Class
 package com.aardvark.payroll.impl; import javax.resource.cci.Streamable; import javax.resource.cci.Record; import java.io.Serializable; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; public class RecordImpl implements Record, Serializable, Streamable {    String  name;    String  desc;    public RecordImpl() {}    // Name of the record    public void setRecordName(String name) {       this.name = name;    }    public String getRecordName() {       return name;    }    // Short description string for this record    public void setRecordShortDescription(String description) {       this.desc = description;    }    public String getRecordShortDescription() {       return desc;    }    // Check if this instance is equal to another record.    public boolean equals(Object other) {       // ...    }    // Read data from InputStream, and initialize fields.    public void read(InputStream istream) throws IOException {       //....    }    // Write fields of a streamable object to OutputStream.    public void write(OutputStream ostream) throws IOException {       //...    }    public Object clone() throws CloneNotSupportedException {       return this;    } } 

The EmployeeRecord class defines the interface that a Java application uses to get and set the values of input arguments for communication with the TP programs (Code Example A.11).

Code Example A.11 EmployeeRecord Class
 package com.aardvark.payroll.impl; import javax.resource.cci.Record; public interface EmployeeRecord extends Record  {    void setName(String name);    void setId(int id);    void setSalary(double salary);    void setBenefitsDeduction(double deduction);    String getName();    int getId();    double getSalary();    double getBenefitsDeduction(); } 

The EmployeeRecordImpl class implements the EmployeeRecord interface and is responsible for the conversion between the Java representation of the values of arguments and the representation understood by the mainframe program. The data in the mainframe representation is passed to a mainframe resource adaptor through the InputStream and OutputStream interfaces (Code Example A.12).

Code Example A.12 EmployeeRecordImpl Class
 package com.aardvark.payroll.impl; import javax.resource.cci.Streamable; import java.io.Serializable; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; public class EmployeeRecordImpl extends RecordImpl         implements EmployeeRecord, Serializable, Streamable {    private String name;    private int id;    private double deduction;    private double salary;    public EmployeeRecordImpl() {}    public void setName(String name) {       this.name = name;    }    public void setId(int id) {       this.id = id;    }    public void setSalary(double salary) {       this.salary = salary;    }    public void setBenefitsDeduction(double deduction) {       this.deduction = deduction;    }    public String getName() {       return name;    }    public int getId() {       return id;    }    public double getSalary() {       return this.salary;    }    public double getBenefitsDeduction() {       return this.deduction;    }    // Read data from a stream, and set the values of fields.    public void read(InputStream istream) throws IOException {       super.read(istream);       //....    }    // Write the values of fields to a stream.    public void write(OutputStream ostream) throws IOException {       super.write(ostream);       //...    } } 


Applying Enterprise Javabeans
Applying Enterprise JavaBeans(TM): Component-Based Development for the J2EE(TM) Platform
ISBN: 0201702673
EAN: 2147483647
Year: 2003
Pages: 110

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net