Exposing InteractionSpec output properties as data

You can expose InteractionSpec properties for output. To expose properties of InteractionSpec for output, you must create a new output class and modify the interface and implementation files of your J2C Java™ bean before using it in an application.

Typically, you expose only the properties that your Java application needs as output.
To expose a property of InteractionSpec for output, complete the following steps:
  1. Create a wrapper class that contains the current return value for the method as a bean property.
  2. Add another bean property to the wrapper class to hold the InteractionSpec property you want to expose as output.
  3. Modify the J2C java bean's interface and implementation class to use this new wrapper class as a return type.
  4. Add the J2C doclet tag to associate the InteractionSpec property to expose with the wrapper bean's property.

Example

The below code fragments expose the functionName InteractionSpec property from the TADERC99 example. A detailed example using IMS™ is located here. Here's an example of the wrapper class:
package sample.cics.data;

public class WrapperBean {
	protected CustomerInfo customerInfo;
	protected String funcName;

	/**
	 * @return Returns the functionName.
	 */
	public String getFuncName() {
		return funcName;
	}
	/**
	 * @param functionName The functionName to set.
	 */
	public void setFuncName(String functionName) {
		this.funcName = functionName;
	}
	/**
	 * @return Returns the customerInfo.
	 */
	public CustomerInfo getCustomerInfo() {
		return customerInfo;
	}
	/**
	 * @param customerInfo The customerInfo to set.
	 */
	public void setCustomerInfo(CustomerInfo customerInfo) {
		this.customerInfo = customerInfo;
	}
}

Here's the updated method. The changes to be made are marked in bold. The changed generated code is in intalics.

/**
	 * @j2c.interactionSpec class="com.ibm.connector2.cics.ECIInteractionSpec"
	 * @j2c.interactionSpec-property name="functionName" value="TADERC99"
	 * @j2c.interactionSpec-returnProperty name="functionName" outputBinding="funcName"
	 * @generated
	 */
	public WrapperBean getCustomer(sample.cics.data.CustomerInfo arg) throws javax.resource.ResourceException {
		ConnectionSpec cs = getConnectionSpec();
		InteractionSpec is = interactionSpec;
		if (is == null) {
			is = new com.ibm.connector2.cics.ECIInteractionSpec();
			((com.ibm.connector2.cics.ECIInteractionSpec) is).setFunctionName("TADERC99");
		}
		sample.cics.data.CustomerInfo output = new sample.cics.data.CustomerInfo();
		invoke(cs, is, arg, output);
		WrapperBean bean = new WrapperBean();
		bean.setCustomerInfo(output);
		bean.setFuncName(((com.ibm.connector2.cics.ECIInteractionSpec) is).getFunctionName());
		return bean;	}
Feedback
(C) Copyright IBM Corporation 2000, 2005. All Rights Reserved.