Skip to content
peacekeeper edited this page Oct 2, 2012 · 16 revisions

The XDI2 library supports a plugin mechanism, which makes it possible to extend its functionality in various ways.

Plugins can apply to any of the library's components, for example:

  • A plugin for the xdi2-core component could provide a new [backend storage mechanism](Available backend storage for XDI graphs) or a new serialization format.
  • A plugin for the xdi2-client component could provide a new way of sending XDI messages, e.g. via SMTP.
  • A plugin for the xdi2-server component could provide new messaging targets, interceptors and contributors.

Plugins

A plugin is a single .jar file containing within itself any number of .jar files, all of which are added to the XDI2 library's classpath when the plugin is loaded.

The typical contents of a plugin .jar file look like this:

/
	xdi2-example-plugin-classes.jar
	/META-INF
	/dependency
		dependency-jar-1.jar
		dependency-jar-2.jar
		dependency-jar-3.jar

This is just an example however. The specific directory structure of a plugin is not mandated and in fact has no effect whatsoever on the loading or the execution of plugins.

Loading Plugins

To load plugins, the following call should be made before other XDI2 library code is used:

xdi2.core.plugins.PluginsLoader.loadPlugins("<path-to-plugins>");

If null is passed as a parameter, the default path is assumed, which is ./plugins.

When running the xdi2-server or xdi2-webtools components, a servlet listener can be used in one's web.xml [configuration file](Configuration files) to load plugins from the default path:

<listener>
	<listener-class>xdi2.server.plugins.PluginsLoaderListener</listener-class>
</listener>
Clone this wiki locally