使用 DConfigBeans 定制模块

您可使用 Java EE Application Deployment API 规范 (JSR-88) 中的 DConfigBean 类,在部署期间配置 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 的 WebSphere Application Server 支持在产品提供的应用程序服务器上部署(安装)Java EE 模块。

请参阅 http://www.oracle.com/technetwork/java/index.html 上有关 JSR-88 规范和使用 DConfigBean 类的文章。

关于此任务

JSR-88 中的 DConfigBean 类提供部署期间对 J2EE 应用程序和模块的、特定于平台配置的、基于 JavaBeans 的支持。您的代码可检查 DConfigBean 实例,以获取特定于平台的配置属性。WebSphere Application Server 提供的 DConfigBean 实例包含单个属性,它具有 java.util.Map 对象数组。映射条目包含配置属性,您的代码可获取并设置其值。

过程

  1. 编写使用 JSR-88 在应用程序服务器上安装 Java EE 模块的代码。
  2. 编写代码,该代码在部署 JSR-88 期间,访问产品生成的 DConfigBean。然后,您(或部署者)可定制已访问的 DConfigBeans 实例。

    下列伪码显示 Java EE 工具提供程序可如何在 JSR-88 部署期间获取产品生成的 DConfigBean 实例属性,并为这些属性设置值。

    import javax.enterprise.deploy.model.*;
    import javax.enterprise.deploy.spi.*;
    {
    DeploymentConfiguration dConfig = ___; // Get from DeploymentManager
    DDBeanRoot ddRoot = ___;               // Provided by J2EE tool
    
    // Obtain root bean.
    DConfigBeanRoot dcRoot = dConfig.getDConfigBeanRoot(dr);
    
    // Configure DConfigBean.
    configureDCBean (dcRoot);
    }
    
    // Get children from DConfigBeanRoot and configure each child.
    method configureDCBean (DConfigBean dcBean)
    {
       // Get DConfigBean attributes for a given archive.
       BeanInfo bInfo = Introspector.getBeanInfo(dcBean.getClass());
       IndexedPropertyDescriptor ipDesc = 
          (IndexedPropertyDescriptor)bInfo.getPropertyDescriptors()[0];
    
       // Get the 0th map.
       int index = 0;
       Map map = (Map) 
          ipDesc.getIndexedReadMethod().invoke
             (dcBean, new Object[]{new Integer(index)});
    
       while (map != null)
       {
          // Iterate over the map and set values for attributes.
    
          // Set the map back into the DCBean.
          ipDesc.getIndexedWriteMethod().invoke
             (dcBean, new Object[]{new Integer(index), map}); 
    
          // Get the next entry in the indexed property
          map = (Map)
             ipDesc.getIndexedReadMethod().invoke
                (dcBean, new Object[]{new Integer(++index)});
       }
    }

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



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