スクリプトを使用したモジュール・レベルでのステートフル・セッション Bean のフェイルオーバーの構成
スクリプトと wsadmin ツールを使用して、 ステートフル・セッション Bean のフェイルオーバー用に アプリケーションを構成します。
始める前に
このタスクについて
手順
- AdminConfig オブジェクトを使用して、
アプリケーションの単一の EJB モジュールに対する
ステートフル・セッション Bean フェイルオーバー構成を
表示します。
- wsadmin スクリプト・クライアントを開始します。
- Jacl を使用
-
wsadmin
- Jython の使用
-
wsadmin -lang Jython
- アプリケーションのデプロイメント構成オブジェクトを識別して、それを変数に割り当てます。例えば、次のようになります。
- Jacl を使用
-
set app [$AdminConfig getid /Deployment:EJBinWARTest/] set depObj [$AdminConfig showAttribute $app deployedObject]
- Jython の使用
-
app = AdminConfig.getid("/Deployment:EJBinWARTest/" ) depObj = AdminConfig.showAttribute(app, "deployedObject" )
- アプリケーションのモジュールのリストを取得します。
- Jacl を使用
-
set modules [lindex [$AdminConfig showAttribute $depObj modules] 0]
- Jython の使用
-
modules = AdminConfig.showAttribute(depObj, "modules" ) modules = modules.replace('[','').replace(']','') modules = modules.split(' ')
- この例では、EJB モジュール EJBBean.jar にエンタープライズ Bean が
含まれており、Web モジュール EJB2xInWARBean.war に
別のエンタープライズ Bean が含まれています。これらの各エンタープライズ Bean の
ステートフル・セッション Bean 構成を変更する方法を
以下のコードで示します。
- Jacl を使用
-
# Assign the EJB and web module configuration IDs to variables ejbmod and webmod: foreach module $modules { set moduleName [$AdminConfig show $module uri] if { [string first "EJBBean.jar" $moduleName] >= 0} { set ejbmod $module } if { [string first "EJB2xInWARBean.war" $moduleName] >= 0} { set webmod $module } }
- Jython の使用
-
# Assign the EJB and web module configuration IDs to variables ejbmod and webmod: for module in modules: moduleName = AdminConfig.showAttribute(module, 'uri') if moduleName.find('EJBBean.jar') >= 0: ejbmod = module if moduleName.find('EJB2xInWARBean.war') >= 0 : webmod = module
- EJB モジュール構成オブジェクトを取得します。
- Jacl を使用
-
# Get the single EJB module configuration object associated with the pure EJB module: set ejbConfig [lindex [$AdminConfig showAttribute $ejbmod configs] 0] if { ($ejbConfig == "") } { puts "¥nejbConfig not present - creating one" set ejbConfig [$AdminConfig create EJBModuleConfiguration $ejbmod {{enableSFSBFailover true} {overrideDefaultDRSSettings false}}] set attrs [list config $ejbConfig] set targetMappings [lindex [$AdminConfig showAttribute $ejbmod targetMappings] 0] $AdminConfig modify $targetMappings [list $attrs] } else { puts "¥nejbConfig present" }
- Jython の使用
-
# Get the list of configuration objects associated with the pure EJB module: ejbmodConfigs = AdminConfig.showAttribute (ejbmod, 'configs') if (ejbmodConfigs): print "¥nejbmodConfigs present" # Extract the single EJB module configuration object: ejbConfig = ejbmodConfigs.replace('[','').replace(']','') print "¥nejbConfig:" print AdminConfig.show(ejbConfig) else: print "¥nejbmodConfigs not present - creating one" ecAttrs = [] attr1 = ["enableSFSBFailover", "true"] attr2 = ["overrideDefaultDRSSettings", "false"] ecAttrs.append(attr1) ecAttrs.append(attr2) ejbConfig = AdminConfig.create('EJBModuleConfiguration', ejbmod, ecAttrs) tmAttrs = ['config', ejbConfig] targetMappings = AdminConfig.showAttribute (ejbmod, 'targetMappings') targetMappings = targetMappings[1:len(targetMappings)-1] AdminConfig.modify(targetMappings, [tmAttrs])
- EJB モジュールのステートフル・セッション Bean フェイルオーバー構成設定を表示します。
- Jacl を使用
-
# Show the Stateful session bean failover configuration of the EJB module: puts "¥nStateful session bean failover settings of the EJB module" puts [$AdminConfig show $ejbConfig] # Show the drsSettings of the EJB module: set drsSettings [$AdminConfig showAttribute $ejbConfig drsSettings] if { ($drsSettings == "") } { puts "drsSettings not present on the EJB module." } else { puts "¥ndrsSettings of the EJB module:" puts [$AdminConfig show $drsSettings] }
- Jython の使用
-
# Show the Stateful session bean failover configuration of the EJB module: print AdminConfig.show(ejbConfig) # Show the drsSettings of the EJB module: drsSettings = AdminConfig.showAttribute (ejbConfig, 'drsSettings') if (drsSettings): print "¥ndrsSettings of the EJB module:" print AdminConfig.show(drsSettings) else: print "¥ndrsSettings not present on the EJB module." drsSettings = AdminConfig.showAttribute (ejbConfig, 'drsSettings') if (drsSettings): print "¥ndrsSettings of the EJB module:" print AdminConfig.show(drsSettings) else: print "¥ndrsSettings not present on the EJB module."
- wsadmin スクリプト・クライアントを開始します。
- AdminConfig オブジェクトを使用して、
同じアプリケーションの Web モジュール内のエンタープライズ Bean に対する
ステートフル・セッション Bean フェイルオーバー構成を変更します。WAR ファイルに
パッケージされた EJB モジュールの場合もステップは同様ですが、
構成オブジェクトのリストから EJB モジュールを
抽出する必要があります。
- ステップ 4 の Web モジュール構成 ID を使用して、Web モジュールに
関連付けられた EJB モジュール構成オブジェクトを取得します。
- Jacl を使用
-
# Get the web module configuration object: set webmodConfig [lindex [$AdminConfig showAttribute $webmod configs] 0] # Extract the EJB module configuration object associated with the web module. set ejbInWarConfig [$AdminConfig showAttribute $webmodConfig ejbModuleConfiguration]
- Jython の使用
-
# Get the list of configuration objects associated with the web module: webmodConfigs = AdminConfig.showAttribute (webmod, 'configs') # Extract the single web module configuration object: webmodConfig = webmodConfigs.replace('[','').replace(']','') # Extract the EJB module configuration object associated with the web module. ejbInWarConfig = AdminConfig.showAttribute (webmodConfig, 'ejbModuleConfiguration')
- ステートフル・セッション Bean の構成設定を表示します。
- Jacl を使用
-
# Show the configuration of the EJB module within the web module: puts "¥nStateful session bean failover settings of the EJB within the web module:" puts [$AdminConfig show $ejbInWarConfig] # Get the SFSB failover settings of the EJB module within the web module: set drsSettings [$AdminConfig showAttribute $ejbInWarConfig drsSettings] if { ($drsSettings == "") } { puts "drsSettings not present on the EJB within the Web module." } else { puts "¥ndrsSettings of the EJB within the Web module:" puts [$AdminConfig show $drsSettings] }
- Jython の使用
-
print "¥nStateful session bean failover configuration of the EJB module within the web module:" print AdminConfig.show(ejbInWarConfig) drsSettings = AdminConfig.showAttribute(ejbInWarConfig, 'drsSettings') if (drsSettings): print "¥ndrsSettings of the EJB module within the web module:" print AdminConfig.show(drsSettings) else: print "¥ndrsSettings not present on the EJB module within the web module." print "¥ndrsSettings of the EJB module within the Web module:"
- ステートフル・セッション Bean の構成設定を変更します。
- Jacl を使用
-
# To enable SFSB failover for the EJB within the web module: $AdminConfig modify $ejbInWarConfig {{enableSFSBFailover "true"}}
- Jython の使用
-
# Enable SFSB failover for the EJB within the web module: AdminConfig.modify(ejbInWarConfig, [['enableSFSBFailover', 'true']])
- ステップ 4 の Web モジュール構成 ID を使用して、Web モジュールに
関連付けられた EJB モジュール構成オブジェクトを取得します。
関連タスク:


http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=txml_ejbsfsbf
ファイル名:txml_ejbsfsbf.html