By Jacob Childress on Jun 17, 2010
A single, comprehensive reference document for WebSphere application server's Jython API is doubtless hidden away in the dark, tangled thicket that is IBM's web site. I am as certain of this fact as I am certain that I will never find it. When, long ago, I wrote a script to automate deployments to a WebSphere app server, I cobbled it together using both the odd blog post here and there as well as the vague samples scattered through IBM's documentation -- and some of those samples were written in JACL, not Jython. It almost goes without saying that there has always been an easier way to find this information.
It helps, first of all, to know that four objects are available as global variables to any Jython process that has been created by
wsadmin. Those objects are:
You can look at these wsadmin objects if you fire up the interactive Jython interpreter:
$WASHOME/bin/wsadmin.sh -lang jython, but if you're familiar with Python's built-in introspection commands, like
help(), you'll quickly see that they're of no use to you. Fortunately, the four wsadmin objects implement their own
help() methods. To use them, print the output of
AdminObject.help(). For example,
print AdminApp.help() prints out the following:
WASX7095I: The AdminApp object allows application objects to be manipulated -- this includes installing, uninstalling, editing, and listing. Most of the commands supported by AdminApp operate in two modes: the default mode is one in which AdminApp communicates with theWebSphere server to accomplish its tasks. A local mode is also possible, in which no server communication takes place. The local mode of operation is invoked by bringing up the scripting client with no server connected using the command line "-conntype NONE" option or setting the "com.ibm.ws.scripting.connectionType=NONE" property in the wsadmin.properties...
deleteUserAndGroupEntries Deletes all the user/group information for all the roles and all the user name/password information for RunAs roles for a given application.
edit Edit the properties of an application
editInteractive Edit the properties of an application interactively...
help() with the name of a command provides details on that command. So
print AdminApp.help("edit") prints out:
WASX7104I: Method: edit
Arguments: application name, options
Description: Modifies the application specified by "application name" using the options specified by "options". The user is not prompted for any information.
This is absolutely basic stuff, but it took me forever to find it. Later, I'll cover the basics of scripting a deployment, which will exhaust my knowledge of this subject.