Modify nested attributes using the wsadmin scripting tool
We can modify nested attributes for a configuration object using scripting and the wsadmin tool.
The attributes for a WebSphere Application Server configuration object are often deeply nested. For example, a JDBCProvider object has an attribute factory, which is a list of the J2EEResourceFactory type objects. These objects can be DataSource objects that contain a connectionPool attribute with a ConnectionPool type containing a variety of primitive attributes.
Tasks
- Invoke the AdminConfig object commands interactively, or in a script, from an operating system command prompt.
See the topic on starting the wsadmin scripting client.
- Obtain the configuration ID of the object, for example:
Use Jacl:
set t1 [$AdminConfig getid /DataSource:TechSamp/]Use Jython:
t1=AdminConfig.getid('/DataSource:TechSamp/')
Element Description set Jacl command t1 Variable name $ Jacl operator for substituting a variable name with its value AdminConfig is an object representing the product configuration getid AdminConfig command DataSource is the object type TechSamp is the name of the object that will be modified - Modify one of the object parents and specify the location of the nested attribute within the parent, for example:
Use Jacl:
$AdminConfig modify $t1 {{connectionPool {{reapTime 2003}}}}Use Jython list:
AdminConfig.modify(t1, [["connectionPool", [["reapTime", 2003]]]])Use Jython string:
AdminConfig.modify(t1, '[[connectionPool [[reapTime 2003]]]]')
Element Description $ Jacl operator for substituting a variable name with its value AdminConfig object representing the WAS configuration modify n AdminConfig command t1 Evaluate to the configuration ID of the datasource in step number 2 connectionPool Attribute reapTime nested attribute within the connectionPool attribute 2003 Value of the reapTime attribute - Save the configuration by issuing an AdminConfig save command. For example:
Use Jacl:
$AdminConfig saveUse Jython:
AdminConfig.save()Use the reset command of the AdminConfig object to undo changes that we made to your workspace since your last save.
Example
An alternative way to modify nested attributes is to modify the nested attribute directly.
Use Jacl:
set techsamp [$AdminConfig getid /DataSource:TechSamp/] set pool [$AdminConfig showAttribute $techsamp connectionPool] $AdminConfig modify $pool {{reapTime 2003}}Use Jython list:
techsamp=AdminConfig.getid('/DataSource:TechSamp/') pool=AdminConfig.showAttribute(techsamp,'connectionPool') AdminConfig.modify(pool,[['reapTime',2003]])Use Jython string:
techsamp=AdminConfig.getid('/DataSource:TechSamp/') pool=AdminConfig.showAttribute(techsamp,'connectionPool') AdminConfig.modify(pool,'[[reapTime 2003]]')In this example, the first command gets the configuration id of the DataSource, and the second command gets the connectionPool attribute. The third command sets the reapTime attribute on the ConnectionPool object directly.
Start the wsadmin scripting client