USERS
DEVELOPERS


see also:
CREATEPROJECT
EXPORT
PROJECT
SLOT WIDGET
TAB WIDGET
 how to write a back-end plug-in

This page describes how to write a file-based back-end for Protégé. A back-end plug-in is the most difficult type of plug-in to write. If you do not have experience writing one of the other plug-in types, we suggest that you first write a tab widget plug-in, after which you will understand most of the process and "administrative" matters involved in getting plug-ins to work. You will then be able to concentrate on the specific requirements of a back-end plug-in.

Developers of back-end plug-ins may be interested in reading the documentation on our Web site that details the differences between the createproject, export, and back-end plug-in types.

There are a number of things that need to be done to implement a back-end plug-in:
  1. Subclass KnowledgeBaseFactory
    1. Implement the fundamental knowledge-base operations:
      1. createKnowledgeBase - creates an new object which implements the KnowledgeBase interface. Usually just creates a new instance of DefaultKnowledgeBase. It may populate this KnowledgeBase object with "standard" frames
      2. loadKnowledgeBase - loads an existing knowledge base into the previously created KnowledgeBase object.
      3. includeKnowledgeBase - includes an existing knowledge base into the previously create KnowledgeBase object.
      4. saveKnowledgeBase - writes out the knowledge base.
    2. Implement the simple helper methods
      1. getDescription - returns a short description of the back-end to display to users.
      2. getProjectFilePath - returns a path to a PPRJ file that contains customized forms used by standard classes in this back-end.
      3. isComplete - returns true if the user has specified enough information (file names, etc.) so that a save may be performed successfully.
      4. createKnowledgeBaseSourcesEditor - returns a component in which the user can enter information (file names, etc.) so that a save may be performed successfully.
  2. Subclass KnowledgeBaseSourcesEditor
    1. Implement the constructor - add elements to the panel that are specific to this back-end. This usually includes one or more fields for file names.
    2. Implement validateContents - checks that the file names and other information that the user has entered are valid.
    3. Implement saveContents - saves the file names and other information that the user has entered into a "sources" property list.
We have provided example code for a back-end to help you get started. Please note that the code is stubbed off in a number of places and the example back-end does not actually write out or read in a knowledge base. Nevertheless, the structure is common to most file-based back-ends.

Follow these steps to compile and run the example back-end:
  1. Download the source code. (Please make sure to preserve the path information in the ZIP file).
  2. Set up your Java development environment:
    • Use JDK 1.4 or higher for your compiler.
    • Configure the compiler to write output classes to <protege_install_dir>/plugins (replacing protege_install_dir with your Protégé installation directory).
    • Add the following JAR files to your classpath: protege.jar, looks.jar, unicode_panel.jar.
    • Pass the JVM the following parameter -Dprotege.dir=<protege_install_dir>.
  3. Compile the source code. Check that your compiler has indeed put the ExampleBackend and ExampleSourcesEditor class files into the "plugins/examples/backend" directory. Also, please make sure that your development environment copies the meta-inf directory with the manifest file to your output directory. Some development environments do this by default, others require you to specify that MF files should be copied to the output directory. The following is an example of what your directory structure should look like after properly downloading and compiling the example code:
    
    <protege_install_dir>
        plugins
            examples
                backend
                createprojectplugin
                exportplugin
                projectplugin
                slotwidget
                tabwidget
            meta-inf
    
  4. Run the example from your development environment, specifying edu.stanford.smi.protege.Application as the main class. You may also wish to specify the name of a project as an application parameter so that when Protégé starts up, a project will automatically be loaded. Any "Duplicate plugin" warnings are benign and can be ignored.
  5. Select the File | New Project... menu item and your back-end should appear in the list of project types.