wiki:plugins

Plugins for TNTBase

To understand why one might need plugins refer to the Integration page.

Plugin API library

The plugin API jar file can be obtained from repository under api depending on a TNTBase version. Also the plugin jar may be built by running ant plugin.api in the DbXmlAccessLib folder. The result will be placed into the dist/pluginapi directory.

Implementing a plugin

Every plugin should implement info.kwarc.tntbase.pluginapi.TntIntegrationPlugin. It has two methods:

  1. public void init(TntPluginDocumentResolver<T> resolver) throws TntPluginException - it is invoked once when Web application is deployed. It received the resolver object, that helps a plugin to locate documents inside TNTBase repository. Also it may resolve XML documents which are in the on-going xSVN transaction, but were not committed yet. This might be useful for pre-commit validation
  2. public T performAction(String path, long revision, TntPluginContext context) throws TntPluginException - this method is invoked on every document that has to be validated or processed by other means. The context object holds parameters that have been passed to TNTBase via a validation/presentation URL. In future this object may hold some additional information.

Packing

When implementation is done, it should be packed into a jar. One additional requirement: the plugin directory structure must contain /META-INF/services folder with the file named info.kwarc.tntbase.pluginapi.TntIntegrationPlugin. Its content should list fully-qualified names of implementation classes, one per line. For more info refer to  http://java.sun.com/javase/6/docs/api/java/util/ServiceLoader.html. Ant jar task may help you to create this structure automatically. Note that it works properly in And 1.7.1 and later.

Deploying

When plugin jar is ready it should be placed to plugins folder of the TNTBase application. Reloading of TNTBase web application is necessary in order to fetch this plugin.

Example

MMTPlugin