Use scripting and the wsadmin tool to configure applications for stateful session bean failover.
wsadmin
wsadmin -lang Jython
set app [$AdminConfig getid /Deployment:EJBinWARTest/]
set depObj [$AdminConfig showAttribute $app deployedObject]
app = AdminConfig.getid("/Deployment:EJBinWARTest/" )
depObj = AdminConfig.showAttribute(app, "deployedObject" )
set modules [lindex [$AdminConfig showAttribute $depObj modules] 0]
modules = AdminConfig.showAttribute(depObj, "modules" )
modules = modules.replace('[','').replace(']','')
modules = modules.split(' ')
# 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
}
}
# 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
# 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"
}
# 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])
# 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]
}
# 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."
# 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]
# 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')
# 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]
}
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:"
# To enable SFSB failover for the EJB within the web module:
$AdminConfig modify $ejbInWarConfig {{enableSFSBFailover "true"}}
# Enable SFSB failover for the EJB within the web module:
AdminConfig.modify(ejbInWarConfig, [['enableSFSBFailover', 'true']])