!!! 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|Meaning of pluginxml].

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:

*The elements within the path are separated by "/".
*If the scope starts with "/" it must match its path from the KDOM root.
*Each of the path entries name a KDOM node, either by naming the "name" of the Type (see Type.getName() or its simple class name or the simple class name of any of it's super-classes or interfaces.
*For default markups the name of the markup section can be used. For it's annotations the annotation name can be used. For a default markup content section "content" can be used. (e.g. "solution/package" matches the package declaration of the solution markup).
*The matching is done case insensitive.
*If you specify a "*" wildcard as a path entry (".../ * /...") any section is matched to it.
*If you specify a "**" wildcard as a path entry (".../ ** /...") , any sub-path is matched to it. Especially also the empty sub-path is matched. (If you want to *have at least one section in between, use ".../ ** / * /...".) 

!! Kinds of Scopes

There are onle a few scopes. Here are descriptions for some of them.

! Scope for Types

For the class [Type|https://isci.informatik.uni-wuerzburg.de/javadoc/KnowWE/de/knowwe/core/kdom/Type.html] scope defines the father type. For example root is the father of HeaderType.

%%prettify {{{
	<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|https://isci.informatik.uni-wuerzburg.de/javadoc/KnowWE/de/knowwe/tools/ToolProvider.html] scope defines at which markup the tools should appear. For example the tools of WikiBookDownloadProvider are for WikiBook.

%%prettify {{{
	<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 SubTreeHandler

For the abstract class [SubTreeHandler|https://isci.informatik.uni-wuerzburg.de/javadoc/KnowWE/de/knowwe/core/kdom/subtreeHandler/SubtreeHandler.html] scope defines at which markup the tools should appear. For example the tools of WikiBookDownloadProvider are for WikiBook.

%%prettify {{{
	<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>
}}}
/%

%%tags
howto
%