How-To Extension Points
Back to current version Restore this version

Extension Points#

A plugin consists of an XML file and a collection of class files (compiled source code). The XML file specifies, which points in the source code are extended by the classes. Also, new points in code can be defined that are extensible. We call these points within the code ExtensionPoints, and we call the classes extending these points Extensions. The structure of the XML file is described in more detail in plugin.xml.

For each ExtensionPoint there exists an interface, that have to be implemented by the class extending the ExtensionPoint. Then, the PluginManager provides an array of instances, that define this ExtensionPoint. The array is sorted according to the priority of the extensions. The priority is defined in the XML file as well as the name and the description of the extension.

In addition, it is possible to define further attributes for an ExtensionPoint. These attributes have to be included in the XML file of the implementing extensions.

Working with Scope#

A scope is an selector of a specific subset of KDOM nodes. Its selection is based on the type of the KDOM nodes itself as well as on the type of the KDOM node's anchestors. It can be compared a little bit to the css selectors.

The scope is a path of those KDOM node types that should be matched/selected. The path can be relative (anywhere in the KDOM tree) or root based. Specific path wildcards as "*" and "**" are allowed.

Synopsis:

Kinds of Scopes#

There are only a few scopes. Here are some descriptions for the most important scopes.

Scope for Types#

For the interface Type scope defines the enclosing type. For example root is the enclosing type of HeaderType. This means that the sections of type HeaderType are located in the root-level of the wiki page, instead of being a sub-section of sections of any other specific type.
	<extension plugin-id="KnowWEExtensionPoints" point-id="Type"
		id="HeaderType">
		<parameter id="class" value="de.knowwe.jspwiki.types.HeaderType" />
		<parameter id="name" value="HeaderType" />
		<parameter id="description" value="Represents a HeaderType in KDOM" />
		<parameter id="version" value="0.2" />
		<parameter id="priority" value="2.1" />
		<parameter id="scope" value="root" />
	</extension>

Scope for ToolProvider#

For the interface ToolProvider scope defines for which markup(s) the tools should appear in the tool menu. In the example below, the tools of WikiBookDownloadProvider are shown for the "%%WikiBook"-markup.
	<extension plugin-id="KnowWEExtensionPoints" point-id="ToolProvider"
		id="WikiBookDownloadProvider">
		<parameter id="class"
			value="com.denkbares.wikibook.WikiBookDownloadProvider" />
		<parameter id="name" value="WikiBookDownloadProvider" />
		<parameter id="description"
			value="Offer a download button to download the Wikibook." />
		<parameter id="version" value="1.0" />
		<parameter id="priority" value="5" />
		<parameter id="scope" value="WikiBook" />
	</extension>

Scope for Renderer#

For the interface Renderer scope defines which type should be rendered by the Renderer. The example below defines, that the root section (the whole wiki-page content) is rendered by an instance of the class RootTypeIdRenderer.
	<extension plugin-id="KnowWEExtensionPoints" point-id="Renderer" id="RootTypeIdRenderer">
		<parameter id="class" value="com.denkbares.editmode.RootTypeIdRenderer" />
		<parameter id="name" value="RootTypeIdRenderer" />
		<parameter id="description" value="Adds ids to rendered sections to allow editing in EditMode" />
		<parameter id="version" value="1.0" />
		<parameter id="priority" value="5" />
		<parameter id="scope" value="root" /> 
	</extension>