With the Project Wizard you specify the Velocity templates that should be used for the code generation and the MIB modules that should be accessible to those templates.
The wizard is divided into three steps which are described by the following sections.
Tip: In order to be able to merge existing code, make sure that the input directories (and file name templates respectively) are provided and point to (copies of) the existing source code.
The Job Configuration specifies the generation jobs to be processed for this project. If the option is selected, any given input directory (see below) will be ignored and existing code will not be preserved.
Environment variables of the operating system can be used within the path strings too. Environment variables may be included in a path string by using the following format: ${<VARIABLE_NAME>}, whereas <VARIABLE_NAME> must contain letters, digits and the underscore ('_') character only.
With the panel, you can specify root directories for relative template paths and input/ouput directories. You may leave these two root directories empty, if you intend to use only absolute paths in the specification below.
Each job consists of the following attributes:
Job Type
The job type specifies whether this job is executed
only once per code generation,
once per MIB module in the module set defined in steps two and three respectively, or
once per context generated by a specified selection template or whether it is executed for each MIB module.
File Name Generation Template
The file name generation template specifies a Velocity template that generates a file name. This file name is then appended to the input and output directories respectively to determine the file name that is subject to the code generation actually done by running the File Generation template.
Parent directories for a generated filename that do not exist will be created by AgenPro.
File Generation
The File Generation Velocity template is the template that actually is responsible for generating the program code. It generates the content of the file(s) whose name(s) has been determined by the File Name Generation Template of this job.
Selection Template
The optional selection template will be executed when the job's type is . A selection template specified for any other job type will be ignored. A selection template has to produce an output text of the following format:
<context1>:
[<Module1>=]<object1>[,[<ModuleN>=]<objectN>..];
<...>
where ModuleN is the module name of the MIB specification defining the MIB object with name objectNameN. There must be generated at least one context per selection template which has to contain at least one object name. Specifying a MIB module name for an object name is optional but recommended since it prevents incorrect mappings when the MIB modules within a project do not have unique object names.
For each context generated by a selection template, an output file will be generated and the code generation job will be executed with the contexts described in the section “Customizing Code Generation” on page 35 for the job type 3. The contexts scalars, tables, traps, etc. will be filled with the selected objects for the respective context name as generated by the selection template.
Because default code will not be replaced with new template code as long as existing code is found, you will have to deactivate the option in AgenPro project wizard to regenerate default code.
But caution: This option affects the whole code generation run. Therefore it might be better to delete/rename the source file that needs new default code instead.
Input Directory (Optional)
The input directory can be the same as the output directory or may be left empty. If the input directory is set to an valid directory, files in that directory will be parsed for AgenPro tags and the code found between the tags, is stored in a map.
The key of the map is build by the string that follows the start tag until the end comment. See “Code Protection” on page 40 for details.
The program code protected by those tags is then available to the generation template when it generates new code from a probably revised MIB module definition. Thus, the protected code may be preserved when an agent is regenerated. This is standard behavior with the AGENT++ and SNMP4J-Agent templates.
Since AgenPro 4.1 templates can generate so called „default code“, which is only generated once.
Output Directory
The output directory specifies the directory where the generated files should be written to. If the input directory is the same as the output directory, existing files will be overwritten without further notice. So backup your agent sources before you run AgenPro.
Filename generation templates might generate filenames that contain relative directory paths. Such directory hierarchies will be created by AgenPro before creating/writing an output file.
The Job Properties wizard step defines global properties for the code generation project. Properties defined here are available in all job types using the agenUtils.getJobProperty method.
To Add a Job Property
1. Choose and enter the property name in the empty column in the newly created row in the job properties table.
2. Enter the value in the column or choose if you want to enter a multi-line value.
To Remove a Job Property
1. Select the property to remove in the table and the choose .
6.4.3 AGENT-CAPABILITIES Selection
If at least one of the loaded MIB modules contains an AGENT-CAPABILITIES statement, you may select the check box. Step two will then replace step three of the wizard.
Note: Only leafs in the displayed tree of available AGENT-CAPABILITIES statements can be selected, because folders (other than the root node) represent the MIB modules defining the AGENT-CAPABILITIES under them.
Instead of selecting the MIB modules with step three, using an AGENT-CAPABILITIES statement has the advantage, that you can specify the objects to be generated on the object level rather than on the module level. In addition, AGENT-CAPABILITIES can provide in depth documentation of an agent implementation.
If you have not specified an AGENT-CAPABILITIES statement in step two, step three allows you to select a subset of the currently loaded MIB modules to be used for the code generation or to use all MIB modules available from the MIB repository at the time of code generation. If you want to select specific MIB modules uncheck the checkbox at the top of the dialog and follow the steps below:
To generate code for a MIB module, that module has to be added to the table on the right by selecting it and using the button.
To disable code generation for a MIB module, remove it from the right table by selecting it and then using the button.
If a MIB module is selected for code generation, then it is a member of the current project.
MIB modules that are members of the current project are displayed with bold text in the open MIB modules list left to the MIB tree. By using the list‘s context menu, the membership of a particular MIB module in the current project can be changed.
MIB objects for which code will be generated are also displayed with bold node names in the MIB tree while the simulation agent is running.
Generated MIB objects are objects that are part of the projects MIB modules or supported by its AGENT-CAPABILITIES and that are not skipped from code generation by a skip=yes property.