Theseus Generic Plugin Engine

Extensions

Extensions are the means by which plugins contribute new functionality to other plugins. To do so, an extension point must be registered with the plugin engine for each extension to it to be resolved. The plugin owner of the extension point does not have to be instantiated/activated for resolution to occur. The plugin registry stores a Plugin model object to represent each plugin. Part of this plugin model is a list of any extension points the plugin contributes, and each of these represent a list of any matching extensions offered by loaded plugins.

Extensions can be implemented in any number of manners. Most often a plugin that provides an extension point will provide some documentation regarding how it is used. An extension can be used like an event, where the plugin code may add a button to a form and when clicked, the plugin code will grab the specific extension point representing that button, iterate through any registered extensions, calling a method of an interface each extension plugin is expected to implement. It may be that an extension point represents an HTML help system where by each extension provides information where to find html files to add to the help system. In this scenario, no plugin code is required for each extension plugin (assuming it doesn't provide any extension points or other extensions that do require plugin code).

It is important to realize that an extension, like an extension point, is simply a string identifier of a point where two plugins meet. The extension point owner is the controller, and each extension act to do as they are instructed by the extension point code. All extension points will have code behind them, doing something with each extension added.

Take particular note that it is imperative when developing an extension to make absolutely sure you fully understand the requirements of the extension point being extended. Some extension points may provide one or more interfaces or classes required to be implemented or extended from to allow the extension to work properly within the context of the extension point code. Some may not require any code at all, some may require a single implementation from an extension, and somehow the specific extension used is selected, either automatically, or by a user configurable option such as in a preference dialog where a user may choose from one of many extensions. Some extension points may like to use all extensions but provide a means to arrange the order of extensions, such that setting the extension that is first used, last used, and so forth can be done. Again, it is completley up to the extension point plugin developer to instruct how the extension point is to be used.

Extension points are very simple. They are nothing more than a single string identifier. They may optionally specify an interface of class name that must be implemented or extended by each extension. This optional parameter is used to enforce a specific class type to be instantiable from each extension. As such, there needs to be a way for each extension to specify information that extension points can use to fulfill their requirements. An extension point that adds html pages to a help system must be given information by each extension where to find html files, where in the help system the html page may go, and so forth. The Theseus Generic Plugin Engine provides a dynamic xml capability for each extension, allowing any amount of xml to be provided with each extension. As there is no means to validate the xml against a dtd or xml schema, it is essential each extension developer be completely accurate in the required xml nodes, and pay attention to any option nodes that may be of benefit to an extension. Let's walk through a simple html help example. In this example, the extension point will provide a little bit of info. We'll give the extension point string identifer the name of "help.index". Below will be a sample of what might be provided with a plugin in regards to its documenting an extension point.

Help System Extension Point Reference

help.index - Provides a hook to add index pages to the help system.
help.index dynamic xml requirement
<point uid="help.index">
  <index file="somefile.html">
    <page file="afile.html"/>
    <page file="bfile.html"/>
  </index>
</point>

Each extension needs to provide the index page and any pages that link from that index page. To do so, the index node is used to specify the index html page. Below the index node, one or more page nodes may be specified to indicate pages linked from the particular index.

Index   Back To Extension Points   On To Plugin Archive File