简体   繁体   English

Osgi捆绑更新和ResourceBundle

[英]Osgi Bundle update and ResourceBundle

Lest's suppose we have two osgi bundles: bundleA and bundleB. 恐怕我们有两个osgi包:bundleA和bundleB。 In bundleB we have some texts.properties . 在bundleB中,我们有一些texts.properties So, in bundleA we do 因此,在bundleA中,我们这样做

ResourceBundle rb= 
        ResourceBundle.getBundle("com/foo/texts",locale, classFromBundleB.getClassLoader());

Now, we update bunldeB or totally remove it and install and start new version of bundleB that contains new version of texts.properties . 现在,我们更新bunldeB或将其完全删除,并安装并启动包含新版本texts.properties新版本。 And two questions : 还有两个问题:

  1. What happens to existing 'rb'? 现有的“ rb”会怎样? Must it work? 它必须工作吗?
  2. If after new version of bundleB came we do the same code as above - will we see in rb new version of texts.properties ? 如果在发布新版本的bundleB之后,我们执行与上述相同的代码-我们会在rb看到texts.properties新版本吗? Or we need to do additional actions for this? 还是我们需要为此采取其他措施?

Since bundleA has a reference to classFromBundleB, unless bundleA is refreshed, it will continue to maintain the classFromBundleB from the original bundleB. 由于bundleA对classFromBundleB的引用,除非刷新bundleA,否则它将继续从原始bundleB维护classFromBundleB。 And since ResourceBundle maintains a cache, you will keep getting the same rb. 而且由于ResourceBundle维护了一个缓存,您将获得相同的rb。 So after updating bundleB, you will need to refresh the bundles which depend upon the classes from bundleB. 因此,在更新bundleB之后,您将需要刷新依赖于bundleB中的类的bundle。

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

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