扩展点-org.eclipse.ui.IStartup

本文详细解析了Eclipse中IStartup扩展点的工作原理及应用技巧,包括其执行顺序、如何正确配置和使用,以及带来的优势。通过具体示例展示了如何利用此特性进行插件的早期启动。
此文对帮助文档中IStartup的内容做注解和补充,详情请见Eclipse帮助文档.

*执行顺序

---start()-->earlyStartup()

Plugin.startup(),Plugin.start(BundleContext context),IStartup.earlyStartup().

从3.0开始start()取代startup(),startup()被废弃

---Workbench.runUI(){display.readAndDispatch()->开始激活bundle,startPlugins()->加载org.eclipse.ui.IStartup}

 

*如何使用这个特性?

---帮助文档如是描述,"Plugins that provide an extension to this extension point are listed in the workbench preferences and the user may disable any plugin from early startup"

举例,

在earlyStartup()中对插件的操作if(Platform.getBundle("cn.com.agree.abop.ide.editor.fd").getState();==Bundle.STARTING){
    try {
        Platform.getBundle("cn.com.agree.abop.ide.editor.fd").uninstall();
    } catch (BundleException e) {
        e.printStackTrace();
    }
}

 

 

*注意class - a fully qualified name of the class that implements org.eclipse.ui.IStartup. If not specified, the plug-in class is used. Do not specify the plug-in class as an explicit value, or it will be instantiated twice (once by regular plug-in activation, and once by this mechanism).

若不看源码或尝试执行,这里的注释可能会导致歧义.以下根据实践说明,

---"If not specified, the plug-in class is used"?

其实就是扩展点不起作用,即使Plugin实现IStartup,Plugin也不会被执行.

---"Do not specify the plug-in class as an explicit value"?

若Plugin被定义在IStartup扩展点中,这将意味着产生两个Plugin类实例,所以不推荐.

 

*使用IStartup的好处

---"the method earlyStartup() will be called from a separate thread"

这个扩展点的意义在于在激活bundle之外,以一个高的优先级完成一些预操作.

转载于:https://www.cnblogs.com/bronte/articles/1814104.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值