适配器扩展点允许插件注册适配器工厂。运行时 XML 表达式语言使用此信息来确定适配器是否存在,而不会导致装入插件。
通过扩展点注册适配器工厂可以使得启动插件时无需手工注册适配器工厂
eg:
<extension
point="org.eclipse.core.runtime.adapters">
<factory
adaptableType="com.jfans.model.Person"
class="com.jfans.adapter.AdapterFactory">
<adapter
type="org.eclipse.ui.views.properties.IPropertySource">
</adapter>
</factory>
</extension>
说明:
class:对应适配器工厂(即实现IAdapterFacotry接口的类)
adaptableType:将要适配的类,此工厂为其提供适配器的类(通常实现 IAdaptable)的标准名称
adapter:要适配成什么类(adapter可以有多个),此工厂可以适用于的 Java 类或接口的标准名称。
使用此接口,在运行时不需要使用 IAdapterFactory.registerAdapters 来注册使用此扩展点来注册的适配器工厂。
不再需要使用以下的注册代码:
Platform.getAdapterManager().register()进行注册。
Eclipse平台扩展点总结之org.eclipse.core.runtime.adapters扩展点的使用
最新推荐文章于 2021-01-27 20:38:37 发布
org.eclipse.core.runtime.adapters扩展点的使用