WebSphere Application Server for z/OS, Version 6.0.x   
             オペレーティング・システム: z/OS

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

プログラミングによるモジュールの準備および更新

既存のアプリケーションのモジュールの更新は、管理コンソール、 wsadmin ツール、またはプログラミングによって行うことができます。モジュールを更新すると、 既存のモジュールが新規バージョンで置き換えられます。この例を使用し、プログラミングによってモジュールを更新します。

始める前に

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

WebSphere Application Server 上でモジュールを更新する前に、 まずアプリケーションをインストールする必要があります。

このタスクについて

以下のタスクを実行し、プログラミングによってモジュールを更新します。

プロシージャー

  1. アプリケーション・デプロイメント・コントローラー・インスタンスを作成して、バインディング情報を Java アーカイブ・ファイルに取り込みます。
  2. モジュールにバインディング情報を保管します。
  3. インストール・オプションを取得します。
  4. 準備フェーズ (EAR ファイルへのデータ取り込み) が実行されない場合は、以下のアクションを実行します。
    1. updateApplication MBean API に渡されるオプション・テーブルを作成します。
    2. サーバー関係に対してモジュールのテーブルを作成し、そのテーブルをオプション・テーブルに追加します。
  5. WebSphere Application Server に接続します。
  6. アプリケーション管理プロキシーを作成します。
  7. 通知フィルターを作成します。
  8. リスナーを追加します。
  9. アプリケーション内のモジュールを置き換えます。
  10. 新規モジュールのターゲットを指定します。
  11. プログラムが終了しないように、タイムアウトまで待ちます。
  12. Java Management Extensions (JMX) 通知を listen し、オペレーションの完了を認識します。
  13. モジュールが追加されたら、リスナーを除去して終了します。

結果

コードが正常に実行されると、既存のモジュールが新規モジュールに置き換えられます。

以下の例には、前のステップに基づいた、アプリケーションへのモジュールの追加方法が示されています。 一部のステートメントは印刷目的のために複数行に分割されています。

//Inputs:
//moduleName specifies the name of the module that you add to the application.
//moduleURI specifies a URI that gives the target location of the module 
// archive contents on a file system. The URI provides the location of the new
// module after installation. この URI は、アプリケーションの URL について相対です。
//uniquemoduleURI specfies the URI that gives the target location of the
// deployment descriptor file. この URI は、アプリケーションの URL について相対です。
//target specifies the cell, node, and server on which the module is installed.
//appName specifies the name of the application to update.
String moduleName = "C:/apps/foo,jar";
String moduleURI = "Increment.jar";
String uniquemoduleURI = "Increment.jar+META-INF/ejb-jar.xml";
String target = "WebSphere:cell=cellname,node=nodename,server=servername";
String appName = "MyApp";

//Get the administrative client to connect to
//WebSphere Application Server.
AdminClient client = ...;
AppManagement proxy = AppManagementProxy. getJMXProxyForClient (client);

Vector tasks = proxy.getApplicationInfo (appName, new Hashtable(), null);

//Create an application deployment controller instance, AppDeploymentController,
//to populate the Java archive (JAR) file with binding information.  
//The binding information is WebSphere Application Server-specific deployment information.

Hashtable preferences = new Hashtable();
preferences.put (AppConstants.APPDEPL_LOCALE, Locale.getDefault());
preferences.put (AppConstants.APPUPDATE_CONTENTTYPE, AppConstants.APPUPDATE_CONTENT_MODULEFILE);
AppDeploymentController controller = AppManagementFactory.readArchiveForUpdate(
				moduleName,
				moduleURI, 
				AppConstants.APPUPDATE_UPDATE,
				preferences, 
				tasks);

アプリケーション用に更新するモジュールにバインディングがない場合は、 バインディングを追加することによって、モジュールの更新が機能します。WebSphere Application Server で提供されているパブリック API を使用して、バインディングを収集および追加します。WebSphere Application Server 固有のバインディング情報を収集してタスクに取り込む方法について詳しくは、AppDeploymentController インスタンスの Java 資料を参照してください。

//After you collect all the binding information, save it in the module.
controller.saveAndClose();

//Create the notification filter.
  NotificationFilterSupport myFilter = new NotificationFilterSupport();
  myFilter.enableType (NotificationConstants.TYPE_APPMANAGEMENT);
  //Add the listener.  NotificationListener listener = new AListener(_soapClient, myFilter,
"Install: " + appName, AppNotification.UPDATE);


//Get the installation options.
Hashtable options = controller. getAppDeploymentSavedResults();

//Update the existing application by adding the module.

options.put (AppConstants.APPUPDATE_CONTENTTYPE, 
			AppConstants. APPUPDATE_CONTENT_MODULEFILE);

//Specify the target for the new module
Hashtable mod2svr = new Hashtable();
options.put (AppConstants.APPDEPL_MODULE_TO_SERVER, mod2svr);
mod2svr.put (uniquemoduleURI, target);

proxy.updateApplication (	appName, 
				moduleURI, 
				moduleName,
				AppConstants.APPUPDATE_UPDATE,
				options,
				null);
// Wait; the installation application programming interface (API) is 
//  asynchronous and so returns immediately.
// If the program does not wait here, the program ends.
  Thread.sleep(300000); // Wait so that the program does not end.
        }
        catch (Exception e) {
            e.printStackTrace();
        }

    }

}
// Specify the Java Management Extensions (JMX) notification listener for JMX events.
class AListener implements NotificationListener
{
    AdminClient _soapClient;
    NotificationFilterSupport  myFilter;
    Object handback;
    ObjectName on;
    String eventTypeToCheck;

    public AListener(AdminClient cl, NotificationFilterSupport fl,
Object h, String eType) throws Exception
    {
        _soapClient = cl;
        myFilter = fl;
        handback = h;
        eventTypeToCheck = eType;

        Iterator iter = _soapClient.queryNames (new ObjectName(
"WebSphere:type=AppManagement,*"), null).iterator();
        on = (ObjectName)iter.next();
        System.out.println ("ObjectName: " + on);
        _soapClient.addNotificationListener (on, this, myFilter, handback);
    }

    public void handleNotification (Notification notf, Object handback)
    {
            AppNotification ev = (AppNotification) notf.getUserData();
            System.out.println ("!! JMX event Recd: (handback obj= " + handback+ "): " + ev);


            //When the installation is done, remove the listener and quit

            if (ev.taskName.equals (eventTypeToCheck) &&
                (ev.taskStatus.equals (AppNotification.STATUS_COMPLETED) ||
                 ev.taskStatus.equals (AppNotification.STATUS_FAILED)))
            {
                    try
                    {
                            _soapClient.removeNotificationListener (on, this);
                    }
            catch (Throwable th)
                    {
                        System.out.println ("Error removing listener: " + th);
                    }
                    System.exit (0);
        }
    }
}



関連タスク
プログラミングによるアプリケーションのインストール
プログラミングによるアプリケーションのアンインストール
プログラミングによるアプリケーションの更新
プログラミングによるアプリケーションの部分的な追加、更新、または削除
モジュールの準備とプログラミングによる既存アプリケーションへの追加
プログラミングによるモジュールの削除
プログラミングによるファイルの追加
プログラミングによるファイルの更新
プログラミングによるファイルの削除
タスク・トピック    

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

最終更新: Jan 21, 2008 10:52:11 PM EST
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r0/index.jsp?topic=/com.ibm.websphere.zseries.doc/info/zseries/ae/tjmx_update_module.html