Eclipse插件編輯器的Overview頁面中,有一個(gè)復(fù)選框叫“This plugin-in is a singleton”叹话,中文下叫“此插件為singleton”偷遗,很多人不明白這個(gè)復(fù)選框選中和不選中有什么區(qū)別,是否會(huì)影響到運(yùn)行時(shí)對插件類的訪問?
其實(shí)這個(gè)是OSGi的一個(gè)配置驼壶,這個(gè)配置表示確保只會(huì)有一個(gè)版本的插件(bundle)會(huì)被加載氏豌。當(dāng)存在多個(gè)版本的插件時(shí),Eclipse或RCP程序只會(huì)加載其中一個(gè)(通常是較新版本)热凹,插件運(yùn)行方式不受任何影響泵喘。
OSGi規(guī)范上關(guān)于“Bundle-SymbolicName”上的說明如下:
singleton - Indicates that the bundle can only have a single version resolved in an environment. A value of true indicates that the bundle is a singleton bundle. The default value is false. The Framework must resolve at most one bundle when multiple versions of a singleton bundle with the same symbolic name are installed.
更多詳細(xì)信息可以參考StackOverflow上的回答: Eclipse Plugin Singleton setting