extension-point schema

先看个例子,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 &lt;i&gt;long&lt;/i&gt; as its input, and returns
         a &lt;i&gt;long&lt;/i&gt; 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>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值