Extension debugging strategies
When you extend Creo Elements/Direct Model Manager you add a small amount of code to the whole Creo Elements/Direct Model Manager code base. Creo Elements/Direct Model Manager 20.8 includes several new debugging aids at different architectural levels. This set of debugging strategies should help you quickly find any defects in your extension code.
Test first
The
Creo Elements/Direct Model Manager developers use test-first development as part of the eXtreme Programming process. Basically, before writing any code, you write a test that will fail until the code change has been successfully implemented. See
How to run Creo Elements/Direct Model Manager unit tests for more information on how to run the
Creo Elements/Direct Model Manager unit tests and add your unit tests.
Ant is a common Java test utility, which is integrated with NetBeans. The Creo Elements/Direct Model Manager extension development scripts are written in Ant.
If you don't want to create an automated test, it's helpful to at least run through the steps that will invoke the extension manually and jot down your actions and Creo Elements/Direct Model Manager's responses. When Creo Elements/Direct Model Manager doesn't respond the way you expect after your code change, you can look back at your notes to see how it behaved before.
If your code change includes database queries, it's good to also document the current performance. The new WANproxy, which will be described later, is useful for measuring the performance of database queries through the database server.
Use the Java debugger
A debuggable
WorkManager.jar file is shipped with
Creo Elements/Direct Manager Server to make it easier to debug extensions with a Java debugger. See
How to start the NetBeans debugger for more information on setting up the NetBeans debugger to debug
Creo Elements/Direct Model Manager extensions.
Use WAN proxy for performance problems
WANproxy monitors the communication between Creo Elements/Direct Model Manager and the database server. WANproxy can simulate performance over a Wide Area Network (WAN) by simulating the latency between Creo Elements/Direct Model Manager and the database server.
To use WANproxy, set wanproxy.enabled to true in dev.properties (in the extension build tools). To simulate performance over a WAN, set wanproxy.latency to on.
Use PDMTrace to analyze kernel calls
If you are trying to debug calls to PDM, Creo Elements/Direct Model Manager's C kernel, it's easiest to watch your code with a debugger, as explained earlier in this document. But if that doesn't help and you need to see inside PDM, Creo Elements/Direct Manager Server includes a PDMTrace tool.
The default PDM listener is in WorkManager.jar/com/osm/tools/PDMTrace. Since the PDM trace tool produces so much output, it's best to narrow your search down to one PDM call before turning on the listener.
To use the PDM trace tool, surround the PDM call with the following code:
PDMTrace myListener = new PDMTrace();
pdm.addDebugListener(myListener);
<your code>
pdm.removeDebugListener(myListener);
You can create your own PDM listener by extending com/osm/tools/PDMDebugEventListener. Every PDM function is enclosed by beginCall() and endCall(). Extending these two functions will allow you to customize the output. See PDMTrace for an example.
Run the unit tests
Run the
Creo Elements/Direct Model Manager unit tests to see whether your customization has broken any of the base product functionality or any of your extension functionality for which you have written tests. See
How to run Creo Elements/Direct Model Manager unit tests for more information on how to run the
Creo Elements/Direct Model Manager unit tests.
Still doesn't work?
Here are some other things to check...
In NetBeans
• Are the class locations the same in all places - classes and source directory structure, as well as in the XML file?
• Are there any extra files in the classes directory?
In the XML file
• Are the correct servers configured?
• Is the format of the file correct (e.g. required tags)?
• Is capitalization correct?
Is the database schema the one you expect?