Native Support for Wizards

Wizards written in Java can be executed on more than one platform. However, most wizards will require a lower level access to the operating system than pure Java provides. For example, an install wizard could not properly perform its function if it were not able to register the installed software in the product registry. Native support for wizards provides a mechanism through which this need can be met.

Wizard objects can use the native support provided through the SystemInterface class. This class has methods that:

The SystemInterface class defers the responsibility of these methods to another class that implements the PlatformToolkit interface. This second class is platform specific. That is, the PlatformToolkit class is designed specifically for one platform (or at least a single type of platform), and is able to interact with the operating system at a level not available to pure Java code.

The PlatformToolkit instance must have a very specific name, so the factory method that instantiates it will know what platform(s) it supports. For example, the PlatformToolkit that works for the Solaris operating system is called SolarisPlatformToolkit. The name SolarisPlatformToolkit is derived from the property "os.name" followed by "PlatformToolkit". Similarly, a PlatformToolkit class for Windows NT might be Windows_NTPlatformToolkit (all spaces within the os.name property are replaced with an underscore). However, it is possible on the Windows family of platforms to be able to describe all of them with a single PlatformToolkit object called WindowsPlatformToolkit. So if the more specific Windows_NTPlatformToolkit class does not exist, the factory method will also try the less specific WindowsPlatformToolkit for Windows 95, Windows 98, and Windows NT platforms.

Wizards can be executed on a variety of platforms, and the native support for wizards had to be written so that all of these platforms could be supported. JNI (Java Native Interface) is the preferred mechanism through which platform-specific code can be executed from Java. JNI provides a rich set of functions that allow the native code to interact with Java objects directly.

Unfortunately, JNI is not supported by all Java virtual machines. For example, Microsoft's jview vm supports JDirect instead of JNI. Since JDirect is a Microsoft technology that is not part of the Java standard, both JNI and JDirect technologies fail to meet the requirement that wizards execute on all (or at least most) platforms.

The technology that WebStart Wizards employ is actually an executable that the wizard can communicate with. The executable is platform-specific and is able to perform any operation required by the wizard that cannot be accessed through Java. The fact that the executable is platform-specific is no different than if wizards were to use JNI - this would also require a platform-specific shared library. At this level, the difference between JNI and the executable solution is that the functions within the executable must be called using Java IO, and the executable has no way to create, return, or modify Java objects.

This executable is a resource of the PlatformToolkit object that can be used to communicate with the operating system at a level that pure Java does not support. For example, the executable is used to get and set file permissions and attributes.

At buildtime, platform support is written into the wizard archive. This platform-specific support includes the executable and the Java classes that communicate with the executable. By default, the ArchiveWriter will include all platform support available. The specific platforms can be specified if the wizard is intended to run on only one or two platforms. For example, an install wizard that installs a Windows NT product probably would not benefit from having Linux support built in. The specific platform(s) can be selected by calling the setArchivePlatforms method of ArchiveWriter.

The support files for each platform the wizard supports are written into the wizard archive. The platform-specific executable files are referenced by a Platform object that describes its target.

At runtime, only the executable referenced by the most specific platform description compatible with the runtime environment gets used. The factory method for the PlatformToolkit classes instantiates the appropriate class and connects that through the SystemInterface object.


Last modified: Fri Nov 25 16:48 PDT