Using OSGi to implement auto-update

戏子无情 提交于 2019-12-18 15:10:34

问题


What I'd like to do is create a "launcher" framework for my code that, given a URL and a predefined versioning scheme: 1) go check if an update exists 2) download the updates 3) "install" the update 4) "re-run" the application

I want to a) do all of this inside of the existing JVM and b) be platform independent. Tall order right? Based on my (limited) knowledge of OSGi and Apache Felix I'm pretty sure this is possible, but I'm really getting lost in the details.

Checking for an update and downloading it is trivial. Causing the "old" bundle to unload and the "new" bundle to load is where I'm getting stuck. I've done OSGi work in the past but it was a lot less dynamic than this. A good starting place or a hard shove in the right direction would be most appreciated.

If I'm seriously over-baking something that's already been solved with a free library then tell me this too, but I haven't found anything so far. :-)


回答1:


You don't even need to download it, just check if an update is available and then call Bundle.update(InputStream) on the bundle that needs to be updated, generally followed by a call to PackageAdmin.refreshPackages() afterward.




回答2:


you can check well-known provisioning solutions that can do all your steps instead of you (check for a new version, download, install/update, restart etc.)

  1. For Equinox framework: p2 http://www.eclipse.org/equinox/p2/
  2. For any OSGi R4 framework: Apache ACE http://incubator.apache.org/ace/a-brief-introduction.html

best regards, Dmytro



来源:https://stackoverflow.com/questions/7097169/using-osgi-to-implement-auto-update

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!