Configuring applications for session management using scripting

This task provides an example that uses the AdminConfig object to configure a session manager for the application.

Before you begin

An application must be installed on a running server.

About this task

You can use the AdminConfig object to set configurations in an application. Some configuration settings are not available through the AdminConfig object.

Procedure

  1. Inicie a ferramenta de script wsadmin.
  2. Identify the deployment configuration object for the application and assign it to the deployment variable.
    Note: This step is not needed for an OSGi application.
    For example:
    • Using Jacl:
      test
      set deployments [$AdminConfig getid /Deployment:myApp/]
    • Using Jython:
      deployments = AdminConfig.getid('/Deployment:myApp/')
      print deployments
    where:
    Table 1. getid command elements. Run the getid command to identify a deployment object.
    Element Description
    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)
  3. Retrieve the application deployment object 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
    Note: For an OSGi application, use the following jython code for this step:
    appDeploy = AdminTask.getOSGiApplicationDeployedObject('-cuName cu_name')
    where:
    Table 2. set command elements. Run the set command to assign the deployment object a value.
    Element Description
    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 that represents the WebSphere Application Server configuration
    showAttribute is an AdminConfig command
    deployments evaluates the ID of the deployment object that is specified in step number 1
    deployedObject is an attribute
    cu_name is the name of the composition unit
    Example output:
    (cells/mycell/applications/myApp.ear/deployments/myApp|deployment.xml#ApplicationDeployment_1)
  4. To obtain a list of attributes that you can set for a session manager, use the attributes command. For example:
    • Using Jacl:
      $AdminConfig attributes SessionManager
    • Using Jython:
      print AdminConfig.attributes('SessionManager')
    where:
    Table 3. attributes command elements. Run the attributes command to list attributes of a session manager.
    Element Description
    $ is a Jacl operator for substituting a variable name with its value
    AdminConfig is an object that represents 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"

    When you configure an application for session management, it is recommended that you specify each attribute.

    Evitar Problemas Evitar Problemas: If you are setting up the session management attributes for a cluster, you must also update the targetMappings element of the AdminConfig object for the cluster before the settings you specify for the sessionManagment element become effective. If you do not update the targetMappings element, the settings are not effective even though they appear in the deployment.xml file.gotcha
  5. Set up the attributes for the session manager.

    The following example sets four top-level attributes in the session manager. You can modify the example to set other attributes of the session manager, including the nested attributes in DRSSettings, SessionDataPersistence, and TuningParms object types.

    Evitar Problemas Evitar Problemas: The session manager requires that you set both the defaultCookieSettings and tuningParams attributes before you initialize an application. If you do not set these attributes, the session manager cannot initialize the application, and the application does not start. gotcha

    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 kuki [list maximumAge -1]
      set cookie [list $kuki]
      Set cookieSettings [list defaultCookieSettings $cookie]
      set attrs [list $attr1 $attr2 $attr3 $cookieSettings]
      set sessionMgr [list sessionManagement $attrs]
      Example output using Jacl:
      sessionManagement {{enableSecurityIntegration true} {maxWaitTime 30} {sessionPersistenceMode NONE} 
      {defaultCookieSettings {{maximumAge -1}}}}
    • Using Jython:
      attr1 = ['enableSecurityIntegration', 'true']
      attr2 = ['maxWaitTime', 30]
      attr3 = ['sessionPersistenceMode', 'NONE']
      kuki = ['maximumAge', -1] 
      cookie = [kuki] 
      cookieSettings = ['defaultCookieSettings', cookie] 
      attrs = [attr1, attr2, attr3, cookieSettings]
      sessionMgr = [['sessionManagement', attrs]]
      Example output using Jython:
      [[sessionManagement, [[enableSecurityIntegration, true], [maxWaitTime, 30], [sessionPersistenceMode, NONE], 
      [defaultCookieSettings [[maximumAge, -1]]]]
    where:
    Table 4. set command elements. Run the set command to set attributes for a session manager.
    Element Description
    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
  6. Perform one of the following:
    • 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:
      Table 5. create command elements. Run the create command to create a session manager.
      Element Description
      $ is a Jacl operator for substituting a variable name with its value
      AdminConfig is an object that represents the WebSphere Application Server configuration
      create is an AdminConfig command
      ApplicationConfig is an attribute
      appDeploy evaluates the ID of the deployed application that is specified in step number 2
      list is a Jacl command
      sessionMgr evaluates the ID of the session manager that is specified in step number 4
      Example output:
      (cells/mycell/applications/myApp.ear/deployments/myApp|deployment.xml#ApplicationConfig_1)
    • If a session manager already exists, use the modify command of the AdminConfig object to update the configuration of the session manager. For example:
      • Using Jacl:
        set configs [lindex [$AdminConfig showAttribute $appDeploy configs] 0]
        set appConfig [lindex $configs 0]
        set SM [$AdminConfig showAttribute $appConfig sessionManagement]
        $AdminConfig modify $SM $attrs
      • Using Jython:
        configs = AdminConfig.showAttribute (appDeploy, 'configs')
        appConfig = configs[1:len(configs)-1] 
        SM = AdminConfig.showAttribute (appConfig, 'sessionManagement') 
        AdminConfig.modify (SM, attrs)
  7. Save the configuration changes.
    Utilize o seguinte exemplo de comando para salvar suas alterações de configuração:
    AdminConfig.save()
  8. Synchronize the node.
    Utilize os scripts syncActiveNode ou syncNode na biblioteca de scripts AdminNodeManagement para propagar as alterações de configuração para o(s) nó(s).
    • Utilize o script syncActiveNodes para propagar as alterações para cada nó na célula, conforme demonstra o seguinte exemplo:
      AdminNodeManagement.syncActiveNodes()
    • Utilize o script syncNode para propagar as alterações para um nó específico, conforme demonstra o seguinte exemplo:
      AdminNodeManagement.syncNode("myNode")

Ícone que indica o tipo de tópico Tópico de Tarefa



Ícone de registro de data e hora Última atualização: July 9, 2016 7:58
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=txml_sessionmgt
Nome do arquivo: txml_sessionmgt.html