Fichier CSG.xml de générateur de module de remplacement d'appel
Le fichier CSG.xml fournit un exemple expliquant de manière approfondie comment démarrer le générateur de module de remplacement d'appel COBOL à partir d'un environnement Ant à l'aide de la tâche personnalisée <csg> ou dans Rational Application Developer sous la forme d'une génération Ant.
Propriétés d'entrée du fichier CSG.xml
Le tableau suivant décrit les propriétés d'entrée du fichier CSG.xml. Si vous exécutez la tâche <csg> dans l'interface graphique de Rational Application Developer, vous pouvez définir les propriétés à l'aide du format -Dnom_propriété=valeur_propriété.
Name | Requis ou facultatif | Description |
---|---|---|
cobolSource | Obligatoire | Indique le chemin complet vers le fichier source COBOL.![]() Dans l'interface graphique de Rational Application Developer, vous pouvez utiliser la variable intégrée ${resource_loc}, dont la valeur est remplacée par le chemin complet de la ressource actuellement sélectionnée dans l'Explorateur de package. |
workSpace | Obligatoire | Indique le chemin complet vers le répertoire racine de l'espace de travail Rational Application Developer ou Eclipse à utiliser pour créer la classe de liaison de données Java™. Dans l'interface graphique de Rational Application Developer, vous pouvez utiliser la variable intégrée ${workspace_loc}, dont la valeur est remplacée par le chemin complet de l'espace de travail actif. |
eclipseProjectName | Obligatoire | Indique le nom du projet dans l'espace de travail Rational Application Developer ou Eclipse qui fournit la base pour la classe Java générée. Dans l'interface graphique de Rational Application Developer, vous pouvez utiliser la variable intégrée ${project_name}, dont la valeur est remplacée par le nom de projet de la ressource actuellement sélectionnée dans l'Explorateur de package. Le projet doit exister avant l'exécution du générateur de module de remplacement d'appel. |
callStubPackage | Obligatoire | Indique le nom de package à utiliser pour le module de remplacement d'appel généré. Dans l'interface graphique de Rational Application Developer, vous pouvez utiliser la variable intégrée ${string_prompt:callStubPackage}. Lors de l'exécution, Rational Application Developer vous invite à entrer une valeur de chaîne. Le titre de la boîte de dialogue d'invite est callStubPackage. |
Emplacement de fichier
Exemple d'emplacement du fichier de génération Ant CSG.xml :
product_installation_root/CobolCallStubGenerator.V1.2/CSG.xml
Contenu de CSG.xml
Le fichier CSG.xml qui est fourni avec le produit se présente comme suit :
<?xml version="1.0" encoding="UTF-8"?>
<!-- ........................................................................... -->
<!-- This Ant build file is used for invoking the COBOLCallStubGenerator (CSG)
within Rational Application Developer. It has two steps:
1. Calls CSG for the given cobolSource file.
CSG is invoked using the custom <csg> task.
<csg> generates the Java call stub and the data binder Ant file.
2. Invokes the data binder Ant file that is generated by <csg>.
The data binder Ant file invokes the data binder and generates
the data binding Java classes for the COBOL parameters.
To configure this file for use within Rational Application Developer:
1. Run -> External Tools -> External Tools Configuration.
2. New Ant Build
Buildfile: full_path_to_this_file.xml
Arguments: -DcobolSource=${resource_loc}
-DworkSpace=${workspace_loc}
-DeclipseProjectName=${project_name}
-DcallStubPackage=${string_prompt:callStubPackage}
Refresh: project
Build: project
JRE: same as workspace (needs J2C tools installed)
Usage instructions:
1. Load the COBOL source into the project.
2. Select the COBOL source file or source directory in Project Explorer.
3. Click Run -> External Tools -> CSG Ant build. -->
<!-- ........................................................................... -->
<project default="CSG">
<property name="csgDir" value="${basedir}" />
<property name="debug" value="false" />
<!-- Include the <csg> and <radlogcheck> task definitions -->
<taskdef resource="com/ibm/ws/batch/cobol/ant/callstub/antlib.xml"
classpath="${csgDir}/lib/COBOLCallStubGenerator.jar"/>
<!-- These input properties are required. They can be specified as arguments to the Ant build. -->
<property name="cobolSource" value="" /> <!-- full path to COBOL source file -->
<property name="workSpace" value="" /> <!-- full path to Eclipse workspace -->
<property name="eclipseProjectName" value="" />
<property name="callStubPackage" value="" />
<!-- The output from the <csg> task is the data binder Ant build file. The data binder Ant
build file invokes the data binder and generates the data binding classes for all
the COBOL parameters for all the COBOL files processed by <csg>. -->
<property name="antBuildFile" value="${workSpace}/${eclipseProjectName}/src/GenAllBindings.xml" />
<!-- Quick way to get the directory of the input COBOL file, in case you wanted to use it
to specify a list of files in the <fileset> type. -->
<dirname property="cobolSourceDir" file="${cobolSource}" />
<target name="CSG">
<csg configFile="${csgDir}/csg.properties"
workSpace="${workSpace}"
eclipseProjectName="${eclipseProjectName}"
antBuildFile="${antBuildFile}" >
<!-- In this example, the input is a single COBOL file, specified using a <fileset>.
You can modify the input to be a list of COBOL files, using either the
<fileset> or <filelist> types. For example, instead of using the cobolSource
property, you can use the cobolSourceDir property to specify all *.cbl files
in the directory or use <filelist> to list a subset of files in the directory.
Examples for setting the input to a list of files are included here, but commented out. -->
<fileset file="${cobolSource}" />
<!-- Example: Set the input to all *.cbl files in a directory: -->
<!-- <fileset dir="${cobolSourceDir}" includes="**/*.cbl" /> -->
<!-- Example: Set the input to a subset of files in a directory: -->
<!-- <filelist dir="${cobolSourceDir}" files="G10M0802.cbl primitve.ccp natltest.ccp" /> -->
<!-- Example: Associate all the nested files with the specified <cobolModule>: -->
<!-- <cobolModule libname="MyDLLName">
<fileset dir="${cobolSourceDir}" includes="**/*.ccp" />
</cobolModule> -->
<!-- You can specify multiple <cobolModule> elements. -->
<callStubPackage>${callStubPackage}</callStubPackage>
<!-- Example: You can use some internal call stub generator properties as substitution
variables. For example, to include the COBOL PROGRAM-ID ($_ProgramId_$) in the
callStubPackage: -->
<!-- <callStubPackage>${callStubPackage}.$_ProgramId_$</callStubPackage> -->
<!-- If not defined, the package name for the data binding classes is
${callStubPackage}.parameters. -->
<!-- <dataElementsPackage>${callStubPackage}.parameters</dataElementsPackage> -->
<!-- Example: Use substitution variables to prepend the COBOL PROGRAM-ID to the
parameter class name. -->
<!-- <dataElementsClass>$_ProgramId_$_$_DataElementName_$</dataElementsClass> -->
<!-- The Java package and class for the parameter identified by 'name' in COBOL
program 'programId' -->
<!-- <dataElement name="#REQUIRED" programId="#REQUIRED" packageName="" className="" /> -->
<!-- You can specify multiple <dataElement> elements. -->
</csg>
<!-- Refresh the workspace in order to compile the Java call stubs generated by <csg> -->
<eclipse.refreshLocal depth="infinite" resource="${eclipseProjectName}" />
<!-- radlogcheck first takes a snapshot of the Rational Application Developer log
(${workSpace}/.metadata/.log). Later, radlogcheck examines the log and searches
for any errors generated during this data binding step. -->
<radlogcheck workSpace="${workSpace}" stage="begin" />
<!-- Now run the data binder Ant build file that is generated by the <csg> task. -->
<ant antfile="${antBuildFile}" />
<!-- Scan the log for any errors that occured during the data binding step.
If errors are detected, the product writes them to the console. -->
<radlogcheck workSpace="${workSpace}" stage="end" />
<!-- Delete the antBuildFile. It is no longer needed and is merely a build artifact. -->
<delete file="${antBuildFile}" failonerror="false"/>
</target>
</project>