WebSphere Application Server, Version 6.1   
             オペレーティング・システム: AIX , HP-UX, Linux, Solaris, Windows, Windows Vista

             目次と検索結果のパーソナライズ化

デプロイ済みアプリケーションの追加属性の操作

デプロイ済みアプリケーションの属性の操作は、 管理コンソール、wsadmin ツール、またはプログラミングによって行うことができます。 この例を使用し、AppDeploymentTask オブジェクトによって、 アプリケーションのインストール時もインストール後にも公開されない属性を操作します。

始める前に

このタスクでは、MBean プログラミングおよび ConfigService インターフェースに関する基本的な知識があることを前提としています。MBean プログラミングについては、MBean Java アプリケーション・プログラミング・インターフェース (API) 資料を参照してください。 ConfigService インターフェースについては、Java アプリケーション・ プログラミング・インターフェース (API) 資料を参照してください。

WebSphere Application Server 上のデプロイ済みアプリケーションの追加属性を操作する前に、 まずアプリケーションをインストールする必要があります。

このタスクについて

デプロイ済みアプリケーションで以下のタスクを実行し、AppDeploymentTask オブジェクトによって 公開されない属性を操作します。この属性は、 デプロイ済みアプリケーションごとに構成リポジトリーで作成される deployment.xml ファイルに保管されています。

プロシージャー

  1. セッションを作成します。
  2. WebSphere Application Server に接続します。
  3. ApplicationDeployment オブジェクトを探します。
  4. 属性を操作します。
  5. 変更を保管します。
  6. セッションをクリーンアップします。

結果

コードが正常に実行されると、デプロイ済みアプリケーション用の deployment.xml ファイルで属性が更新されます。

以下の例には、前のステップに基づいた、startingWeight、warClassLoaderPolicy、 およびクラス・ローダー属性の操作方法が示されています。

import java.util.Properties;

import javax.management.Attribute;
import javax.management.AttributeList;
import javax.management.ObjectName;

import com.ibm.websphere.management.AdminClient;
import com.ibm.websphere.management.AdminClientFactory;
import com.ibm.websphere.management.Session;
import com.ibm.websphere.management.configservice.ConfigService;
import com.ibm.websphere.management.configservice.ConfigServiceHelper;
import com.ibm.websphere.management.configservice.ConfigServiceProxy;
import com.ibm.websphere.management.exception.ConfigServiceException;
import com.ibm.websphere.management.exception.ConnectorException;

public class AppManagementSample1 {

	public static void main(String[] args) {
		String hostName = "localhost";
String port = "8880";
		String appName = "ivtApp";

		ConfigService configService = null;

		// create a session.
Session session = new Session();

		// establish connection to the server.
		try {
Properties props = new Properties();
			props.setProperty(AdminClient.CONNECTOR_TYPE,
					AdminClient.CONNECTOR_TYPE_SOAP);
			props.setProperty(AdminClient.CONNECTOR_HOST, hostName);
			props.setProperty(AdminClient.CONNECTOR_PORT, port);
			AdminClient adminClient =
				AdminClientFactory.createAdminClient(props);

			// create a config service proxy object.
			configService = new ConfigServiceProxy(adminClient);

			// Locate the application object.
			ObjectName rootID = configService.resolve(session,
					"Deployment="+appName)[0];
			System.out.println ("rootID is: " + rootID);

			// Locate the ApplicationDeployment object from the root.
			ObjectName appDeplPattern = ConfigServiceHelper.createObjectName
						(null, "ApplicationDeployment");
			/*
			ObjectName appDeplID = configService.queryConfigObjects(session,
					rootID, appDeplPattern, null)[0];
			*/
			AttributeList list1 = configService.getAttributes(session,
					rootID, new String[]{"deployedObject"}, false);
			ObjectName appDeplID = (ObjectName)
				ConfigServiceHelper.getAttributeValue(list1, "deployedObject");
			System.out.println ("appDeplID: " + appDeplID);
			
			// Locate the class loader.
			
			// Change the starting weight through the startingWeight attribute.The starting weight
       // affects the order in which applications start.
			AttributeList attrList = new AttributeList();
			Integer newWeight = new Integer (10);
			attrList.add(new Attribute("startingWeight", newWeight));

			// Change the WAR class loader policy through the warClassLoaderPolicy attribute by
       // specifying SINGLE or MULTIPLE.
			// SINGLE=one classloader for all WAR modules
			attrList.add(new Attribute("warClassLoaderPolicy", "SINGLE"));

			// Set the class loader mode to PARENT_FIRST or PARENT_LAST.
			AttributeList clList = (AttributeList) configService.getAttribute
				(session, appDeplID, "classloader");
			ConfigServiceHelper.setAttributeValue (clList, "mode",
				"PARENT_LAST");
			attrList.add (new Attribute ("classloader", clList));

			// Set the new values.
			configService.setAttributes(session,  appDeplID, attrList);

			// Save your changes.
configService.save(session, false);

} catch (Exception ex) {
			ex.printStackTrace();
} finally {
            // Clean up the session.
			try {
				configService.discard(session);
			}
			catch (ConfigServiceException csEx)
			{
				csEx.printStackTrace();
			}
			catch (ConnectorException cnEx)
			{
				cnEx.printStackTrace();
			}
		}		
	}
}



関連概念
アプリケーション管理
関連タスク
プログラミングによるアプリケーションのインストール
タスク・トピック    

ご利用条件 | フィードバック

最終更新: Jan 21, 2008 5:05:53 PM EST
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.base.doc/info/aes/ae/tjmx_config_appdeploy.html