Java 2 Platform, Enterprise
Edition (J2EE) Deployment API Specification (JSR-88) の DConfigBean クラスを使用して、
デプロイメント中に J2EE アプリケーションまたはスタンドアロン・モジュールを構成できます。
このタスクについて
JSR-88 の DConfigBean クラスは、デプロイメント中に、J2EE アプリケーションおよびモジュールのプラットフォーム固有の構成に対する JavaBean ベースのサポートを提供します。コードは DConfigBean インスタンスを検査して、プラットフォーム固有の構成属性を取得できます。WebSphere Application Server が提供する DConfigBean インスタンスには、java.util.Hashtable オブジェクトの配列を持つ単一の属性が含まれます。ハッシュ・テーブル項目には、コードが値を取得および設定できる構成属性が含まれます。
プロシージャー
- JSR-88 を使用してアプリケーション・サーバー
に J2EE モジュールをインストールするコードを記述します。
- JSR-88 デプロイメント中に WebSphere Application Server によって生成される DConfigBeans にアクセスするコードを記述します。ユーザー (またはデプロイヤー) は、
アクセスした DConfigBeans インスタンスをカスタマイズできます。 以下の疑似コードは
、J2EE ツール・プロバイダーが、JSR-88 デプロイメント中に WebSphere Application Server によって
生成された 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 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)});
}
}