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:
- Subclass
KnowledgeBaseFactory
- Implement the fundamental knowledge-base operations:
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
loadKnowledgeBase
- loads an existing knowledge base into the previously created KnowledgeBase object.
includeKnowledgeBase
- includes an existing knowledge base into the previously create KnowledgeBase object.
saveKnowledgeBase
- writes out the knowledge base.
- Implement the simple helper methods
getDescription
- returns a short description of the back-end to display to users.
getProjectFilePath
- returns a path to a PPRJ file that contains customized forms used
by standard classes in this back-end.
isComplete
- returns true if the user has specified enough information (file names, etc.) so that
a save may be performed successfully.
createKnowledgeBaseSourcesEditor
- returns a component in which the user can enter information (file
names, etc.) so that a save may be performed successfully.
- Subclass
KnowledgeBaseSourcesEditor
- 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.
- Implement
validateContents
- checks that the file names and other information
that the user has entered are valid.
- 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:
- Download the source code. (Please make sure to preserve the path information in the ZIP file).
- 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>
.
- 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
- 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.
- Select the File | New Project... menu item and your back-end should appear in the list of project types.