Use scripting and the wsadmin tool to configure applications for stateful session bean failover.
Before starting this task, the wsadmin tool must be running. Read about starting the wsadmin scripting client for more information.
You can use the AdminConfig object to set configurations in an application. In this task, you use the AdminConfig object to display the stateful session bean failover configuration for all EJB modules in the application. Then, you use the AdminConfig object to modify the stateful session bean failover configuration for all the EJB modules in the same application.
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" )
# 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"
}
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])
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]
}
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"
$AdminConfig modify $appConfig {{enableSFSBFailover "true"}}
# Enable Stateful session bean failover for the application:
AdminConfig.modify(appConfig, [['enableSFSBFailover', 'true']])
# 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]
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)