Is it possible to set application session-timout (viz. image) by jython script?
1
votes
2 Answers
1
votes
In the snippet below change node name and server name to match your own. Use 'invalidationTimeout' attribute to specify session timeout (in example below it is set to 45 minutes), also you you can specify other related attributes as below.
server = AdminConfig.getid("/Node:was7host01Node01/Server:server1")
sms=AdminConfig.list("SessionManager",server)
AdminConfig.modify(sms,'[[tuningParams [[allowOverflow "true"] [invalidationTimeout "45"] [maxInMemorySessionCount "1000"]]]]')
AdminConfig.save()
0
votes
Yes, you'll need to use AdminConfig to create this sequence of objects:
- Find the
WebModuleDeploymentfor your module. - Find or create the
WebModuleConfigchild object underWebModuleDeployment. - Find or create the
SessionManagerchild object under theWebModuleConfig. - Find or create the
TuningParamschild object under theSessionManager. - Set the
maxInMemorySessionCountattribute of theTuningParamsobject.
I am not fluent in Jython, but the following Jacl script should do that. If you're familiar with Jython scripting in WAS, then it should be straightforward to translate.
set appName myApp
set modName myWeb.war
set maxInMemorySessionCount 1000
# Find the WebModuleDeployment.
set appDepl [$AdminConfig getid /Deployment:$appName/]
foreach webModDepl [$AdminConfig list WebModuleDeployment $appDepl] {
set uri [$AdminConfig showAttribute $webModDepl uri]
if {$uri == $modName} {
# Find or create the WebModuleConfig.
set webModCfg [$AdminConfig list WebModuleConfig $webModDepl]
if {[string length $webModCfg] == 0} {
puts "Adding WebModuleConfig to $webModDepl"
set webModCfg [$AdminConfig create WebModuleConfig $webModDepl {}]
}
# Find or create the SessionManager.
set sessionManager [$AdminConfig list SessionManager $webModCfg]
if {[string length $sessionManager] == 0} {
puts "Adding SessionManager to $webModCfg"
set sessionManager [$AdminConfig create SessionManager $webModCfg {}]
}
# Find or create the TuningParams.
set tuningParams [$AdminConfig list TuningParams $sessionManager]
if {[string length $tuningParams] == 0} {
puts "Adding TuningParams to $sessionManager"
set tuningParams [$AdminConfig create TuningParams $sessionManager {}]
}
# Set the maxInMemorySessionCount parameter.
puts "Setting maxInMemorySessionCount=$maxInMemorySessionCount in $tuningParams"
$AdminConfig modify $tuningParams [list [list maxInMemorySessionCount $maxInMemorySessionCount]]
}
}
$AdminConfig save