使用脚本编制在应用程序级别配置有状态会话 Bean 故障转移
使用脚本编制和 wsadmin 工具为有状态会话 Bean 故障转移配置应用程序。
开始之前
开始本任务前,wsadmin 工具必须正在运行。请阅读“启动 wsadmin 脚本编制客户机”,以了解更多信息。
关于此任务
可以使用 AdminConfig 对象来设置应用程序中的配置。在此项任务中,将使用 AdminConfig 对象来显示应用程序中所有 EJB 模块的有状态会话 Bean 故障转移配置。然后,使用 AdminConfig 对象来修改同一应用程序中所有 EJB 模块的有状态会话 Bean 故障转移配置。
过程
- 启动 wsadmin 脚本编制客户机。
- 使用 Jacl
wsadmin
- 使用 Jython:
wsadmin -lang Jython
- 使用 Jacl
- 识别应用程序的部署配置对象,并将其指定给部署变量;例如:
- 使用 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
- 获取应用程序配置对象。如果该对象不存在,请创建该对象。
- 使用 Jacl
# Get the single application configuration object: set appConfig [lindex [$AdminConfig showAttribute $depObj configs] 0] # Create the application configuration object if not present: if { ($appConfig == "") } { puts "\nappConfig not present - creating one" set appConfig [$AdminConfig create ApplicationConfig $depObj {{enableSFSBFailover true} {overrideDefaultDRSSettings false}}] set attrs [list config $appConfig] set targetMappings [lindex [$AdminConfig showAttribute $depObj targetMappings] 0] $AdminConfig modify $targetMappings [list $attrs] } else { puts "\nappConfig present" }
- 使用 Jython:
appConfig = AdminConfig.showAttribute (depObj, 'configs') appConfig = appConfig.replace('[','').replace(']','') if (appConfig): print "\nappConfig present" else: print "\nappConfig not present - creating one" acAttrs = [] attr1 = ["enableSFSBFailover", "true"] attr2 = ["overrideDefaultDRSSettings", "false"] acAttrs.append(attr1) acAttrs.append(attr2) appConfig = AdminConfig.create('ApplicationConfig', depObj, acAttrs) tmAttrs = ['config', appConfig] targetMappings = AdminConfig.showAttribute (depObj, 'targetMappings') targetMappings = targetMappings[1:len(targetMappings)-1] AdminConfig.modify(targetMappings, [tmAttrs])
- 使用 Jacl
- 显示应用程序的有状态会话 Bean 故障转移配置设置。
- 使用 Jacl
puts "\nStateful session bean failover settings at the application level" puts [$AdminConfig show $appConfig] # Show the drsSettings of the application: set drsSettings [$AdminConfig showAttribute $appConfig drsSettings] if { ($drsSettings == "") } { puts "drsSettings not present" } else { puts "\ndrsSettings of the application:" puts [$AdminConfig show $drsSettings] }
- 使用 Jython:
print "\nStateful session bean failover configuration of the application :" print AdminConfig.show(appConfig) drsSettings = AdminConfig.showAttribute (appConfig, 'drsSettings') if (drsSettings): print "\ndrsSettings of the application:" print AdminConfig.show(drsSettings) else: print "drsSettings not present"
- 使用 Jacl
- 为应用程序启用有状态会话 bean 故障转移。
- 使用 Jacl
$AdminConfig modify $appConfig {{enableSFSBFailover "true"}}
- 使用 Jython:
# Enable Stateful session bean failover for the application: AdminConfig.modify(appConfig, [['enableSFSBFailover', 'true']])
- 使用 Jacl
- 为应用程序添加或修改数据复制服务设置。
- 使用 Jacl
# To add or modify drsSettings for the application: set drsSettings [$AdminConfig showAttribute $appConfig drsSettings] if { ($drsSettings == "") } { puts "\ndrsSettings not present - creating them" $AdminConfig create DRSSettings $appConfig "{messageBrokerDomainName ReplicationDomain2}" } else { set newMessageBrokerDomainName "{messageBrokerDomainName ReplicationDomain2}" $AdminConfig modify $drsSettings $newMessageBrokerDomainName } $AdminConfig modify $appConfig {{overrideDefaultDRSSettings "true"}} # Show the new or modified drsSettings of the application: set drsSettings [$AdminConfig showAttribute $appConfig drsSettings] puts "\nModified drsSettings of the application:" puts [$AdminConfig show $drsSettings]
- 使用 Jython:
drsSettings = AdminConfig.showAttribute (appConfig, 'drsSettings') if (drsSettings): newMessageBrokerDomainName = "{messageBrokerDomainName ReplicationDomain2}" AdminConfig.modify(drsSettings, newMessageBrokerDomainName) else: print "\ndrsSettings not present - creating them" drsAttr1 = ["messageBrokerDomainName","ReplicationDomain2"] drsAttrs = [] drsAttrs.append(drsAttr1) AdminConfig.create("DRSSettings",appConfig,drsAttrs) AdminConfig.modify(appConfig, [['overrideDefaultDRSSettings', 'true']]) # Show the new or modified drsSettings of the application: drsSettings = AdminConfig.showAttribute (appConfig, 'drsSettings') print "\nNew or Modified drsSettings of the application:" print AdminConfig.show(drsSettings)
- 使用 Jacl
相关概念:
相关参考:


http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=txml_ejbsfsbapp
文件名:txml_ejbsfsbapp.html