17.5. The Plugins

In this section the different plugins are described. Most of them follow a simple pattern: They contain two methods, one for returning a definition for the plugin (name, required parameters, etc. ) and one for executing it:

interface XYZPlugin extends IPlugin {
   XYZDefinition getDefinition();
   void execute(...); 
}

The XYZDefinition class simply contains getters and setters for the definition of the plugin, so your getDefinition() method should simply return an XYZDefinition where you have set the fields using the setters (setName("MyPlugin") etc). Many of the definitions only contains a name, but having a definition class makes it easier to extend without breaking backwards compatibility.

You will find that all plugin interfaces extends IPlugin. IPlugin is empty and simply a way of ensuring type safety if you want an object you are sure is a plugin.

17.5.1. Macro Plugins

The interface for a macro looks like this:

public interface IMacro extends IPlugin {
   MacroDefinition getDefinition();
   byte[] execute(IValue[] parameters, IEngine engine);
}

public class MacroDefinition {
   // Properties
   private String name;

   // Getters/setters for properties, in this case getName() and setName(name)
   ....
}


Macro plugins are described previously in the 'Quick Example' section, so look there for a complete example.