Design: Create plugin architecture (zz)

 原文地址:http://dita-ot.sourceforge.net/SourceForgeFiles/doc/plugin/design.html

Design: Create plugin architecture

introduction

There are 2 options for the plugin architecture.

Option One is just like eclipse plugin architecture. We load the plugins every time a build is invoked.

Opion Two is like mozilla firefox. Every time when we installed new plugin, we should start a program to install those plugin and integrate them with toolkit.

Overview

In order to implement either of the above options. We can write a program to generate an integrated interface for ant script or xsl etc. which will be called in the building process. In the following diagram Integrator is such a program which combine every ant script into one integrated script which imports the content from the script of each plugins. This mechanism can ensure that we can implement either option 1 or option 2. When we want to remove a plugin, we can just delete that plugin and call the Integrator again to regenerate integrated ant script. Integrator can also works on the validation of plugins dependency which will make sure that each plugin we will load can work properly.
Figure 1. Structure of ant script
Note: In the figure, ant script 1 is the ant script provided by plugin 1. Integrated ant script is generated by Integrator. It imports different ant scripts from every plugin and serves as the call interface.
structure of ant script

If we want to implement Option One, we need to put the integration step before the preprocess when a build is invoked. If we want to implement Option Two, we can just put integrator as utility in the toolkit and ask users to run that whenever they update, install or remove any plugin. Now we decided to support Option One. So the integrator should be run every time when a build is started and generate the general ant script to be called in the main transformation.

Here is the internal class structure between Integrator and other java classes
Figure 2. Internal class structure
Note: In this diagram, Integrator is used to generate all of the integrated ant script, xsl or catalog files. PlugTable is used to find and register all of the plugins. Class Plugin is just like every entry in the plugin table which contains the all of the information for each plugin.
class structure
Here is the sequce diagrams for the overall build process and detail integration process.
Figure 3. Overall build process
Figure 4. Detail sequence of integration detail integration sequence

The plugin can also contains the document which serves as the sample document for the plugin. It should contain at least the build script for the document or the document in web pages style with a toc file. The toolkit won't run the build script automatically. Any document plugin with only the source dita files and build script will be considered as the source document plugin and can be build into plugin that toolkit can integrate.

The integration of document is similar to that of ant script. The integrator will generate a general toc file which links to different toc files for each plugin.

Plugin descriptor is an xml file which describe the structure of the plugin and what the plugin contains. The PluginTable search the plugin according plugin descriptor. If there is no plugin descriptor then the plugin cannot be integrated by the toolkit.

Plugin descriptor also contains the dependency information of the plugin and contact information of plugin author. Integrator will validate the dependency between plugins and it will not load the plugin if its required plugin is not loaded. The plugin author information will also be put to website but it can be found in the plugin when the website is inaccessable.

原文地址:https://www.cnblogs.com/strinkbug/p/1349347.html