Metaprogramming Text Processor

Using the MTP Tool

The MTP tool is implemented as a Java application. It can be activated in any computing environment in which Java is installed. The tool is currently provided as part of a DsE adoption initiative; otherwise, it is only available by request to PHS.

{historical note: Both Java applets and Java Web Start (javaws) have now been deprecated and removed from current Java releases. The following describes its use prior to that. The previously defined examples described in Adaptable component examples still work as indicated with Javaws}
The MTP tool was developed as a Java applet-application hybrid. It supported being activated directly as an application in a conventional environment or via an HTML file in a web browser. Alternatively, the MTP tool could be linked directly with other Java code to create integrated product generators. It also included an implementation of a plugin for the Metrowerks CodeWarrior integrated development environment that enabled the use of MTP files for streamlined generation of executable code. The form of the MTP input was the same (with minor differences) regardless of the form of tool activation used.}


{The following needs to be revised to illustrate use of MTP as an application.}

Activation of MTP using HTML

To use MTP, first create an MTP-annotated input file. At a minimum, this file will contain one metaprogram definition and an instantiation of that metaprogram.

To apply the MTP tool through an applet to your input file, create an HTML file with contents similar to the following:

<html>
<head> <title>Generated Component</title> </head>
<body>
<applet archive="http://www.domain-specific.com/MTP/metapLib.zip"
	code="component.class"  width=420 height=315>
<param name="file" value="sample.mtp">
</applet>
</body>
</html>

changing the value of the "file" parameter from "sample.mtp" to the name of your input file. You then open your HTML file with your favorite browser that supports Java 1.1 programs. Your browser will then display the output of MTP processing.

Select the file ELT.java.mtp to see an example of an MTP annotated Adaptable Component. This component contains a definition and instantiation of a metaprogram named "setTracker". It generates compilable Java source code that implements a simple expense ledger capability. Activate the file ELT.html to display the generated Java code that results.

Note that this means of using MTP over the Internet, due to security conventions, imposes two constraints inherent to Java applets. First, use of "file inclusion" statements will cause most browsers to produce a security violation and terminate the applet without producing a result. Second, although MTP is capable of generating its output into a file, the applet form must generate all output into a window; you can then either print the window's contents or select, copy, and save the text to a file using browser commands.




PHS