先看个例子,com.bolour.sample.eclipse.service.ui_1.0.0的extension-point schema,省略了部分不重要的内容.
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
<schema targetNamespace="com.bolour.sample.eclipse.services.ui">
<annotation>
<appInfo>
<meta.schema plugin="com.bolour.sample.eclipse.services.ui" id="functions" name="Functions"/>
</appInfo>
<documentation>
Each extension provides one or more service callbacks functions.
For each function, the service UI plug-in will add
a button for invoking the function, and a label that identifies
the function, to its user interface. The UI plug-in also provides an input
field and a result field that are shared between all function.
The function takes a <i>long</i> as its input, and returns
a <i>long</i> as its output.
</documentation>
</annotation>
<element name="extension">
<complexType>
<sequence>
<element ref="function" minOccurs="1" maxOccurs="unbounded"/>
</sequence>
<attribute name="point" type="string" use="required">
<annotation>
<documentation>
The extension-point of this extension.
</documentation>
</annotation>
</attribute>
<attribute name="id" type="string">
<annotation>
<documentation>
Extension identifier.
</documentation>
</annotation>
</attribute>
<attribute name="name" type="string">
<annotation>
<documentation>
Name of this extension.
</documentation>
</annotation>
</attribute>
</complexType>
</element>
<element name="function">
<complexType>
<attribute name="name" type="string">
<annotation>
<documentation>
The name of the function.
</documentation>
</annotation>
</attribute>
<attribute name="class" type="string">
<annotation>
<documentation>
The specific class implementing the function.
</documentation>
</annotation>
</attribute>
<attribute name="constant" type="string">
<annotation>
<documentation>
A constant parameter used in the computation of the function.
This constant may be interpreted differently by different extension members.
For example, in a member that provides an exponentiation function,
the constant is interpreted as the exponent.
</documentation>
</annotation>
</attribute>
</complexType>
</element>
</schema>
再看multplication的plug-in.xml, 可以看出,这个plug-in.xml就是依据上面schema的格式定义的。首先,extension element包括point, name, id三个域,以及若干个function域。每个function也是依照schema的定义,分别包括name, class, constant三个域。
<?xml version="1.0" encoding="UTF-8"?>
<plugin
id="com.bolour.sample.eclipse.service.multiplication"
name="Multiplication Service"
provider-name="Bolour Computing"
version="1.0.0">
<runtime>
<library name="multiplication.jar">
<export name="*"/>
</library>
</runtime>
<requires>
<import plugin="org.eclipse.ui"/>
<import plugin="com.bolour.sample.eclipse.service.ui"/>
</requires>
<!-- Multiplication operations for specific multiplication factors. -->
<!-- The multiplication service interprets the attribute "constant" of a service
as a multiplication factor to be used in the service's multiplication operation. -->
<extension
id="functions.multiplication"
name="MultiplicationFunctions"
point="com.bolour.sample.eclipse.service.ui.functions">
<function
name="DOUBLE"
constant="2"
class="com.bolour.sample.eclipse.service.multiplication.Multiplication">
</function>
<function
name="TRIPLE"
constant="3"
class="com.bolour.sample.eclipse.service.multiplication.Multiplication">
</function>
<function
name="QUADRUPLE"
constant="4"
class="com.bolour.sample.eclipse.service.multiplication.Multiplication">
</function>
</extension>
</plugin>