+

Search Tips   |   Advanced Search

 

Customizing modules using DConfigBeans

 

You can configure J2EE applications or standalone modules during deployment using the DConfigBean class in the Java 2 Platform, Enterprise Edition (J2EE) Deployment API Specification (JSR-88). This topic assumes that you are deploying (installing) J2EE modules on an appserver provided by the WAS platform using the WebSphere Application Server support for JSR-88.

Read about the JSR-88 specification and using the DConfigBean class at http://java.sun.com/j2ee/tools/deployment/.

 

Overview

The DConfigBean class in JSR-88 provides JavaBeans-based support for platform-specific configuration of J2EE applications and modules during deployment. Your code can inspect DConfigBean instances to get platform-specific configuration attributes. The DConfigBean instances provided by WebSphere Application Server contain a single attribute which has an array of java.util.Hashtable objects. The hashtable entries contain configuration attributes, for which your code can get and set values.

 

Procedure

  1. Write code that installs J2EE modules on an appserver using JSR-88.

  2. Write code that accesses DConfigBeans generated by WebSphere Application Server during JSR-88 deployment. You (or a deployer) can then customize the accessed DConfigBeans instances. The following pseudocode shows how a J2EE tool provider can get DConfigBean instance attributes generated by WAS during JSR-88 deployment and set values for the attributes:

    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 table.
       int index = 0;
       Hashtable tbl = (Hashtable) 
          ipDesc.getIndexedReadMethod().invoke
             (dcBean, new Object[]{new Integer(index)});
    
       while (tbl != null)
       {
          // Iterate over the hashtable and set values for attributes.
    
          // Set the table back into the DCBean.
          ipDesc.getIndexedWriteMethod().invoke
             (dcBean, new Object[]{new Integer(index), tbl}); 
    
          // Get the next entry in the indexed property
          tbl = (Hashtable)
             ipDesc.getIndexedReadMethod().invoke
                (dcBean, new Object[]{new Integer(++index)});   }
    }
    
    



Installing J2EE application files
Installing J2EE modules with JSR-88

 

Related information


J2EE Application Deployment Specification