2011-07-19 36 views
5

我是新近在春天DM,我想訪問Bundlecontext。我的問題是我有一個與Activator綁定,但它沒有xml配置文件。我無法觸及這個包,然後我需要訪問BundleContext和serviceReference來獲取我的包中的服務。我正在使用Spring DM。那麼,我怎麼能得到BundleContext?如何在Spring DM中獲取BundleContext?

謝謝!

問候!

回答

8

的方法之一是實現​​和另外一個,如果你不希望依靠DM及其機制:

BundleContext bundleContext = FrameworkUtil.getBundle(this.getClass()).getBundleContext(); 
0

Spring DM documentation說你應該實現​​接口來獲取你的bundle上下文。但是,它也正確地解釋了你幾乎不應該使用它,如果你需要訪問某些服務,使用Spring DM注入機制可能會更好。

相關問題