Java EE Application Deployment API Specification (JSR-88) の DConfigBean クラスを使用して、デプロイメント中に Java Platform, Enterprise Edition (Java EE) アプリケーション、またはスタンドアロン・モジュールを構成できます。
始める前に
非推奨の機能 (Deprecated feature): Java EE Application Deployment API 仕様 (JSR-88) を使用するアプリケーション・インストールは、
WebSphere® Application Server バージョン 8.0 では非推奨になっていました。別のオプションを使用して、アプリケーションをサーバーにデプロイしてください。Java EE Deployment API の使用に最も近いオプションは、Java Management Extensions (JMX) MBean プログラミングを使用するオプションです。デプロイメント・オプションについては、『エンタープライズ・アプリケーションまたはモジュールのインストール方法』を参照してください。
depfeat
このトピックでは、WebSphere Application Server JSR-88 用
サポートを使用して、製品が提供するアプリケーション・サーバー
上に Java EE モジュールをデプロイ (インストール) していることを前提とします。
JSR-88 仕様および DConfigBean クラスの使用については、http://www.oracle.com/technetwork/java/index.html を参照してください。
このタスクについて
JSR-88 の DConfigBean クラスは、デプロイメント中に、J2EE アプリケーションおよびモジュールのプラットフォーム固有の構成に対する JavaBean ベースのサポートを提供します。コードは DConfigBean インスタンスを検査して、プラットフォーム固有の構成属性を取得できます。WebSphere Application Server が提供する DConfigBean インスタンスには、java.util.Map オブジェクトの配列を持つ単一の属性が含まれます。
マップ項目には、コードによって値を取得および設定できる構成属性が含まれます。
手順
- JSR-88 を使用してアプリケーション・サーバー
に Java EE モジュールをインストールするコードを記述します。
- JSR-88 デプロイメント中に、製品によって生成される DConfigBeans にアクセスするコードを作成します。
ユーザー (またはデプロイヤー) は、
アクセスした DConfigBeans インスタンスをカスタマイズできます。
以下の疑似コードは、JSR-88 デプロイメント中に、製品によって生成された DConfigBean インスタンス属性を Java EE ツール・プロバイダーが取得し、その属性に値を設定する方法を示しています。
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)});
}
}