Configure a shared library for an application using scripting
This task uses the AdminConfig object to configure a shared library for an application. Before starting this task, the wsadmin tool must be running. See the Start the wsadmin scripting client article for more information.
Overview
You can use the AdminApp object to set certain configurations in the application.
Procedure
- Identify the shared library and assign it to the library variable. You can either use an existing shared library or create a new one...
- To create a new shared library, perform the following steps:
- Idenitfy the node and assign it to a variable...
- Use Jacl:
set n1 [$AdminConfig getid /Cell:mycell/Node:mynode/]
- Use Jython:
n1 = AdminConfig.getid('/Cell:mycell/Node:mynode/') print n1where:
set Jacl command n1 variable name $ Jacl operator for substituting a variable name with its value AdminConfig object representing the WebSphere Application Server configuration getid AdminConfig command Cell object type mycell name of the object that will be modified Node object type mynode name of the object that will be modified Example output:
mynode(cells/mycell/nodes/mynode|node.xml#Node_1)
- Create the shared library in the node. The following example creates a new shared library in the node scope. You can modify it to use the cell or server scope.
Use Jacl:
set library [$AdminConfig create Library $n1 {{name mySharedLibrary} {classPath c:/mySharedLibraryClasspath}}]Use Jython:
library = AdminConfig.create('Library', n1, [['name', 'mySharedLibrary'], ['classPath', 'c:/mySharedLibraryClasspath']]) print librarywhere:
set Jacl command library variable name $ Jacl operator for substituting a variable name with its value AdminConfig object representing the WebSphere Application Server configuration create AdminConfig command Library AdminConfig object n1 evaluates to the ID of host node specified in step number 1 name attribute mySharedLibrary value of the name attribute classPath attribute /mySharedLibraryClasspath value of the classPath attribute Example output:
MySharedLibrary(cells/mycell/nodes/mynode|libraries.xml#Library_1)
To use an existing shared library,...
- Use Jacl:
set library [$AdminConfig getid /Library:mySharedLibrary/]
- Use Jython:
library = AdminConfig.getid('/Library:mySharedLibrary/') print librarywhere:
set Jacl command library variable name $ Jacl operator for substituting a variable name with its value AdminConfig object representing the WebSphere Application Server configuration getid AdminConfig command Library attribute mySharedLibrary value of the Library attribute Example output:
MySharedLibrary(cells/mycell/nodes/mynode|libraries.xml#Library_1)
Identify the deployment configuration object for the application and assign it to the deployment variable. For example:
- Use Jacl:
set deployment [$AdminConfig getid /Deployment:myApp/]
- Use Jython:
deployment = AdminConfig.getid('/Deployment:myApp/') print deploymentwhere:
set Jacl command deployment variable name $ Jacl operator for substituting a variable name with its value AdminConfig object representing the WebSphere Application Server configuration getid AdminConfig command Deployment attribute myApp value of the Deployment attribute Jython command Example output:
myApp(cells/mycell/applications/myApp.ear/deployments/myApp|deployment.xml#Deployment_1)
Retrieve the application deployment and assign it to the appDeploy variable. For example:
- Use Jacl:
set appDeploy [$AdminConfig showAttribute $deployment deployedObject]
- Use Jython:
appDeploy = AdminConfig.showAttribute(deployment, 'deployedObject') print appDeploywhere:
set Jacl command appDeploy variable name $ Jacl operator for substituting a variable name with its value AdminConfig object representing the WebSphere Application Server configuration showAttribute AdminConfig command deployment evaluates the ID of the deployment configuration object specified in step number 2 deployedObject attribute of modify objects Jython command Example output:
(cells/mycell/applications/myApp.ear/deployments/ myApp|deployment.xml#ApplicationDeployment_1)
Identify the class loader in the application deployment and assign it to the classLoader variable. For example:
- Use Jacl:
set classLoad1 [$AdminConfig showAttribute $appDeploy classloader]
- Use Jython:
classLoad1 = AdminConfig.showAttribute(appDeploy, 'classloader') print classLoad1where:
set Jacl command classLoad1 variable name $ Jacl operator for substituting a variable name with its value AdminConfig object representing the WebSphere Application Server configuration showAttribute AdminConfig command appDeploy evaluates the ID of the application deployment specified in step number 3 classLoader attribute of modify objects Jython command Example output:
(cells/mycell/applications/myApp.ear/deployments/myApp|deployment.xml#Classloader_1)
Associate the shared library in the application through the class loader. For example:
- Use Jacl:
$AdminConfig create LibraryRef $classLoad1 {{libraryName MyshareLibrary} {sharedClassloader true}}
- Use Jython:
print AdminConfig.create('LibraryRef', classLoad1, [['libraryName', 'MyshareLibrary'], ['sharedClassloader', 'true']])where:
$ Jacl operator for substituting a variable name with its value AdminConfig object representing the WebSphere Application Server configuration create AdminConfig command LibraryRef AdminConfig object classLoad1 evaluates to the ID of class loader specified in step number 4 libraryName attribute MyshareLibrary value of the libraryName attribute sharedClassloader attribute true value of the sharedClassloader attribute Example output:
(cells/mycell/applications/myApp.ear/deployments/myApp|deployment.xml#LibraryRef_1)
Save the configuration changes. See the Saving configuration changes with the wsadmin tool article for more information.
In a network deployment environment only, synchronize the node. See the Synchronizing nodes with the wsadmin tool article for more information.
Use the AdminConfig object for scripted administration
Configure a shared library using scripting
Related Reference
Commands for the AdminConfig object