Set a shared library using scripting


 

+

Search Tips   |   Advanced Search

 

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, we 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. We can run each script procedure individually, or combine several procedures to quickly develop new scripts.

Jacl...

### Identify the server and assign it to the serv variable.
set serv [$AdminConfig getid /Cell:mycell/Node:mynode/Server:server1/]

### Create the shared libary on the server
$AdminConfig create Library $serv {{name mySharedLibrary} {classPath /mySharedLibraryClasspath}}

### Identify the appserver from the server and assign it to the appServer variable.
set appServer [$AdminConfig list ApplicationServer $serv]

### Identify the class loader in the appserver and assign it to the classLoader variable.

###

The following commands use the first class loader:
set classLoad [$AdminConfig showAttribute $appServer classloaders]
set classLoader1 [lindex $classLoad 0]

### To create a new class loader
### set classLoader1 [$AdminConfig create Classloader $appServer {{mode PARENT_FIRST}}]

### Associate the shared library that you created with the application server through the class loader.
$AdminConfig create LibraryRef $classLoader1 {{libraryName MyshareLibrary}}

Jython...

serv = AdminConfig.getid('/Cell:mycell/Node:mynode/Server:server1/')
print serv
print AdminConfig.create('Library', serv, [['name', 'mySharedLibrary'], ['classPath', '/mySharedLibraryClasspath']])
appServer = AdminConfig.list('ApplicationServer', serv)
print appServer

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

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

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

AdminConfig.save()
AdminNodeManagement.syncActiveNodes()

 

Related tasks

Create shared libraries
Associating shared libraries with applications or modules
Set a shared library for an application using scripting
Use the AdminConfig object for scripted administration

 

Related

Resource configuration scripts
Server settings configuration scripts
Commands for the AdminConfig object