使用 JSR-88 安装企业模块

可以使用 Java EE Application Deployment API 规范 (JSR-88) 在 WebSphere® Application Server 产品提供的应用程序服务器上安装 Java™ Platform, Enterprise Edition (Java EE) 模块。

开始之前

不推荐使用的功能部件 不推荐使用的功能部件: 不推荐在 WebSphere Application Server V8.0 中使用 Java EE 应用程序部署 API 规范 (JSR-88) 安装应用程序。使用另一个选项将应用程序部署到服务器。使用 Java EE 部署 API 的最接近选项是使用 Java 管理扩展 (JMX) MBean 编程。有关部署选项的信息,请参阅“安装企业应用程序或模块的方法”。depfeat

JSR-88 定义标准应用程序编程接口 (API),以允许 Java EE 应用程序和独立模块部署到 Java EE 产品平台。Java EE Application Deployment 规范版本 1.1 在 http://www.oracle.com/technetwork/java/index.html 中作为 Java 2 Platform, Enterprise Edition (J2EE) 1.4 Application Server Developer Release 的一部分提供。

关于此任务

JSR-88 在工具提供者和平台之间定义一个合同,使来自多个供应商的工具能配置、部署和管理任何 Java EE 产品平台上的应用程序。工具提供者通常提供软件工具和集成开发环境 (IDE),用于开发和组装 Java EE 应用程序模块。Java EE 平台提供部署、取消部署、启动、停止及其他管理 Java EE 应用程序的应用程序管理功能。

WebSphere Application Server 是符合 Java EE 规范的平台,它实现 JSR-88 API。完成以下步骤以便在 WebSphere Application Server 平台提供的应用程序服务器上部署(安装)Java EE 模块。

过程

  1. 对可以访问该产品的 JSR-88 DeploymentManager 类的 Java 程序进行编码。
    1. 编写查找 JAR 清单属性 J2EE-DeploymentFactory-Implementation-Class 的代码。

      在 JSR-88 下,您的代码使用 JAR 清单属性 J2EE-DeploymentFactory-Implementation-Class 来查找 DeploymentFactory。以下产品应用程序管理 JAR 文件包含此属性并提供支持。

      表 1. 包含清单属性的 JAR 文件. 使代码能够使用 JAR 清单属性来查找 DeploymentFactory。
      环境 包含清单属性的 JAR 文件
      应用程序服务器 app_server_root/plugins/com.ibm.ws.admin.services.jar
      应用程序客户机 app_client_root/plugins/com.ibm.ws.j2ee.client.jar
      瘦应用程序客户机 app_client_root/runtimes/com.ibm.ws.admin.client_9.0.jar

      在您的代码找到 DeploymentFactory 后,部署工具可以创建 WebSphere DeploymentFactory 的实例,并向其 DeploymentFactoryManager 注册该实例。

      应用程序服务器环境的示例代码如下。该示例代码要求您使用产品附带的开发包或使用可插拔客户机来部署独立模块。有关受支持开发包的信息,请参阅《WebSphere Application Server 详细系统需求》(http://www.ibm.com/support/docview.wss?rs=180&uid=swg27006921)。

      import javax.enterprise.deploy.shared.factories.DeploymentFactoryManager;
      import javax.enterprise.deploy.spi.DeploymentManager;
      import javax.enterprise.deploy.spi.factories.DeploymentFactory;
      import java.util.jar.JarFile;
      import java.util.jar.Manifest;
      
      // Get the DeploymentFactory implementation class from the MANIFEST.MF file.
      File jsr88Jar = new File(wasHome + "/plugins/com.ibm.ws.admin.services.jar");
      JarFile jarFile = new JarFile(jsr88Jar);
      Manifest manifest = jarFile.getManifest();
      Attributes attributes = manifest.getMainAttributes();
      String key = "J2EE-DeploymentFactory-Implementation-Class";
      String className = attributes.getValue(key);
      // Get an instance of the DeploymentFactoryManager
      DeploymentFactoryManager dfm = DeploymentFactoryManager.getInstance();
      
      // Create an instance of the WebSphere Application Server DeploymentFactory.
      Class deploymentFactory = Class.forName(className);
      DeploymentFactory deploymentFactoryInstance =
         (DeploymentFactory) deploymentFactory.newInstance();
      
      // Register the DeploymentFactory instance with the DeploymentFactoryManager.
      dfm.registerDeploymentFactory(deploymentFactoryInstance);
      
      // Provide WebSphere Application Server URI, user ID, and password.
      // For more information, see the step that follows.
      wsDM = dfm.getDeploymentManager(
         "deployer:WebSphere:myserver:8880", null, null);
    2. 编写访问该产品的 DeploymentManager 实例的代码。

      用于部署的产品 URI 具有下列格式:

      "deployer:WebSphere:host:port"

      前一步中的示例 "deployer:WebSphere:myserver:8880" 尝试使用 SOAP 连接器连接到主机 myserver 端口 8880,这是缺省值。

      可以对用于部署的 URI 中的 host 元素指定因特网协议 V6 (IPv6) 地址。将 IPv6 地址括在方括号 ([]) 中;例如:

      "deployer:WebSphere:[IPv6_address]:port"

      此外,您也可以将可选参数 connectorType 添加到用于部署的 URI。例如,要使用 RMI 连接器访问 myserver,按如下所示对 URI 进行编码:

      "deployer:WebSphere:myserver:2809?connectorType=RMI"
  2. 可选: 对可以使用 JSR-88 支持定制或部署 Java EE 应用程序或模块(此支持由该产品提供)的 Java 程序进行编码。
  3. 使用用于启动应用程序或模块的 JSR-88 API 启动部署的 Java EE 应用程序或独立 Java EE 模块。

下一步做什么

测试已部署应用程序或模块。例如,将 Web 浏览器指向已部署应用程序的 URL,并检查应用程序的性能。如果需要,更新应用程序。


指示主题类型的图标 任务主题



时间戳记图标 最近一次更新时间: last_date
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=trun_app_jsr88
文件名:trun_app_jsr88.html