Configuring stateful session bean failover at the module level using scripting
Use scripting and the wsadmin tool to configure applications for stateful session bean failover.
Before you begin
About this task
Procedure
- Use the AdminConfig object to display the stateful session
bean failover configuration for an EJB module in the application.
- Start the wsadmin scripting client.
- Using Jacl
-
wsadmin
- Using Jython
-
wsadmin -lang Jython
- Identify the deployment configuration object for the
application, and assign it to a 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" )
- Get the list of modules for the application.
- Using Jacl
-
set modules [lindex [$AdminConfig showAttribute $depObj modules] 0]
- Using Jython
-
modules = AdminConfig.showAttribute(depObj, "modules" ) modules = modules.replace('[','').replace(']','') modules = modules.split(' ')
- In this example, the EJB module, EJBBean.jar, contains
an enterprise bean, and the web module, EJB2xInWARBean.war,contains
another enterprise bean. The following code shows how to modify the
stateful session bean configuration for each of these enterprise beans.
- Using 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 } }
- Using 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
- Get the EJB module configuration
object.
- Using 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" }
- Using 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])
- Display the stateful session bean
failover configuration settings of the EJB module.
- Using 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] }
- Using 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."
- Start the wsadmin scripting client.
- Use the AdminConfig object to modify the stateful session
bean failover configuration for an enterprise bean within a web module
in the same application. For an EJB module packaged in a WAR file,
the steps are similar, with the added step of extracting the EJB module
from the list of configuration objects.
- Given the web module configuration ID in step 4, get
the EJB module configuration object that is associated with the Web
module.
- Using 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]
- Using 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')
- Display the stateful session bean
configuration settings.
- Using 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] }
- Using 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:"
- Modify the stateful session bean configuration settings.
- Using Jacl
-
# To enable SFSB failover for the EJB within the web module: $AdminConfig modify $ejbInWarConfig {{enableSFSBFailover "true"}}
- Using Jython
-
# Enable SFSB failover for the EJB within the web module: AdminConfig.modify(ejbInWarConfig, [['enableSFSBFailover', 'true']])
- Given the web module configuration ID in step 4, get
the EJB module configuration object that is associated with the Web
module.
Related concepts:
Related tasks:
Related reference:


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