<?xml version='1.0' encoding='UTF-8'?>
<!-- This file is part of the DITA Open Toolkit project hosted on 
     Sourceforge.net. See the accompanying license.txt file for 
     applicable licenses.-->
<!-- (C) Copyright IBM Corporation 2005, 2006. All Rights Reserved. -->
<!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "..\..\..\dtd\topic.dtd" []>
<topic xmlns:ditaarch="http://dita.oasis-open.org/architecture/2005/" id="plugindesign">
  <title>Design: Create plugin architecture</title>
  <body>
    <section spectitle="introduction">
      <p>There are 2 options for the plugin architecture. </p>
      <p>Option One is just like eclipse plugin architecture. We load the plugins every time a build is invoked.</p>
      <p> 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. </p>
    </section>
    <section spectitle="Overview">
      <p>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.<fig>
          <title>Structure of ant script</title>
          <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.</note>
          <image href="images/antStructure.JPG" alt="structure of ant script"/>
        </fig></p>
    </section>
    <section>
      <p>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.</p>
    </section>
    <section>
      <p>Here is the internal class structure between Integrator and other java classes<fig>
          <title>Internal class structure</title>
          <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.</note>
          <image href="images/structure.JPG" alt="class structure"/>
        </fig></p>
    </section>
    <section>
      <p>Here is the sequce diagrams for the overall build process and detail integration process.<fig>
          <title>Overall build process</title>
          <image href="images/overall_sequence.JPG" alt="Overall build process">
            <alt/>
          </image>
        </fig><fig>
          <title>Detail sequence of integration</title>
          <image href="images/detail_integration.JPG" alt="detail integration sequence"/>
        </fig></p>
    </section>
    <section>
      <p>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&apos;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.</p>
      <p>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.</p>
    </section>
    <section>
      <p>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.</p>
      <p>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.</p>
    </section>
  </body>
</topic>
