You can use the J2C wizards to create an Ant configuration file by capturing your selections and entered values. Since an Ant configuration file is essentially 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. After 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/I), there is an additional step that involves generating the interface binding. The following example describes the data discovery section of the Ant script used to generate a J2C bean:
<j2c:generateService>
<j2c:buildService class="Customer" package="sample.cics">
<j2c:method>
<j2c:methodName value="getCustomer"/>
<j2c:methodInput value="/Test/src/sample/cics/data/CustomerInfo.java"/>
<j2c:methodOutput value="/Test/src/sample/cics/data/CustomerInfo.java"/>
<j2c:interactionSpec class="com.ibm.connector2.cics.ECIInteractionSpec">
<adapter:propertyGroup name="INTERACTION_SPEC_PROPERTY_PG">
<adapter:propertyElement name="functionName" value="taderc99"/>
<adapter:propertyElement name="commareaLength" value="-1"/>
<adapter:propertyElement name="replyLength" value="-1"/>
<adapter:propertyElement name="executeTimeout" value="0"/>
<adapter:propertyElement name="interactionVerb" value="1"/>
</adapter:propertyGroup>
</j2c:interactionSpec>
</j2c:method>
<j2c:managedConnectionFactory class="com.ibm.connector2.cics.ECIManagedConnectionFactory" target="MyDefaultJNDIName">
<adapter:propertyGroup name="MANAGED_CONNECTION_FACTORY_CLASS_PROPERTIES">
<adapter:propertyGroup name="Server">
<adapter:propertyElement name="ConnectionURL" value="j2c"/>
<adapter:propertyElement name="ServerName" value="cics"/>
</adapter:propertyGroup>
<adapter:propertyGroup name="UserVerification">
<adapter:propertyElement name="UserName" value="sysad"/>
<adapter:propertyElement name="Password" value="susad"/>
</adapter:propertyGroup>
<adapter:propertyGroup name="Security"/>
</adapter:propertyGroup>
</j2c:managedConnectionFactory>
<j2c:connectionSpec class="com.ibm.connector2.cics.ECIConnectionSpec"/>
<j2c:resourceAdapter project="${ra.project}"/>
</j2c:buildService>
<adapter:writeToWorkspace writer="{com/ibm/adapter/j2c/codegen/writer}J2CAnnotationWorkspaceResourceWriter">
<adapter:propertyGroup name="J2C Java Bean Writer Properties">
<adapter:propertyElement name="Project" value="Test"/>
<adapter:propertyElement name="PackageName" value="sample.cics"/>
<adapter:propertyElement name="InterfaceName" value="Customer"/>
</adapter:propertyGroup>
</adapter:writeToWorkspace>
</j2c:generateService>
Additional Tasks
Other utility tasks are useful but not required to generate the artifact.
<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 to by their unique names (QName). 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 that are 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 group and property names, is described in the discovery agent or resource writer documentation.
Properties are defined by a pair of name-value attributes. The name is 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 is not set.