Network Deployment (Distributed operating systems), v8.0 > Administer applications and their environment > Administer EJB applications > Administer session beans
Configure stateful session bean failover at the module level using scripting
Use scripting and wsadmin.sh to configure applications for stateful session bean failover. We can use the AdminConfig object to set configurations in an application. In this task, use the AdminConfig object to display the stateful session bean failover configuration for an EJB module in the application. Then, use the AdminConfig object to modify the stateful session bean failover configuration for a web module in the same application.
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.
- Use Jacl
wsadmin
- Use Jython
wsadmin -lang Jython
- Identify the deployment configuration object for the application, and assign it to a variable; for example:
- Use Jacl
set app [$AdminConfig getid /Deployment:EJBinWARTest/] set depObj [$AdminConfig showAttribute $app deployedObject]
- Use Jython
app = AdminConfig.getid("/Deployment:EJBinWARTest/" ) depObj = AdminConfig.showAttribute(app, "deployedObject" )
- Get the list of modules for the application.
- Use Jacl
set modules [lindex [$AdminConfig showAttribute $depObj modules] 0]
- Use 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.
- Use 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 } }
- Use 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.
- Use 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" }
- Use 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.
- Use 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] }
- Use 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."
- 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.
- Use 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]
- Use 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.
- Use 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] }
- Use 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.
- Use Jacl
# To enable SFSB failover for the EJB within the web module: $AdminConfig modify $ejbInWarConfig {{enableSFSBFailover "true"}}
- Use Jython
# Enable SFSB failover for the EJB within the web module: AdminConfig.modify(ejbInWarConfig, [['enableSFSBFailover', 'true']])
Stateful session bean failover for the EJB container
Enable or disabling stateful session bean failover at the EJB module level
Related
Stateful session beans failover settings (EJB modules)
Enable or disabling stateful session bean failover with the EJB container panel