简体   繁体   English

Java Web Start ExtensionInstallerService-如何掌握应用程序中的安装路径?

[英]Java Web Start ExtensionInstallerService - How to get hold of the install path in the application?

Java Web Start features a ExtensionInstallerService that is invoked when the application is installed (and uninstalled). Java Web Start具有ExtensionInstallerService ,在安装(和卸载)应用程序时将调用它。 It allows to install "extensions" in a local directory which is provided by the getInstallPath() API which reads like this: 它允许在由getInstallPath() API提供的本地目录中安装“扩展”,其内容如下:

java.lang.String getInstallPath()

Returns the directory where the installer is recommended to install the extension in. It is not required that the installer install in this directory, this is merely a suggested path. 返回建议安装程序在其中安装扩展的目录。不需要安装程序在此目录中安装,这只是建议的路径。

I'd now like to know how to get hold of the provided install path in the running Web Start application (what's defined in application-desc JNLP element). 我现在想知道如何掌握正在运行的Web Start应用程序(在application-desc JNLP元素中定义的内容)中提供的安装路径。

I've already checked the system properties of the JVM the application is running in. Lot's of deployment.* properties there, but not the install path used by the extension installer. 我已经检查了应用程序正在运行的JVM的系统属性deployment.*那里有很多deployment.*属性,但没有扩展安装程序使用的安装路径。 The ExtensionInstallerService itself is unavailable in the running application - so not possible to call getInstallPath() there. ExtensionInstallerService本身在正在运行的应用程序中不可用-因此无法在此处调用getInstallPath()

Use ServiceManager.lookup("javax.jnlp.ExtensionInstallerService") to get access to an instance of the service, then use its methods as needed. 使用ServiceManager.lookup("javax.jnlp.ExtensionInstallerService")可以访问服务实例,然后根据需要使用其方法。

Asks the JNLP Client for a service with a given name. 向JNLP客户端请求具有给定名称的服务。 The lookup must be idempotent, that is return the same object for each invocation with the same name. 查找必须是幂等的,即对于具有相同名称的每次调用都返回相同的对象。

Parameters: 参数:

name - Name of service to lookup. name -服务的名称来查找。

Returns: 返回:

An object implementing the service. 实现服务的对象。 null will never be returned. null将永远不会返回。 Instead an exception will be thrown. 而是将引发异常。

Throws: 抛出:

UnavailableServiceException - if the service is not available, or if name is null . UnavailableServiceException如果服务不可用,或者name为null

Edit 编辑

I have no problem to lookup ExtensionInstallerService in the extension installer class (JNLP element installer-desc ), but this service is unavailable in the running application (JNLP element application-desc ). 我在扩展安装程序类(JNLP element installer-desc )中查找ExtensionInstallerService没问题,但是此服务在正在运行的应用程序(JNLP element application-desc )中不可用。

Huh, had not realised. ,没有意识到。 In any case, while in the extension installer code, offer the user the place to install the extension, then store that path using the PersistenceService . 无论如何,在扩展程序安装程序代码中,向用户提供安装扩展程序的位置,然后使用PersistenceService存储该路径。

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

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