Dynamically load additional jar files using Web St

2019-04-08 10:04发布

The Web Start Developers Guide states

All application resources must be retrieved from the JAR files specified in the resources section of the JNLP file, or retrieved explicitly using an HTTP request to the Web server.

Storing resources in JAR files is recommended, since they will be cached on the local machine by Java Web Start.

Now, I have some resources I want to dynamically load after my application has been started (for example OSGi bundles). I can do this using plain HTTP, but I would like to make use of Web Start's support for local caching and versioned/architecture-specific resources.

Is there a way to download additional jar files from the original code base (as specified in the application's jnlp file) using the Web Start infrastructure?

Or alternatively: is there already an established way to integrate OSGi and Web Start that would relieve me of the task to install bundles from the Web Start server?

2条回答
倾城 Initia
2楼-- · 2019-04-08 10:46

If you make your application in itself an Equinox-based OSGI application, you can web-start it with all the addition bundles you need.

This article "WebStarting Equinox OSGi Apps" can give you a good introduction on the required settings.

  • All bundles have to be deployed as signed JAR files
  • You need a feature that contains all the necessary bundles
  • When exporting the feature, make sure that PDE creates a JNLP (Java Network Lauching Protocol) file (a checkbox in the export wizard) for this feature
  • Provide a root JNLP file for you application
  • Deploy your application to a web server and make sure that the web server is aware of the application/x-java-jnlp-file mime type

He also has an OSGI demo.

查看更多
戒情不戒烟
3楼-- · 2019-04-08 11:04

I haven't tried it but look at the javax.jnlp.DownloadService API

查看更多
登录 后发表回答