Eclipse自動外掛程式依賴的一種配置解決方式

來源:互聯網
上載者:User

  Eclipse的外掛程式具有以下特點:

(1)每一個外掛程式有自己獨立的classloader

(2)外掛程式資源的互動通過MENIFEST.MF中"Export-Package, Require-Bundle, Import-Package"等屬性控制

(3)外掛程式不能相互依賴

  最近開發的系統需要進行許可權控制,控制粒度到視圖的定義、命令的定義等等。當系統啟動的時候,需要根據配置(資料庫儲存)載入目前使用者可用的配置,這樣問題就來了:

    Eclipse的外掛程式是需要依賴的,才能引用。例如B依賴A,則B可以引用A,但A不依賴B,A不能調用B的資源。這意味著,如果A作為許可權檢測並載入外掛程式配置的類,是不能引用B的類的。一種解決方案,就是A加入對B的依賴。但是當系統變大,不可能是一個開發組開發時,A怎麼會知道到底有些什麼外掛程式呢。顯然它不可能Crowdsourced Security Testing先覺。因此存在問題。

  幸好,Eclipse提供了對MENIFEST檔案的擴充,擴充了Eclipse-BuddyPolicy指令。

網址:http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fmisc%2Fbundle_manifest.html  給出了此指令的介紹

The Eclipse-BuddyPolicy header is used to specify the buddy classloading policies for a bundle.The Eclipse-BuddyPolicy header must use the following syntax:

Eclipse-BuddyPolicy ::= ( policy-name ) ( ',' policy-name ) *policy-name ::= ( 'dependent' | 'global' | 'registered' |                   'app' | 'ext' | 'boot' | 'parent' )
registered - indicates that the buddy mechanism will consult bundlesthat have been registered to it. Bundle willing to be registered to a particular bundle add in their manifest: "Eclipse-RegisterBuddy: <bundleSymbolicName>"; dependent - indicates that the classes/resources will be looked uptransitively in all the dependent of the bundle; global - indicates that the classes/resources will be looked up in theglobal pool of exported package; app - indicates that the application classloader will be consulted; ext - indicates that the extensiont classloader will be consulted; boot - indicates that the boot classloader will be consulted.   於是根據上述描述,在A外掛程式MENIFEST檔案中插入
Eclipse-BuddyPolicy: global
  指令,然後B引用A,A不需要引用B,但是在A中需要調用的B的資源,需要在B中Export出來。這樣,就可以在A中使用B的資源了。

  通過這種方式,實現了根據使用者角色,過濾介面的功能,很好地實現了介面部分許可權的控制。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.