1
votes

Is it possible to set application session-timout (viz. image) by jython script?

http://prntscr.com/8t1n8

2
I have done it by one line, but thanks to all AdminConfig.create('TuningParams', AdminConfig.create('SessionManager',AdminConfig.create('ApplicationConfig',AdminConfig.list('ApplicationDeployment',AdminConfig.getid('/Deployment:taskspace/' )),[]),[]), [['invalidationTimeout', 40]]) - bilak

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:

  1. Find the WebModuleDeployment for your module.
  2. Find or create the WebModuleConfig child object under WebModuleDeployment.
  3. Find or create the SessionManager child object under the WebModuleConfig.
  4. Find or create the TuningParams child object under the SessionManager.
  5. Set the maxInMemorySessionCount attribute of the TuningParams object.

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