简体   繁体   English

OSGi捆绑包更新后如何做重新布线框架

[英]How to do the Rewiring Framework after OSGi bundle update

I have a equinox based application. 我有一个基于春分的应用程序。 I need to update a bundle and rewire the OSGi bundles corresponding to the updated bundle. 我需要更新捆绑软件并重新连接与更新的捆绑软件对应的OSGi捆绑软件。

I updated the bundle using, 我使用

bundle.update(new FileInputStream(new File(filePath)));

I need to refresh the affected bundles in order the update to be affected. 我需要刷新受影响的捆绑软件才能使更新受到影响。

How can I do this?... 我怎样才能做到这一点?...

BundleContext bcx = bundle.getBundleContext();
Bundle systemBundle = bcx.getBundle(0);

bundle.update(new FileInputStream(new File(filePath)));

FrameworkWiring frameworkWiring = systemBundle.adapt(FrameworkWiring.class);
frameworkWiring.refreshBundles(null);

Please note that refreshBundles is an asynchron function call. 请注意,refreshBundles是一个异步函数调用。 Therefore if you want to catch the event when the bundles are refreshed, you must pass a FrameworkListener as the second parameter. 因此,如果要在刷新分发包时捕获事件,则必须传递FrameworkListener作为第二个参数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM