Configuring stateful session bean failover at the application level using scripting
Use scripting and the wsadmin tool to configure applications for stateful session bean failover.
Before you begin
Before starting this task, the wsadmin tool must be running. Read about starting the wsadmin scripting client for more information.
About this task
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.
Procedure
- Start the wsadmin scripting client.
- Using Jacl
wsadmin
- Using Jython
wsadmin -lang Jython
- Using Jacl
- Identify the deployment configuration object for the application
and assign it to the deployment variable; for example:
- Using Jacl
set app [$AdminConfig getid /Deployment:EJBinWARTest/] set depObj [$AdminConfig showAttribute $app deployedObject]
- Using Jython
app = AdminConfig.getid("/Deployment:EJBinWARTest/" ) depObj = AdminConfig.showAttribute(app, "deployedObject" )
- Using Jacl
- Get the application configuration
object. If it does not exist, create it.
- Using 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" }
- Using 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])
- Using Jacl
- Display the stateful session bean
failover configuration settings of the application.
- Using 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] }
- Using 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"
- Using Jacl
- Enable stateful session bean failover for the application.
- Using Jacl
$AdminConfig modify $appConfig {{enableSFSBFailover "true"}}
- Using Jython
# Enable Stateful session bean failover for the application: AdminConfig.modify(appConfig, [['enableSFSBFailover', 'true']])
- Using Jacl
- Add or modify the data replication
service settings for the application.
- Using 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]
- Using 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)
- Using Jacl
Related concepts:
Related tasks:
Related reference:


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