5.1.1 Visual Debugging with Java
As explained in Section
2.6, visual debugging uses the MetaEdit+
API to access the models during the application execution. To make this
possible, a few additions on the code generator side are required. First we need
the following three additions to ensure that we have a working connection to the
API and the required information to make the animation calls:
| 1) | Master
init: initializes the variable holding a port on the MetaEditAPI SOAP
service |
| 2) | AbstractWatchApplication
constructor: makes an MEOop reference for this
graph |
| 3) | AbstractWatchApplication
addStateOop: makes an MEOop reference for this state
object |
 | The
MEOop mentioned above is a data type for a variable holding a reference to a
model instance in MetaEdit+. For more information about API-specific data types
and the API in general, please refer to the Section 8 in ‘MetaEdit+
Workbench User’s Guide’. |
To
make the actual animation calls to MetaEdit+, a further set of three additions
are needed:
| 4) | AbstractWatchApplication
handleEvent: handles the event of moving to a new state, calls
animate |
| 5) | AbstractWatchApplication
animate: calls Master animate with the graph and state
MEOop |
| 6) | Master
animate: calls port.animate |
These are the
modifications required for the generated Java code. However, the Autobuild
process itself also requires a few modifications. To be able to establish the
connection with MetaEdit+ API, two things are needed: a Web Service Description
Language (WSDL) file that defines the interface for the available API commands,
and a running API server at the MetaEdit+ end. Both of these needs are fulfilled
by the ‘_prebuild for Java: API’ subgenerator by internally
executing a few MetaEdit+ start-up commands. It will first use
saveWSDL: to write out the WSDL file,
then ensure that the API server is running by executing
stopAPI and
startAPI.
Finally, the build process must be changed to ensure that
we link in the SOAP framework that will interface the Java code with the
MetaEdit+ API. The makeWatch.bat file
is augmented with commands that take care of building the SOAP interface for
Java from the generated WSDL file using the Apache Xerces2 XML parser and Apache
Axis SOAP library, as shown in Listing 3.
if "%cd%"=="" set cd=..
set wsdlFile="%cd%\MetaEditAPI.wsdl"
cd /D reports\2012Models\src\
@if exist *.class del *.class
@del ..\bin\com\metacase\API\*.class
set classpath=C:\Java\axis-1_4\lib\*;C:\Java\xerces-2_11_0\*;.
"C:\Program Files\Java\jdk1.6.0_37\bin\java"
org.apache.axis.wsdl.WSDL2Java -p com.metacase.API %wsdlFile%
@echo on
"C:\Program Files\Java\jdk1.6.0_37\bin\javac" -d ..\bin
com\metacase\API\*.java
@cd /D reports\2012Models\src\
@if exist *.class del *.class
@echo on
"C:\Program Files\Java\jdk1.6.0_37\bin\javac" -d ..\bin @javaFiles
@cd ..\bin
javaw com.metacase.watch.generated._2012Models
exit
Listing 3. makeWatch.bat for visual debugging