Configure applications for session management using scripting

 

Configure applications for session management using scripting

Before starting this task, the wsadmin tool must be running. See the Starting the wsadmin scripting client article for more information.

You can use the AdminApp object to set configurations in an application. Some configuration settings are not available through the AdminApp object. The following example uses the AdminConfig object to configure session manager for the application.

  1. Identify the deployment configuration object for the application and assign it to the deployment variable. For example:

    • Using Jacl:
      set deployments [$AdminConfig getid /Deployment:myApp/]

    • Using Jython:
      deployments = AdminConfig.getid('/Deployment:myApp/')
      print deployments

    where:

    set is a Jacl command
    deployments is a variable name
    $ is a Jacl operator for substituting a variable name with its value
    AdminConfig is an object representing the WebSphere Application Server configuration
    getid is an AdminConfig command
    Deployment is an attribute
    myApp is the value of the attribute
    Example output:

    myApp(cells/mycell/applications/myApp.ear/deployments/myApp|deployment.xml#Deployment_1)

  2. Retrieve the applicaton deployment and assign it to the appDeploy variable. For example:

    • Using Jacl:
      set appDeploy [$AdminConfig showAttribute $deployments deployedObject]

    • Using Jython:
      appDeploy = AdminConfig.showAttribute(deployments, 'deployedObject')
      print appDeploy

    where:

    set is a Jacl command
    appDeploy is a variable name
    $ is a Jacl operator for substituting a variable name with its value
    AdminConfig is an object representing the WebSphere Application Server configuration
    showAttribute is an AdminConfig command
    deployments evaluates to the ID of the deployment object specified in step number 1
    deployedObject is an attribute
    Example output:

    (cells/mycell/applications/myApp.ear/deployments/myApp|deployment.xml#ApplicationDeployment_1)

  3. To obtain a list of attributes you can set for session manager, use the attributes command. For example:

    • Using Jacl:
      $AdminConfig attributes SessionManager

    • Using Jython:
      print AdminConfig.attributes('SessionManager')

    where:

    $ is a Jacl operator for substituting a variable name with its value
    AdminConfig is an object representing the WebSphere Application Server configuration
    attributes is an AdminConfig command
    SessionManager is an attribute
    Example output:

    "accessSessionOnTimeout Boolean"
    "allowSerializedSessionAccess Boolean"
    "context ServiceContext@"
    "defaultCookieSettings Cookie"
    "enable Boolean"
    "enableCookies Boolean"
    "enableProtocolSwitchRewriting Boolean"
    "enableSSLTracking Boolean"
    "enableSecurityIntegration Boolean"
    "enableUrlRewriting Boolean"
    "maxWaitTime Integer"
    "properties Property(TypedProperty)*"
    "sessionDRSPersistence DRSSettings"
    "sessionDatabasePersistence SessionDatabasePersistence"
    "sessionPersistenceMode ENUM(DATABASE, DATA_REPLICATION, NONE)"
    "tuningParams TuningParams"

  4. Set up the attributes for the session manager. The following example sets three top level attributes in the session manager. You can modify the example to set other attributes of session manager including the nested attributes in Cookie, DRSSettings, SessionDataPersistence, and TuningParms object types. To list the attributes for those object types, use the attributes command of the AdminConfig object.

    • Using Jacl:
      set attr1 [list enableSecurityIntegration true]
      set attr2 [list maxWaitTime 30]
      set attr3 [list sessionPersistenceMode NONE]
      set attrs [list $attr1 $attr2 $attr3]
      set sessionMgr [list sessionManagement $attrs]
      
      Example output using Jacl:
      sessionManagement {{enableSecurityIntegration true} {maxWaitTime 30} {sessionPersistenceMode NONE}}

    • Using Jython:
      attr1 = ['enableSecurityIntegration', 'true']
      attr2 = ['maxWaitTime', 30]
      attr3 = ['sessionPersistenceMode', 'NONE']
      attrs = [attr1, attr2, attr3]
      sessionMgr = [['sessionManagement', attrs]]
      Example output using Jython:
      [[sessionManagement, [[enableSecurityIntegration, true], [maxWaitTime, 30], [sessionPersistenceMode, NONE]]]

    where:

    set is a Jacl command
    attr1, attr2, attr3, attrs, sessionMgr are variable names
    $ is a Jacl operator for substituting a variable name with its value
    enableSecurityIntegration is an attribute
    true is a value of the enableSecurityIntegration attribute
    maxWaitTime is an attribute
    30 is a value of the maxWaitTime attribute
    sessionPersistenceMode is an attribute
    NONE is a value of the sessionPersistenceMode attribute

  5. Create the session manager for the application. For example:

    • Using Jacl:
      $AdminConfig create ApplicationConfig $appDeploy [list $sessionMgr]

    • Using Jython:
      print AdminConfig.create('ApplicationConfig', appDeploy, sessionMgr)

    where:

    $ is a Jacl operator for substituting a variable name with its value
    AdminConfig is an object representing the WebSphere Application Server configuration
    create is an AdminConfig command
    ApplicationConfig is an attribute
    appDeploy evaluates to the ID of the deployed application specified in step number 2
    list is a Jacl command
    sessionMgr evaluates to the ID of the session manager specified in step number 4
    Example output:

    (cells/mycell/applications/myApp.ear/deployments/myApp|deployment.xml#ApplicationConfig_1)

  6. Save the configuration changes. See the Saving configuration changes with the wsadmin tool article for more information.

  7. In a network deployment environment only, synchronize the node. See the Synchronizing nodes with the wsadmin tool article for more information.