Configuring a shared library using scripting

You can use scripting to configure a shared library for application servers. Shared libraries are files used by multiple applications. Create a shared library to reduce the number of duplicate library files on your system.

Before you begin

There are two ways to complete this task. The example in this topic uses the AdminConfig object to create and configure a shared library. Alternatively, you can use the createSharedLibrary script in the AdminResources script library to configure shared libraries.

스크립트 라이브러리는 가장 일반적인 관리 기능을 자동화하는 프로시저 세트를 제공합니다. 각 스크립트 프로시저를 개별적으로 실행하거나 여러 프로시저를 결합하여 새 스크립트를 신속하게 개발할 수 있습니다.

Procedure

  1. wsadmin 스크립트 도구를 시작하십시오.
  2. Identify the server and assign it to the server variable. For example:
    • Using Jacl:

      set serv [$AdminConfig getid /Cell:mycell/Node:mynode/Server:server1/]
    • Using Jython:
      serv = AdminConfig.getid('/Cell:mycell/Node:mynode/Server:server1/')
      print serv
    Table 1. getid command elements. The following table describes each element of the getid command.
    Element Description
    set is a Jacl command
    serv 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
    getid is an AdminConfig command
    Cell is an attribute
    mycell is the value of the attribute
    Node is an attribute
    mynode is the value of the attribute
    Server is an attribute
    server1 is the value of the attribute
    Example output:
    server1(cells/mycell/nodes/mynode/servers/server1|server.xml#Server_1)
  3. Create the shared library in the server.

    Following are examples of how to create the shared library using either Jacl or Jython.

    • Using Jacl:

      [AIX Solaris HP-UX Linux Windows]
      $AdminConfig create Library $serv {{name mySharedLibrary} {classPath c:/mySharedLibraryClasspath}}
      [z/OS]
      $AdminConfig create Library $serv {{name mySharedLibrary} {classPath /mySharedLibraryClasspath}}
      [IBM i]
      $AdminConfig create Library $serv {{name mySharedLibrary} {classPath 
      /home/myProfile/mySharedLibraryClasspath}}
    • Using Jython:

      [AIX Solaris HP-UX Linux Windows]
      print AdminConfig.create('Library', serv, [['name', 'mySharedLibrary'], ['classPath',  
      'c:/mySharedLibraryClasspath']])
      [z/OS]
      print AdminConfig.create('Library', serv, [['name', 'mySharedLibrary'], ['classPath',  
      '/mySharedLibraryClasspath']])
      [IBM i]
      print AdminConfig.create('Library', serv, [['name', 'mySharedLibrary'], ['classPath',  
      'home/myProfile/mySharedLibraryClasspath']])
    문제점 방지 문제점 방지:
    • If you are using Jython, and the classpath does not contain any spaces, you can use a semicolon (;) or a space as a separator. For example:
      AdminConfig.create('Library', serv, [['name', 'mySharedLibrary'],              
      ['classPath','test1.jar;test2.jar;test3.jar']]) 
      or
      AdminConfig.create('Library', serv, [['name', 'mySharedLibrary'],              
      ['classPath','test1.jar test2.jar test3.jar']])  
    • If you are using Jacl, and the classpath contains one or more spaces, you must add additional braces or quotation marks around the classpath. For example:
      $AdminConfig create Library $serv {{name mySharedLibrary} {classPath {c:/Program Files/JDBC Driver/test.jar}}}
      or
      $AdminConfig create Library $serv {{name mySharedLibrary} {classPath "c:/Program Files/JDBC Driver/test.jar"}}
    • If you are using Jython, and the classpath contains one or more spaces, you must use a semicolon (;) as a separator. For example:
      AdminConfig.create('Library', serv, [['name', 'mySharedLibrary'],              
      ['classPath','c:/Program Files/JDBC Driver/test.jar;a.jar']])
      or if there is only one path:
      AdminConfig.create('Library', serv, [['name', 'mySharedLibrary'],              
      ['classPath','test1.jar test2.jar test3.jar']])  
    • If you are using Jython, and the classpath contains one or more spaces, you must add additional brackets or quotation marks around the classpath. For example:[AIX Solaris HP-UX Linux Windows]
      print AdminConfig.create('Library', serv, [['name', 'mySharedLibrary'], [['classPath',  
      'c:/Program Files/JDBC Driver/test.jar']]])
      [z/OS]
      print AdminConfig.create('Library', serv, [['name', 'mySharedLibrary'], [['classPath',  
      '/Program Files/JDBC Driver/test.jar']]])
      [IBM i]
      print AdminConfig.create('Library', serv, [['name', 'mySharedLibrary'], [['classPath',  
      'home/myProfile/Program Files/JDBC Driver/test.jar']]])
      or [AIX Solaris HP-UX Linux Windows]
      print AdminConfig.create('Library', serv, [['name', 'mySharedLibrary'], ['classPath',  
      "'c:/Program Files/JDBC Driver/test.jar'"]])
      [z/OS]
      print AdminConfig.create('Library', serv, [['name', 'mySharedLibrary'], ['classPath',  
      "'/Program Files/JDBC Driver/test.jar'"]])
      [IBM i]
      print AdminConfig.create('Library', serv, [['name', 'mySharedLibrary'], ['classPath',  
      "'home/myProfile/Program Files/JDBC Driver/test.jar'"]])
    • Using Jython, if the classpath contains more than one path, you can use either list syntax, or string syntax delimited by a semicolon to specify the multiple classpaths.

      Using list syntax :

      [AIX Solaris HP-UX Linux Windows]
      print AdminConfig.create('Library', serv, [['name', 'mySharedLibrary'], [classPath [test1.jar test2.jar test3.jar]]]')
      [z/OS]
      print AdminConfig.create('Library', serv, [['name', 'mySharedLibrary'], ['classPath [test1.jar test2.jar test3.jar]]]')
      [IBM i]
      print AdminConfig.create('Library', serv, [['name', 'mySharedLibrary'], ['classPath [test1.jar test2.jar test3.jar]]]')

      Using string syntax delimited by a semicolon:

      [AIX Solaris HP-UX Linux Windows]
      print AdminConfig.create('Library', serv, [['name', 'mySharedLibrary'], [classPath,'test1.jar;test2.jar;test3.jar']])
      [z/OS]
      print AdminConfig.create('Library', serv, [['name', 'mySharedLibrary'], [classPath,'test1.jar;test2.jar;test3.jar']])
      [IBM i]
      print AdminConfig.create('Library', serv, [['name', 'mySharedLibrary'], [classPath,'test1.jar;test2.jar;test3.jar']])
    • Using Jython, if the classpath contains more than one path, and one of those classpaths contain one or more spaces, enclose the path string that contains the spaces with quotation marks. For example:[AIX Solaris HP-UX Linux Windows]
      print AdminConfig.create('Library', serv, [['name', 'mySharedLibrary'], [classPath [test1.jar "C:/Program Files/JDBC Driver/test.jar" test3.jar]]]')
      [z/OS]
      print AdminConfig.create('Library', serv, [['name', 'mySharedLibrary'], ['classPath [test1.jar "C:/Program Files/JDBC Driver/test.jar" test3.jar]]]')
      [IBM i]
      print AdminConfig.create('Library', serv, [['name', 'mySharedLibrary'], ['classPath [test1.jar "C:/Program Files/JDBC Driver/test.jar" test3.jar]]]')
    gotcha
    Table 2. create Library command elements. The following table describes each element of the create Library command.
    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
    Library is an attribute
    serv evaluates the ID of the server that is specified in step number 1
    name is an attribute
    mySharedLibrary is a value of the name attribute
    classPath is an attribute
    /mySharedLibraryClasspath is the value of the classpath attribute
    print is a Jython command
    Example output:
    MysharedLibrary(cells/mycell/nodes/mynode/servers/server1|libraries.xml#Library_1)
  4. Identify the application server from the server and assign it to the appServer variable. For example:
    • Using Jacl:

      set appServer [$AdminConfig list ApplicationServer $serv]
    • Using Jython:
      appServer = AdminConfig.list('ApplicationServer', serv)
      print appServer
    Table 3. list command elements. The following table describes each element of the create list command.
    Element Description
    set is a Jacl command
    appServer 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
    list is an AdminConfig command
    ApplicationServer is an attribute
    serv evaluates the ID of the server that is specified in step number 1
    print is a Jython command
    Example output:
    server1(cells/mycell/nodes/mynode/servers/server1|server.xml#ApplicationServer_1
  5. Identify the class loader in the application server 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:
      • Using Jacl:

        set classLoad [$AdminConfig showAttribute $appServer classloaders]
        set classLoader1 [lindex $classLoad 0]
      • Using Jython:
        classLoad = AdminConfig.showAttribute(appServer, 'classloaders')
        cleanClassLoaders = classLoad[1:len(classLoad)-1]
        classLoader1 = cleanClassLoaders.split(' ')[0]
      Table 4. showAttribute command elements. The following table describes each element of the showAttribute command.
      Element Description
      set is a Jacl command
      classLoad, classLoader1 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
      appServer evaluates the ID of the application server that is specified in step number 3
      classloaders is an attribute
      print is a Jython command
    • To create a new class loader, issue the following command:
      • Using Jacl:

        set classLoader1 [$AdminConfig create Classloader $appServer {{mode PARENT_FIRST}}]
      • Using Jython:
        classLoader1 = AdminConfig.create('Classloader', appServer, [['mode',  'PARENT_FIRST']])
    Table 5. create Classloader command elements. The following table describes each element of the create Classloader command.
    Element Description
    set is a Jacl command
    classLoader1 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
    create is an AdminConfig command
    Classloader is an attribute
    appServer evaluates the ID of the application server that is specified in step number 3
    mode is an attribute
    PARENT_FIRST is the value of the attribute
    print is a Jython command
    Example output:
    (cells/mycell/nodes/mynode/servers/server1|server.xml#Classloader_1)
  6. Associate the shared library that you created with the application server through the class loader. For example:
    • Using Jacl:

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

    • Using Jython:
      print AdminConfig.create('LibraryRef', classLoader1, [['libraryName', 'MyshareLibrary']])
    Table 6. create LibraryRef command elements. The following table describes each element of the create LibraryRef command.
    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
    LibraryRef is an attribute
    classLoader1 evaluates the ID of the class loader that is specified in step number 4
    libraryName is an attribute
    MyshareLibrary is the value of the attribute
    print is a Jython command
    Example output:
    (cells/mycell/nodes/mynode/servers/server1|server.xml#LibraryRef_1)
  7. Save the configuration changes.
    다음 명령 예제를 사용하여 구성 변경사항을 저장하십시오.
    AdminConfig.save()
  8. Synchronize the node.
    AdminNodeManagement 스크립트 라이브러리에 있는 syncActiveNode 또는 syncNode 스크립트를 사용하여 구성 변경사항을 노드에 전파하십시오.
    • 다음 명령 데모에 표시된 것과 같이, syncActiveNodes 스크립트를 사용하여 변경사항을 셀 내의 각 노드에 전파하십시오.
      AdminNodeManagement.syncActiveNodes()
    • 다음 명령 데모에 표시된 것과 같이, syncNode 스크립트를 사용하여 변경사항을 특정 노드에 전파하십시오.
      AdminNodeManagement.syncNode("myNode")

주제 유형을 표시하는 아이콘 태스크 주제



시간소인 아이콘 마지막 업데이트 날짜: July 9, 2016 6:14
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=txml_library
파일 이름:txml_library.html