Plug-in startup process

For a plug-in to be recognized by the WAT, it has to implement an entry method and perform a few startup tasks. The Plugin classes/jar file also have to be in the WAT's classpath, and be loaded as a plugin in the Plugins -d variable.

Plug-in Jar file location

The plug-in's jar file must be placed in the WAT's install folder's jar/ext folder. When the WAT starts it searches that folder for jar files and for every jar file added to the PLUGINS -d variable for a valid manifest entry. During development and debugging of a plug-in, placing an the plug-in's jar file in the jar/ext folder with just the manifest entry and no classes and then referencing the plug-in classes in the classpath makes things easier because the plug-in jar file doesn't have to keep being updated.

Plug-in Entry Method


Plug-ins are started by the com.rma.util.PluginLoader. It calls the plug-in's main class's public static void main(String[]) method to start the plug-in. The class containing the main method must be specified in the plug-in jar's manifest file.


Jar File Manifest Entry

In the plug-in's jar file, in the META-INF folder there's a MANIFEST.MF file. The manifest file must contain the entry:
WatPluginMainClass: <path to plugin class with main method>
As an example:
WatPluginMainClass: hec2.wat.plugin.ras.RasPluginClient
It is possible to have multiple plug-ins in a single jar file. Just append a unique identifier after the WatPluginMainClass.
WatPluginMainClass1: myplugins.MyPlugin1WatPluginMainClass2: myplugins.MyPlugin2

Plug-in initialization

The Plug-in must register with the hec2.wat.plugin.WatPluginManager to be recognized by the WAT. They also need to create a hec2.model.ProgramOrderItem and register it with the hec2.model.ProgramOrderItem class with a call to ProgramOrderItem.addProgramOrderItem(ProgramOrderItem) to participate in a compute.
If the plug-in has a server-side component, its server should be started up during the plug-in's initialization.

WatPlugin Manager

The WAT contains a Plug-in Manager (hec2.wat.plugin.WatPluginManager) that all plug-ins that wish to participate in simulation modeling are required to register with. To register with the WAT PluginManager the plug needs to implement the WAT Plug-in interface hec2.wat.plugin.BasicWatPlugin or one of its subinterfaces. The call to the WAT Plug-in Manager is simple:
WatPluginManager.register(this);