The J2C wizards allow you to quickly create an Ant configuration file by capturing your selections and entered values. Since an Ant configuration file is in essence an XML file, it can be modified or built entirely by hand.
An Ant configuration file consists of a target tree where various tasks are run. Tasks within a target are processed in a pipeline fashion. Each task is run by an object that implements a particular task interface. When the Ant configuration file is invoked, properties corresponding to each task are loaded into the implementing task objects. Once the information is loaded the task object is invoked.
Data Discovery Task
<adapter:discover>
<adapter:performImport agent="{com/ibm/adapter}CobolDiscoveryAgent">
<adapter:importResource>
<adapter:propertyGroup name="CobolFileGroup">
<adapter:propertyElement name="CobolFile" value="/${project}/taderc99.ccp"/>
</adapter:propertyGroup>
</adapter:importResource>
<adapter:queryProperties>
<adapter:propertyGroup name="ImportProperties">
<adapter:propertyElement name="Platform" value="Win32"/>
</adapter:propertyGroup>
</adapter:queryProperties>
<adapter:queryResult>
<adapter:selectElement name="DFHCOMMAREA"/>
</adapter:queryResult>
</adapter:performImport>
<adapter:writeToWorkspace writer="{com/ibm/adapter/cobol/writer}JAVA_WRITER">
<adapter:propertyGroup name="COBOLToJavaResourceWriter">
<adapter:propertyElement name="GenerationStyle" value="0"/>
<adapter:propertyGroup name="Java Type Name">
<adapter:propertyElement name="Overwrite existing class" value="true"/>
<adapter:propertyElement name="Project Name" value="${project}"/>
<adapter:propertyElement name="Package Name" value="com.ibm.test"/>
<adapter:propertyElement name="Class Name" value="Taderc99"/>
</adapter:propertyGroup>
</adapter:propertyGroup>
</adapter:writeToWorkspace>
</adapter:discover>
<?xml version="1.0" encoding="UTF-8" ?>
<project xmlns:adapter="http://com.ibm.adapter" default="DataBinding1" name="/Taderc99/CustomerInfo.xml">
<property name="debug" value="true" />
<property name="project1" value="Taderc99" />
<target name="DataBinding1">
<adapter:createProject projectName="${project1}" projectType="Java" />
<adapter:discover>
<adapter:performImport agent="{com/ibm/adapter}CobolDiscoveryAgent">
<adapter:importResource>
<adapter:propertyGroup name="CobolFileGroup">
<adapter:propertyElement name="CobolFile" value="C:\Samples\CICS\taderc99\taderc99.cbl" />
</adapter:propertyGroup>
</adapter:importResource>
<adapter:queryProperties>
<adapter:propertyGroup name="ImportProperties">
<adapter:propertyElement name="Platform" value="Win32" />
<adapter:propertyElement name="Codepage" value="ISO-8859-1" />
<adapter:propertyElement name="Numproc" value="PFD" />
<adapter:propertyElement name="FloatingPointFormat" value="IEEE 754" />
<adapter:propertyGroup name="ExternalDecimalSignGroup">
<adapter:propertyElement name="ExternalDecimalSign" value="ASCII" />
</adapter:propertyGroup>
<adapter:propertyGroup name="EndianGroup">
<adapter:propertyElement name="Endian" value="Little" />
<adapter:propertyElement name="RemoteEndian" value="Little" />
</adapter:propertyGroup>
<adapter:propertyGroup name="CompileOptions">
<adapter:propertyElement name="Quote" value="DOUBLE" />
<adapter:propertyElement name="Trunc" value="STD" />
<adapter:propertyElement name="Nsymbol" value="DBCS" />
</adapter:propertyGroup>
</adapter:propertyGroup>
</adapter:queryProperties>
<adapter:queryResult>
<adapter:selectElement name="DFHCOMMAREA" />
</adapter:queryResult>
</adapter:performImport>
<adapter:writeToWorkspace writer="{com/ibm/adapter/cobol/writer}JAVA_WRITER">
<adapter:propertyGroup name="COBOLToJavaResourceWriter">
<adapter:propertyElement name="GenerationStyle" value="Default" />
<adapter:propertyGroup name="Java Type Name">
<adapter:propertyElement name="Project Name" value="${project1}" />
<adapter:propertyElement name="Package Name" value="sample.cics" />
<adapter:propertyElement name="Class Name" value="CustomerInfo" />
<adapter:propertyElement name="Overwrite existing class" value="true" />
</adapter:propertyGroup>
</adapter:propertyGroup>
</adapter:writeToWorkspace>
</adapter:discover>
<eclipse.refreshLocal depth="infinite" resource="${project1}" />
<eclipse.incrementalBuild project="${project1}" />
</target>
</project>
Service Generation Task
In the special case of the language import (COBOL, C and PL/1), there is an additional step that involves the Interface Binding generation. The following example describes the data discovery section of the Ant script used for J2C Bean generation:
<j2c:generateService>
<j2c:buildService package="com.ibm.test" class="Taderc99Interface">
<j2c:method>
<j2c:methodName value="gettaderc99"/>
<j2c:methodInput value="${project}/com/ibm/test/Taderc99.java">
<j2c:argumentBinding property="commareaLength" propertyType="InteractionSpec" name="length" type="int"/>
</j2c:methodInput>
<j2c:methodOutput value="${project}/com/ibm/test/Taderc99.java"/>
<j2c:interactionSpec class="com.ibm.connector2.cics.ECIInteractionSpec">
<adapter:propertyGroup name="InteractionSpec property group">
<adapter:propertyElement name="functionName" value="TADERC99"/>
</adapter:propertyGroup>
</j2c:interactionSpec>
</j2c:method>
<j2c:managedConnectionFactory class="com.ibm.connector2.cics.ECIManagedConnectionFactory" target="myJNDIName">
<adapter:propertyGroup name="Managed connection property group">
<adapter:propertyGroup name="Server">
<adapter:propertyElement name="ConnectionURL" value="rubicon.torolab.ibm.com"/>
<adapter:propertyElement name="ServerName" value="rubicon"/>
</adapter:propertyGroup>
<adapter:propertyGroup name="UserVerification">
<adapter:propertyElement name="UserName" value="sysad"/>
<adapter:propertyElement name="Password" value="sysad"/>
</adapter:propertyGroup>
</adapter:propertyGroup>
</j2c:managedConnectionFactory>
<j2c:connectionSpec class="com.ibm.connector2.cics.ECIConnectionSpec"/>
<j2c:resourceAdapter project="CICS ECI"/>
</j2c:buildService>
<adapter:writeToWorkspace writer="com/ibm/adapter/j2c/codegen:J2CAnnotationWriter">
<adapter:propertyGroup name="J2C Writer Properties">
<adapter:propertyElement name="Project" value="${project}"/>
<adapter:propertyElement name="InterfaceName" value="Taderc99Interface"/>
<adapter:propertyElement name="BindingName" value="Taderc99Binding"/>
<adapter:propertyElement name="PackageName" value="com.ibm.test"/>
<adapter:propertyGroup name="CommandBean">
<adapter:propertyGroup name="gettaderc99">
<adapter:propertyElement name="EnableGenerate" value="true"/>
<adapter:propertyElement name="CommandBeanName" value="Taderc99CICSECIServiceProxy"/>
<adapter:propertyElement name="Input" value="Taderc99Part"/>
<adapter:propertyElement name="Output" value="Taderc99Part"/>
</adapter:propertyGroup>
</adapter:propertyGroup>
</adapter:propertyGroup>
</adapter:writeToWorkspace>
</j2c:generateService>
Additional Tasks
These are utility tasks, useful, but not required for artifact generation.
<adapter:createProject projectName="taderc99Project" projectType="Web" runtimeName="J2EE Runtime Library" addToEAR="yes" EARProjectName="TestEAR"/>Where:
<j2c:importResourceAdapter connectorModule="cicseci602" connectorFile="D:\IBM\SDP70\ResourceAdapters\cics15\cicseci602.rar" targetRuntime="J2EE Runtime Library" addToEAR="yes" EARProjectName="TestEAR"/>
Defining Properties
Discovery agents and workspace writer are referred by their name (QName), which is uniquely identified. To find all registered discovery agents, workspace resource Writers, and Import configurations, use the displayAll.xml script found in the sample directory.
As observed in the example scripts, the values passed to the discovery agents or resource writers are defined by propertyGroup and propertyElement tags. A property group defines a logical grouping of properties through a nested structure. The structure layout and the contained group and property names, should be described in the discovery agent or resource writer documentation.
Properties are defined by a pair of name, value attributes. The name is actually a property defined internally by the discovery agent or resource writer and it is used to pass the value along. It is important to get the name right. If the name is not recognized by the component the value will not be set.