Textual Convention class not generated

In my MIB, I’ve defined a textual convention (an enum) to be used in a object bound to a notification. When this object has MAX-ACCESS set to accessible-for-notify, the java class for my textual convention is not generated by agenpro.

It is only generated if I set my object to read-only (for example) instead of accessible-for-notify, or if I add in my mib a separate object that uses this TC but with MAX-ACCESS set to read-only.

Is there a way to tell agenpro to create TC classes even if they are only used in accessible-for-notify objects?

That is an interesting question. Normally, one would not like to create an object (nor a TC for an object) that is not accessible. “accessible-for-notify” are virtual objects for which an object representation in an agent is normally “oversized”.

Anyway, if you need it, you can get it by modifying the java_code.vm Velocity template. The original template uses:

// Scalars
#foreach ( $leaf in $scalars )
#if (!$agenUtils.isDefined($leaf.printableOid, "skip"))
#addTC($leaf $tcModules $tcNames $localTCs $importedTCs)

The reason why your object (leaf) is not generating a TC object is that it is not part of the $scalars collection because it is not accessible for GET operations.
To force a creation for that object, you need to add a single line (here the second line in the snippet below):

// Scalars
#addTC( $module.getObject("<your-object-name>") $tcModules $tcNames $localTCs $importedTCs)
#foreach ( $leaf in $scalars )
#if (!$agenUtils.isDefined($leaf.printableOid, "skip"))
#addTC($leaf $tcModules $tcNames $localTCs $importedTCs)

I have not tested that, but it should work anyway :wink:

Thanks very much for your reply,

Your proposition worked fine!

I usually define objects in MIBs for bound variables to help 3rd parties figuring out what to expect in traps by reading the MIB. For example I find practical to know that one of these variables is providing a value from an enumeration and have the enum somewhere in the MIB…

Thanks again, Eric