スクリプトによる Web モジュールでのセッション管理用アプリケーションの構成

スクリプトと wsadmin ツールを使用して、Web モジュール内のセッション・マネージメント用のアプリケーションを構成します。

このタスクについて

AdminApp オブジェクトを使用して、アプリケーションの構成を設定できます。 ただし、AdminApp オブジェクトでは設定できない構成もいくつかあります。 以下のタスクでは、AdminConfig オブジェクトを使用して、アプリケーションで Web モジュールのセッション・マネージャーを構成します。

手順

  1. wsadmin スクリプト・ツールを開始します。
  2. アプリケーションのデプロイメント構成オブジェクトを識別して、 deployment 変数に割り当てます。 以下に例を示します。
    • Jacl を使用:
      set deployments [$AdminConfig getid /Deployment:myApp/]
    • Jython の使用:
      deployments = AdminConfig.getid('/Deployment:myApp/')
      print deployments
    各部の意味は、次のとおりです。
    表 1. デプロイメント構成の値です。. 以下の表で、getid コマンドのエレメントについて説明します。
    エレメント 定義
    set Jacl コマンドです。
    deployments 変数名です。
    $ 変数名を値で置換する Jacl 演算子です。
    AdminConfig WebSphere® Application Server の構成を表すオブジェクトです。
    getid AdminConfig コマンドです。
    デプロイメント 属性です。
    myApp 属性の値です。
    出力例:
    myApp(cells/mycell/applications/myApp.ear/deployments/myApp|deployment.xml#Deployment_1)
  3. アプリケーション内のすべてのモジュールを取得して、modules 変数に割り当てます。 以下に例を示します。
    • Jacl を使用:
      set appDeploy [$AdminConfig showAttribute $deployments deployedObject]
      set mod1 [$AdminConfig showAttribute $appDeploy modules]set mod1 [lindex $mod1 0]
      出力例:
      (cells/mycell/applications/myApp.ear/deployments/myApp:deployment.xml#WebModuleDeployment_1)
      (cells/mycell/applications/myApp.ear/deployments/myApp:deployment.xml#EJBModuleDeployment_1)
      (cells/mycell/applications/myApp.ear/deployments/myApp:deployment.xml#WebModuleDeployment_2)
    • Jython の使用:
      appDeploy = AdminConfig.showAttribute(deployments, 'deployedObject')
      mod1 = AdminConfig.showAttribute(appDeploy, 'modules')
      print mod1
      出力例:
      [(cells/mycell/applications/myApp.ear/deployments/myApp|deployment.xml#WebModuleDeployment_1) 
      (cells/mycell/applications/myApp.ear/deployments/myApp|deployment.xml#EJBModuleDeployment_1)
      (cells/mycell/applications/myApp.ear/deployments/myApp|deployment.xml#EJBModuleDeployment_2)]
    各部の意味は、次のとおりです。
    表 2. アプリケーション・モジュールの値です。. 以下の表で、showAttribute AdminConfig コマンドのエレメントについて説明します。
    エレメント 定義
    set Jacl コマンドです。
    appDeploy 変数名です。
    mod1 変数名です。
    $ 変数名を値で置換する Jacl 演算子です。
    AdminConfig WebSphere Application Server の構成を表すオブジェクトです。
    showAttribute AdminConfig コマンドです。
    deployments ステップ 1 で指定したデプロイメント・オブジェクトの ID を評価します。
    deployedObject 属性です。
  4. セッション・マネージャーに設定できる属性のリストを取得するには、 attributes コマンドを使用します。以下に例を示します。
    • Jacl を使用:
      $AdminConfig attributes SessionManager
    • Jython の使用:
      print AdminConfig.attributes('SessionManager')
    各部の意味は、次のとおりです。
    表 3. attributes AdminConfig コマンド. 以下の表で、attributes AdminConfig コマンドのエレメントについて説明します。
    エレメント 定義
    $ 変数名を値で置換する Jacl 演算子です。
    AdminConfig WebSphere Application Server の構成を表すオブジェクトです。
    attributes AdminConfig コマンドです。
    SessionManager 属性です。
    出力例:
    "accessSessionOnTimeout Boolean"
    "allowSerializedSessionAccess Boolean"
    "context ServiceContext@"
    "defaultCookieSettings Cookie"
    "enable Boolean"
    "enableCookies Boolean"
    "enableProtocolSwitchRewriting Boolean"
    "enableSSLTracking Boolean"
    "enableSecurityIntegration Boolean"
    "enableUrlRewriting Boolean"
    "maxWaitTime Integer"
    "properties Property(TypedProperty)*"
    "sessionDRSPersistence DRSSettings"
    "sessionDatabasePersistence SessionDatabasePersistence"
    "sessionPersistenceMode ENUM(DATABASE, DATA_REPLICATION, NONE)"
    "tuningParams TuningParams"
  5. セッション・マネージャーの属性をセットアップします。 次の例では、 セッション・マネージャーに 4 つのトップレベル属性を設定します。

    この例を変更して、セッション・マネージャーに他の属性を設定できます。 これには、Cookie、DRSSettings、SessionDataPersistence、および TuningParms オブジェクト・タイプのネストされた属性が含まれます。 それらのオブジェクト・タイプの属性をリストするには、 AdminConfig オブジェクトの attribute コマンドを使用します。

    トラブルの回避 (Avoid trouble) トラブルの回避 (Avoid trouble): アプリケーションを 初期化する前に defaultCookieSettings 属性および tuningParams 属性 の両方を設定することがセッション・マネージャーによって必要とされます。 これらの属性を設定しないと、セッション・マネージャーはアプリケーションを 初期化できず、アプリケーションは開始しません。gotcha
    • Jacl を使用:
      set attr0 [list enable true]
      set attr1 [list enableSecurityIntegration true]
      set attr2 [list maxWaitTime 30]
      set attr3 [list sessionPersistenceMode NONE]
      set attr4 [list enableCookies true]
      set attr5 [list invalidationTimeout 45]
      set tuningParmsDetailList [list $attr5]
      set tuningParamsList [list tuningParams $tuningParmsDetailList]
      set pwdList [list password 95ee608]
      set userList [list userId Administrator]
      set dsNameList [list datasourceJNDIName jdbc/session]
      set dbPersistenceList [list $dsNameList $userList $pwdList]
      set sessionDBPersistenceList [list $dbPersistenceList]
      set sessionDBPersistenceList [list sessionDatabasePersistence $dbPersistenceList]
      set kuki [list maximumAge 1000]
      set cookie [list $kuki]
      set cookieSettings [list defaultCookieSettings $cookie]
      set sessionManagerDetailList [list $attr0 $attr1 $attr2 $attr3 $attr4 $cookieSettings $tuningParamsList $sessionDBPersistenceList]
      set sessionMgr [list sessionManagement $sessionManagerDetailList]
      set id [$AdminConfig create ApplicationConfig $appDeploy [list $sessionMgr] configs]
      set targetMappings [lindex [$AdminConfig showAttribute $appDeploy targetMappings] 0]
      set attrs [list config $id]
      $AdminConfig modify $targetMappings [list $attrs]
      サポートされる構成 サポートされる構成: 上記のサンプルの最後の 5 行では、1 つのターゲット・サーバーのみに Web モジュールをデプロイしたことを想定しています。更新を各ターゲットに適用する場合は、ループを使用することによって、モジュールのターゲットを複数のサーバーまたはクラスターにすることができます。 更新を複数のターゲットに適用するには、上記のサンプルの最後の 6 行を次のコードで置き換えます。
      set id [$AdminConfig create ApplicationConfig $appDeploy [list $sessionMgr] configs]
      
      set targetMappings [lindex [$AdminConfig showAttribute $appDeploy targetMappings] 0]
      
      foreach target $targetMappings {
          if {[regexp DeploymentTargetMapping $target] == 1} {
              set attrs [list config $id]
              $AdminConfig modify $target [list $attrs]
          }
      }
      sptcfg
      Jacl を使用した出力例:
      sessionManagement {{enableSecurityIntegration true} {maxWaitTime 30} 
      {sessionPersistenceMode NONE} {enabled true}}
    • Jython の使用:
      attr0 = ['enable', 'true']
      attr1 = ['enableSecurityIntegration', 'true']
      attr2 = ['maxWaitTime', 30]
      attr3 = ['sessionPersistenceMode', 'NONE']
      attr4 = ['enableCookies', 'true']
      attr5 = ['invalidationTimeout', 45]
      tuningParmsDetailList = [attr5]
      tuningParamsList = ['tuningParams', tuningParmsDetailList]
      pwdList = ['password', '95ee608']
      userList = ['userId', 'Administrator']
      dsNameList = ['datasourceJNDIName', 'jdbc/session']
      dbPersistenceList = [dsNameList, userList, pwdList]
      sessionDBPersistenceList = [dbPersistenceList]
      sessionDBPersistenceList = ['sessionDatabasePersistence', dbPersistenceList]
      kuki = ['maximumAge', 1000]
      cookie = [kuki]
      cookieSettings = ['defaultCookieSettings', cookie]
      sessionManagerDetailList = [attr0, attr1, attr2, attr3, attr4, cookieSettings, tuningParamsList, sessionDBPersistenceList]
      sessionMgr = ['sessionManagement', sessionManagerDetailList]
      id = AdminConfig.create('ApplicationConfig', appDeploy,[sessionMgr], 'configs')
      targetMappings = AdminConfig.showAttribute(appDeploy, 'targetMappings')
      targetMappings = targetMappings[1:len(targetMappings)-1]
      print targetMappings
      attrs = ['config', id]
      AdminConfig.modify(targetMappings,[attrs])
      サポートされる構成 サポートされる構成: 上記のサンプルの最後の 6 行では、1 つのターゲット・サーバーのみに Web モジュールをデプロイしたことを想定しています。更新を各ターゲットに適用する場合は、ループを使用することによって、モジュールのターゲットを複数のサーバーまたはクラスターにすることができます。 更新を複数のターゲットに適用するには、上記のサンプルの最後の 6 行を次のコードで置き換えます。
      id = AdminConfig.create('ApplicationConfig', appDeploy,[sessionMgr], 'configs')
      
      targetMappings = AdminConfig.showAttribute(appDeploy, 'targetMappings')
      targetMappings = targetMappings[1:len(targetMappings)-1].split(" ")
      for target in targetMappings:
       if target.find('DeploymentTargetMapping') != -1:
        attrs = ['config', id]
        AdminConfig.modify(target,[attrs])
       #endif
      #endfor
      sptcfg
      Jython を使用した出力例:
      [sessionManagement, [[enableSecurityIntegration, true], [maxWaitTime, 30], [sessionPersistenceMode, NONE]]
  6. Web モジュールの属性をセットアップします。以下に例を示します。
    • Jacl を使用:
      set nameAttr [list name myWebModuleConfig]
      set descAttr [list description "Web Module config post create"]
      set webAttrs [list $nameAttr $descAttr $sessionMgr]
      出力例:
      {name myWebModuleConfig} {description {Web Module config post create}}
      {sessionManagement {{enableSecurityIntegration true} {maxWaitTime 30}
      {sessionPersistenceMode NONE} {enabled true}}}
    • Jython の使用:
      nameAttr = ['name', 'myWebModuleConfig']
      descAttr = ['description', "Web Module config post create"]
      webAttrs = [nameAttr, descAttr, sessionMgr]
      出力例:
      [[name, myWebModuleConfig], [description, "Web Module config post create"],
      [sessionManagement, [[enableSecurityIntegration, true], [maxWaitTime, 30],
      [sessionPersistenceMode, NONE], [enabled, true]]]]
    各部の意味は、次のとおりです。
    表 4. Web モジュールの属性の設定. 以下の表で、Web モジュールの属性設定のエレメントについて説明します。
    エレメント 定義
    set Jacl コマンドです。
    nameAttr、descAttr、webAttrs 変数名です。
    $ 変数名を値で置換する Jacl 演算子です。
    name 属性です。
    myWebModuleConfig name 属性の値です。
    description 属性です。
    Web Module config post create description 属性の値です。
  7. アプリケーション内の Web モジュールごとにセッション・マネージャーを作成します。次の例を変更して、Web モジュール構成内にセッション・マネージャーの他の属性を設定できます。このステップにはターゲット・マッピングも定義する必要があります。
    • Jacl を使用:
      foreach module $mod1 {
      	if {[regexp WebModuleDeployment $module] == 1} {
      				set moduleConfig [$AdminConfig create WebModuleConfig $module $webAttrs]
      				set targetMappings [lindex [$AdminConfig showAttribute $module targetMappings] 0]
      				set attrs [list config $moduleConfig]
      				$AdminConfig modify $targetMappings [list $attrs]
      	}
      }
      サポートされる構成 サポートされる構成: オプションのループをさらに追加して、新しい Web モジュール構成を各ターゲットに割り当てることができます。ただし、この Web モジュールは複数のターゲット・サーバーにデプロイされることが前提となっています。
      foreach module $mod1 {
          if {[regexp WebModuleDeployment $module] == 1} {
              		set moduleConfig [$AdminConfig create WebModuleConfig $module $webAttrs]
              		set targetMappings [lindex [$AdminConfig showAttribute $module targetMappings] 0]
              foreach target $targetMappings {
              if {[regexp DeploymentTargetMapping $target] == 1} {
                  		set attrs [list config $moduleConfig]
                  $AdminConfig modify $target [list $attrs]
              } 
          }
      }
      sptcfg
    • Jython の使用:
      arrayModules = mod1[1:len(mod1)-1].split(" ")
      for module in arrayModules:
      	if module.find('WebModuleDeployment') != -1:
      				AdminConfig.create('WebModuleConfig', module, webAttrs)
      		targetMappings = targetMappings[1:len(targetMappings)-1]
      				attrs = ['config', moduleConfig]
      				AdminConfig.modify (targetMappings, [attrs])
      サポートされる構成 サポートされる構成: オプションのループをさらに追加して、新しい Web モジュール構成を各ターゲットに割り当てることができます。ただし、この Web モジュールは複数のターゲット・サーバーにデプロイされることが前提となっています。
      arrayModules = mod1[1:len(mod1)-1].split(" ")
      for module in arrayModules:
        if module.find('WebModuleDeployment') != -1:
          moduleConfig = AdminConfig.create('WebModuleConfig', module, webAttrs)
          		attrs = ['config', moduleConfig]
          targetMappings = AdminConfig.showAttribute(appDeploy, 'targetMappings')
          targetMappings = targetMappings[1:len(targetMappings)-1].split(" ")
          for target in targetMappings:
              if target.find('DeploymentTargetMapping') != -1:
                  		attrs = ['config', moduleConfig]
                  AdminConfig.modify(target,[attrs])
      sptcfg
    出力例:
    myWebModuleConfig(cells/mycell/applications/myApp.ear/deployments/myApp|deployment.xml#WebModuleConfiguration_1)

    セッション・マネージャーを作成するときに tuningParamsList 属性を指定しないと、デプロイしたアプリケーションを始動する際にエラーを受け取ります。

  8. 構成の変更を保存します。
    以下のコマンド例を使用して、構成変更を保存します。
    AdminConfig.save()
  9. ノードを同期します (Network Deployment 環境の場合のみ)。
    AdminNodeManagement スクリプト・ライブラリーの syncActiveNode または syncNode スクリプトを使用して、 構成変更をノード (複数可) に伝搬します。
    • syncActiveNodes スクリプトを使用して、以下の例に示すように、変更をセルの各ノードに 伝搬します。
      AdminNodeManagement.syncActiveNodes()
    • syncNode スクリプトを使用して、以下の例に示すように、変更を特定のノードに 伝搬します。
      AdminNodeManagement.syncNode("myNode")

トピックのタイプを示すアイコン タスク・トピック



タイム・スタンプ・アイコン 最終更新: last_date
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=txml_webmodules
ファイル名:txml_webmodules.html