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.
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.
The scripting library provides a set of procedures to automate the most common administration functions. You can run each script procedure individually, or combine several procedures to quickly develop new scripts.
Using Jacl:
set serv [$AdminConfig getid /Cell:mycell/Node:mynode/Server:server1/]
serv = AdminConfig.getid('/Cell:mycell/Node:mynode/Server:server1/') print serv
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 |
server1(cells/mycell/nodes/mynode/servers/server1|server.xml#Server_1)
Following are examples of how to create the shared library using either Jacl or Jython.
Using Jacl:
$AdminConfig create Library $serv {{name mySharedLibrary} {classPath /home/myProfile/mySharedLibraryClasspath}}
Using Jython:
print AdminConfig.create('Library', serv, [['name', 'mySharedLibrary'], ['classPath', 'home/myProfile/mySharedLibraryClasspath']])
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']])
$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"}}
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']])
print AdminConfig.create('Library', serv, [['name', 'mySharedLibrary'], [['classPath', 'home/myProfile/Program Files/JDBC Driver/test.jar']]])or
print AdminConfig.create('Library', serv, [['name', 'mySharedLibrary'], ['classPath', "'home/myProfile/Program Files/JDBC Driver/test.jar'"]])
Using list syntax :
print AdminConfig.create('Library', serv, [['name', 'mySharedLibrary'], ['classPath [test1.jar test2.jar test3.jar]]]')
Using string syntax delimited by a semicolon:
print AdminConfig.create('Library', serv, [['name', 'mySharedLibrary'], [classPath,'test1.jar;test2.jar;test3.jar']])
print AdminConfig.create('Library', serv, [['name', 'mySharedLibrary'], ['classPath [test1.jar "C:/Program Files/JDBC Driver/test.jar" test3.jar]]]')
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 |
is a Jython command |
MysharedLibrary(cells/mycell/nodes/mynode/servers/server1|libraries.xml#Library_1)
Using Jacl:
set appServer [$AdminConfig list ApplicationServer $serv]
appServer = AdminConfig.list('ApplicationServer', serv) print appServer
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 |
is a Jython command |
server1(cells/mycell/nodes/mynode/servers/server1|server.xml#ApplicationServer_1
Using Jacl:
set classLoad [$AdminConfig showAttribute $appServer classloaders] set classLoader1 [lindex $classLoad 0]
classLoad = AdminConfig.showAttribute(appServer, 'classloaders') cleanClassLoaders = classLoad[1:len(classLoad)-1] classLoader1 = cleanClassLoaders.split(' ')[0]
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 |
is a Jython command |
Using Jacl:
set classLoader1 [$AdminConfig create Classloader $appServer {{mode PARENT_FIRST}}]
classLoader1 = AdminConfig.create('Classloader', appServer, [['mode', 'PARENT_FIRST']])
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 |
is a Jython command |
(cells/mycell/nodes/mynode/servers/server1|server.xml#Classloader_1)
Using Jacl:
$AdminConfig create LibraryRef $classLoader1 {{libraryName MyshareLibrary}}
print AdminConfig.create('LibraryRef', classLoader1, [['libraryName', 'MyshareLibrary']])
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 |
is a Jython command |
(cells/mycell/nodes/mynode/servers/server1|server.xml#LibraryRef_1)
AdminConfig.save()