+

Search Tips   |   Advanced Search

 

Configure a shared library using scripting

 

You can use scripting to configure a shared library for appservers. Before starting this task, the wsadmin tool must be running. See the Start the wsadmin scripting client article for more information.

 

Overview

Perform the following steps to configure an appserver to use a shared library.

 

Procedure

  1. Identify the server and assign it to the server variable. For example:

      Use Jacl:

      set serv [$AdminConfig getid /Cell:mycell/Node:mynode/Server:server1/]
      

    • Use Jython:

      serv = AdminConfig.getid('/Cell:mycell/Node:mynode/Server:server1/') print serv
      

    where:

    set Jacl command
    serv variable name
    $ Jacl operator for substituting a variable name with its value
    AdminConfig object that represents the WebSphere Application Server configuration
    getid AdminConfig command
    Cell attribute
    mycell value of the attribute
    Node attribute
    mynode value of the attribute
    Server attribute
    server1 value of the attribute

    Example output:

    server1(cells/mycell/nodes/mynode/servers/server1|server.xml#Server_1)
    

  2. Create the shared library in the server. For example:

      Use Jacl:

      $AdminConfig create Library $serv {{name mySharedLibrary} {classPath c:/mySharedLibraryClasspath}}
      

      Use Jython:

      print AdminConfig.create('Library', serv, [['name', 'mySharedLibrary'], ['classPath',  
      'c:/mySharedLibraryClasspath']])
      
      

    where:

    $ Jacl operator for substituting a variable name with its value
    AdminConfig object that represents the WebSphere Application Server configuration
    create AdminConfig command
    Library attribute
    serv evaluates the ID of the server that is specified in step number 1
    name attribute
    mySharedLibrary value of the name attribute
    classPath attribute
    /mySharedLibraryClasspath value of the classpath attribute
    print Jython command

    Example output:

    MysharedLibrary(cells/mycell/nodes/mynode/servers/server1|libraries.xml#Library_1)
    

  3. Identify the appserver from the server and assign it to the appServer variable. For example:

      Use Jacl:

      set appServer [$AdminConfig list ApplicationServer $serv]
      

    • Use Jython:

      appServer = AdminConfig.list('ApplicationServer', serv) print appServer
      

    where:

    set Jacl command
    appServer variable name
    $ Jacl operator for substituting a variable name with its value
    AdminConfig object that represents the WebSphere Application Server configuration
    list AdminConfig command
    ApplicationServer attribute
    serv evaluates the ID of the server that is specified in step number 1
    print Jython command

    Example output:

    server1(cells/mycell/nodes/mynode/servers/server1|server.xml#ApplicationServer_1
    

  4. Identify the class loader in the appserver and assign it to the classLoader variable. For example:

    • To use the existing class loader that is associated with the server, the following commands use the first class loader:

        Use Jacl:

        set classLoad [$AdminConfig showAttribute $appServer classloaders] set classLoader1 [lindex $classLoad 0]
        

      • Use Jython:

        classLoad = AdminConfig.showAttribute(appServer, 'classloaders') cleanClassLoaders = classLoad[1:len(classLoad)-1] classLoader1 = cleanClassLoaders.split(' ')[0]
        

      where:

      set Jacl command
      classLoad, classLoader1 variable name
      $ Jacl operator for substituting a variable name with its value
      AdminConfig object that represents the WebSphere Application Server configuration
      showAttribute AdminConfig command
      appServer evaluates the ID of the appserver that is specified in step number 3
      classloaders attribute
      print Jython command

    • To create a new class loader,...

        Use Jacl:

        set classLoader1 [$AdminConfig create Classloader $appServer {{mode PARENT_FIRST}}]
        

      • Use Jython:

        classLoader1 = AdminConfig.create('Classloader', appServer, [['mode',  'PARENT_FIRST']])
        

    where:

    set Jacl command
    classLoader1 variable name
    $ Jacl operator for substituting a variable name with its value
    AdminConfig object that represents the WebSphere Application Server configuration
    create AdminConfig command
    Classloader attribute
    appServer evaluates the ID of the appserver that is specified in step number 3
    mode attribute
    PARENT_FIRST value of the attribute
    print Jython command

    Example output:

    (cells/mycell/nodes/mynode/servers/server1|server.xml#Classloader_1)
    

  5. Associate the shared library that you created with the appserver through the class loader. For example:

      Use Jacl:

      $AdminConfig create LibraryRef $classLoader1 {{libraryName MyshareLibrary} {sharedClassloader true}}
      

    • Use Jython:

      print AdminConfig.create('LibraryRef', classLoader1, [['libraryName', 'MyshareLibrary'],  
      ['sharedClassloader', 'true']])
      

    where:

    $ Jacl operator for substituting a variable name with its value
    AdminConfig object that represents the WebSphere Application Server configuration
    create AdminConfig command
    LibraryRef attribute
    classLoader1 evaluates the ID of the class loader that is specified in step number 4
    libraryName attribute
    MyshareLibrary value of the attribute
    sharedClassloader attribute
    true value of the attribute
    print Jython command

    Example output:

    (cells/mycell/nodes/mynode/servers/server1|server.xml#LibraryRef_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.



Configure a shared library for an application using scripting
Use the AdminConfig object for scripted administration

 

Related Reference


Commands for the AdminConfig object