You can configure Java Platform, Enterprise Edition (Java
EE) applications or standalone modules during deployment using the
DConfigBean class in the Java EE Application Deployment API specification
(JSR-88).
About 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.Map objects. The map entries
contain configuration attributes, for which your code can get and
set values.
Procedure
- Write code that installs
Java EE modules on an application server using JSR-88.
- Write code that accesses DConfigBeans generated by the
product 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);
// 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)});
}
}