【问题标题】:Websphere 7, session-timeout using jythonWebsphere 7,使用 jython 的会话超时
【发布时间】:2012-05-03 08:44:30
【问题描述】:

是否可以通过 jython 脚本设置应用程序会话超时(即图像)?

http://prntscr.com/8t1n8

【问题讨论】:

  • 我已经完成了一行,但感谢所有 AdminConfig.create('TuningParams', AdminConfig.create('SessionManager',AdminConfig.create('ApplicationConfig',AdminConfig.list('ApplicationDeployment ',AdminConfig.getid('/Deployment:taskspace/')),[]),[]), [['invalidationTimeout', 40]])

标签: websphere jython


【解决方案1】:

在下面的 sn-p 中更改节点名称和服务器名称以匹配您自己的名称。使用 'invalidationTimeout' 属性指定会话超时(在下面的示例中设置为 45 分钟),您也可以指定其他相关属性,如下所示。

server = AdminConfig.getid("/Node:was7host01Node01/Server:server1")
sms=AdminConfig.list("SessionManager",server)
AdminConfig.modify(sms,'[[tuningParams [[allowOverflow "true"] [invalidationTimeout "45"] [maxInMemorySessionCount "1000"]]]]')
AdminConfig.save()

【讨论】:

    【解决方案2】:

    是的,您需要使用AdminConfig 来创建这个对象序列:

    1. 为您的模块查找WebModuleDeployment
    2. WebModuleDeployment 下查找或创建WebModuleConfig 子对象。
    3. WebModuleConfig 下查找或创建SessionManager 子对象。
    4. SessionManager 下查找或创建TuningParams 子对象。
    5. 设置TuningParams对象的maxInMemorySessionCount属性。

    我不精通 Jython,但下面的 Jacl 脚本应该可以做到这一点。如果您熟悉 WAS 中的 Jython 脚本,那么它应该很容易翻译。

    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
    

    【讨论】:

    • 如果答案解决了您的问题,我们鼓励您点击答案旁边的复选框接受它。
    猜你喜欢
    • 2014-08-13
    • 2014-01-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多