+

Search Tips   |   Advanced Search

Customizing modules using DConfigBeans


Configure Java EE applications or standalone modules during deployment using the DConfigBean class in the Java EE Application Deployment API spec (JSR-88).

This page assumes that we are deploying (installing) Java EE modules on an appserver provided by WAS using the WAS support for JSR-88.

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

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

 

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

  2. Write code that accesses DConfigBeans generated by WAS ND during JSR-88 deployment. You (or a deployer) can then customize the accessed DConfigBeans instances.

    The following pseudocode shows how a Java EE tool provider can get DConfigBean instance attributes generated by the product 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);
    
    
    // Set 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)});
    
    
    

    }

 

Related tasks


Install enterprise application files
Install enterprise modules with JSR-88

 

Related information


Java EE Application Deployment specification