Query the application state using wsadmin.sh
Use the wsadmin tool and scripting to determine if an application is running.
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.
Tasks
- Start the wsadmin scripting tool.
- Determine the application state.
The following example queries the presence of the Application MBean to find out whether the application is running.
- Use Jacl:
$AdminControl completeObjectName type=Application,name=myApplication,*- Use Jython:
print AdminControl.completeObjectName('type=Application,name=myApplication,*')
Element Description $ Jacl operator for substituting a variable name with its value AdminControl Enable the manipulation of MBeans running in a WebSphere Application Server process completeObjectName AdminControl command type=Application,name=myApplication is the hierarchical containment path of the configuration object Jython command
If myApplication is running, then an Bean is created. Otherwise, the command returns nothing. If myApplication is running, the output resembles the following:
WebSphere:cell=mycell,name=myApplication,mbeanIdentifier=cells/mycell/applications/myApplication.ear/ deployments/myApplication/deployment.xml#ApplicationDeployment_1,type=Application,node=mynode,Server= dmgr,process=dmgr,J2EEName=myApplication
wsadmin AdminControl Commands for the AdminControl object