Network Deployment (Distributed operating systems), v8.0 > Scripting the application serving environment (wsadmin) > Configure applications using scripting
Configure a shared library using scripting
We 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 the 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.
Procedure
- Start wsadmin.sh.
- Identify the server and assign it to the server variable. For example:
### Jacl
set serv [$AdminConfig getid /Cell:mycell/Node:mynode/Server:server1/]### Jython
serv = AdminConfig.getid('/Cell:mycell/Node:mynode/Server:server1/') print serv
Example output:
server1(cells/mycell/nodes/mynode/servers/server1|server.xml#Server_1)
- Create the shared library in the server. For example:
### Jacl
$AdminConfig create Library $serv {{name mySharedLibrary} {classPath c:/mySharedLibraryClasspath}}### Jython
print AdminConfig.create('Library', serv, [['name', 'mySharedLibrary'], ['classPath', 'c:/mySharedLibraryClasspath']])
Example output:
MysharedLibrary(cells/mycell/nodes/mynode/servers/server1|libraries.xml#Library_1)
- Identify the application server from the server and assign it to the appServer variable. For example:
### Jacl
set appServer [$AdminConfig list ApplicationServer $serv]### Jython
appServer = AdminConfig.list('ApplicationServer', serv) print appServer
Example output:
server1(cells/mycell/nodes/mynode/servers/server1|server.xml#ApplicationServer_1
- 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:
### Jacl
set classLoad [$AdminConfig showAttribute $appServer classloaders] set classLoader1 [lindex $classLoad 0]### Jython
classLoad = AdminConfig.showAttribute(appServer, 'classloaders') cleanClassLoaders = classLoad[1:len(classLoad)-1] classLoader1 = cleanClassLoaders.split(' ')[0]
- To create a new class loader, issue the following command:
### Jacl
set classLoader1 [$AdminConfig create Classloader $appServer {{mode PARENT_FIRST}}]### Jython
classLoader1 = AdminConfig.create('Classloader', appServer, [['mode', 'PARENT_FIRST']])
Example output:
(cells/mycell/nodes/mynode/servers/server1|server.xml#Classloader_1)
- Associate the shared library that you created with the application server through the class loader. For example:
### Jacl
$AdminConfig create LibraryRef $classLoader1 {{libraryName MyshareLibrary}}### Jython
print AdminConfig.create('LibraryRef', classLoader1, [['libraryName', 'MyshareLibrary']])
Example output:
(cells/mycell/nodes/mynode/servers/server1|server.xml#LibraryRef_1)
- Save the configuration changes.
Save the configuration changes:
AdminConfig.save()
- Synchronize the node.
Use the syncActiveNode or syncNode scripts in the AdminNodeManagement script library to propagate the configuration changes to node or nodes.
- Use the syncActiveNodes script to propagate the changes to each node in the cell:
AdminNodeManagement.syncActiveNodes()
- Use the syncNode script to propagate the changes to a specific node:
AdminNodeManagement.syncNode("myNode")
Start the wsadmin scripting client using wsadmin.sh
Create shared libraries
Associate shared libraries with applications or modules
Configure a shared library for an application using wsadmin.sh
Use the wsadmin scripting AdminConfig object for scripted administration
Related
Resource configuration scripts
Server settings configuration scripts
Commands for the AdminConfig object using wsadmin.sh