简体   繁体   English

使用 Web Start / JNLP 动态加载额外的 jar 文件

[英]Dynamically load additional jar files using Web Start / JNLP

The Web Start Developers Guide states Web Start Developers Guide状态

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.所有应用程序资源必须从 JNLP 文件的资源部分中指定的 JAR 文件中检索,或者使用对 Web 服务器的 HTTP 请求显式检索。

Storing resources in JAR files is recommended, since they will be cached on the local machine by Java Web Start.建议将资源存储在 JAR 文件中,因为它们会被缓存在本地机器上,由 Java Web 启动。

Now, I have some resources I want to dynamically load after my application has been started (for example OSGi bundles).现在,我想要在我的应用程序启动后动态加载一些资源(例如 OSGi 包)。 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.我可以使用普通的 HTTP 来做到这一点,但我想利用 Web Start 对本地缓存和版本化/架构特定资源的支持。

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?有没有办法使用 Web Start 基础设施从原始代码库(在应用程序的 jnlp 文件中指定)下载额外的 jar 文件?

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?或者:是否已经有一种整合 OSGi 和 Web Start 的既定方法可以减轻我从 Web Start 服务器安装捆绑包的任务?

If you make your application in itself an Equinox-based OSGI application, you can web-start it with all the addition bundles you need.如果您使您的应用程序本身成为基于 Equinox 的 OSGI 应用程序,您可以使用所需的所有附加包启动它。

This article " WebStarting Equinox OSGi Apps " can give you a good introduction on the required settings.这篇文章“ WebStarting Equinox OSGi Apps ”可以很好地介绍所需的设置。

  • All bundles have to be deployed as signed JAR files所有捆绑包都必须部署为签名的 JAR 文件
  • 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导出功能时,确保 PDE 为该功能创建 JNLP(Java 网络启动协议)文件(导出向导中的复选框)
  • Provide a root JNLP file for you application为您的应用程序提供根 JNLP 文件
  • 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将您的应用程序部署到 web 服务器并确保 web 服务器知道 application/x-java-jnlp-file mime 类型

He also has an OSGI demo .他还有一个OSGI 演示

I haven't tried it but look at the javax.jnlp.DownloadService API我没试过,但看看javax.jnlp.DownloadService API

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

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