简体   繁体   中英

Osgi Bundle update and ResourceBundle

Lest's suppose we have two osgi bundles: bundleA and bundleB. In bundleB we have some texts.properties . So, in bundleA we do

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 . And two questions :

  1. What happens to existing '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 ? 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. And since ResourceBundle maintains a cache, you will keep getting the same rb. So after updating bundleB, you will need to refresh the bundles which depend upon the classes from bundleB.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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