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).
Before you begin
This article assumes that you are deploying (installing) J2EE modules on an application server provided by the WebSphere Application Server 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/.
Why and when to perform this task
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.Steps for this task
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)}); } }
Related tasks
Installing application files
Installing J2EE modules with JSR-88
Related information
J2EE Application Deployment Specification