|
Theseus Generic Plugin Engine |
Plugin Archive File Format
Every plugin can be made available to the plugin engine in two formats. While
developing plugins, it is often easiest to create a plugin project in an
exploded directory structure, which is basically a representation
of the plugin the way it needs to be formatted with any added directories
and files that are specific for development purposes. In this format, a
directory has four primary components.
The descriptor
that every plugin must have to be a valid plugin is named plugin.xml. This is
always found in the root directory of a plugin. The root directory of a plugin
project will also contain a build.xml file (usually), possibly any helper
files such as resource bundles for different languages, and so forth, although
these may be found under other directories.
If a plugin contains a lifecycle class and any other compiled java code, these
must be located in the /classes directory off of the root plugin directory.
A plugin does not require a lifecycle class or any compiled classes. Plugins
may contribute to extension points in other ways besides code, such as adding
html files to an html help system plugin.
If a plugin depends on any third party libraries, these must be placed in the
/lib directory off of the root directory. The plugin engine automatically adds
any .jar and .zip files in the /lib directory as part of the plugins classpath.
A plugin may contribute libraries without providing any other plugin code with
the exception that all plugins that provide any libraries must provide a
lifecycle class in the /classes directory. This is to make sure that all plugins
are given a chance to do any initialization and cleanup when a plugin is
first activated and later when it is destroyed or deactivated. At a bare
minimum, a lifecycle class can simply implement the PluginListener interface
and provide the handleEvent() method with no further code. A common use of
plugins providing only libraries are wrappers around often used libraries,
such as xml parsers, tools like ant, logging libraries and so forth. Learn
more about how libraries can be used by dependent plugins here
The last useful plugin piece is the /resource directory. While you can choose
to put any files like images, html pages and so forth anywhere, the /resource
directory, if present, gets special attention with the engine. It is used by
the getClass().getResource() and getClass().getClassLoader().getResource()
methods to find any resources a plugin may wish to find within the confines
of this directory.