Stopping applications with scripting

You can stop applications using the wsadmin tool and scripting.

Before you begin

Before starting this task, the wsadmin tool must be running. See the Starting the wsadmin scripting client article for more information.

About this task

The following example stops all running applications on a server:

Procedure

  1. Identify the application manager MBean for the server where the application resides, and assign it to the appManager variable.
    • Using Jacl:
      set appManager [$AdminControl queryNames cell=mycell,node=mynode,type=
      ApplicationManager,process=server1,*]
    • Using Jython:
      appManager = AdminControl.queryNames('cell=mycell,node=mynode,type=
      ApplicationManager,process=server1,*')
      print appManager
    where:
    set is a Jacl command
    appManager is a variable name
    $ is a Jacl operator for substituting a variable name with its value
    AdminControl is an object that enables the manipulation of MBeans running in a WebSphere server process
    queryNames is an AdminControl command
    cell=mycell,node=mynode,type= ApplicationManager,process=server1 is the hierarchical containment path of the configuration object
    print is a Jython command

    This command returns the application manager MBean.

    Example output:
    WebSphere:cell=mycell,name=ApplicationManager,mbeanIdentifier=ApplicationManager,
    type=ApplicationManager,node=mynode,process=server1
  2. Query the running applications belonging to this server and assign the result to the apps variable.
    • Using Jacl:
      set apps [$AdminControl queryNames cell=mycell,node=mynode,type=Application,
      process=server1,*]
    • Using Jython:
      # get line separator 
      import  java.lang.System  as sys
      lineSeparator = sys.getProperty('line.separator')
      
      apps = AdminControl.queryNames('cell=mycell,node=mynode,type=Application,
      process=server1,*').split(lineSeparator)
      print apps
    where:
    set is a Jacl command
    apps is a variable name
    $ is a Jacl operator for substituting a variable name with its value
    AdminControl is an object that enables the manipulation of MBeans running in a WebSphere server process
    queryNames is an AdminControl command
    cell=mycell,node=mynode,type= ApplicationManager,process=server1 is the hierarchical containment path of the configuration object
    print is a Jython command

    This command returns a list of application MBeans.

    Example output:
    WebSphere:cell=mycell,name=adminconsole,mbeanIdentifier=deployment.xml
    #ApplicationDeployment_1,type=Application,node=mynode,Server=server1,
    process=server1,J2EEName=adminconsole
    WebSphere:cell=mycell,name=filetransfer,mbeanIdentifier=deployment.xml
    #ApplicationDeployment_1,type=Application,node=mynode,Server=server1,
    process=server1,J2EEName=filetransfer
  3. Stop all the running applications.
    • Using Jacl:
      foreach app $apps {
           set appName [$AdminControl getAttribute $app name]
           $AdminControl invoke $appManager stopApplication $appName}
      
    • Using Jython:
      for app in apps:
          appName = AdminControl.getAttribute(app, 'name')
          AdminControl.invoke(appManager, 'stopApplication', appName)
    This command stops all the running applications by invoking the stopApplication operation on the MBean, passing in the application name to stop.

Results

Once you complete the steps for this task, all running applications on the server are stopped.



In this information ...


IBM Redbooks, demos, education, and more

(Index)

Use IBM Suggests to retrieve related content from ibm.com and beyond, identified for your convenience.

This feature requires Internet access.

Task topic Task topic    

Terms and conditions for information centers | Feedback

Last updatedLast updated: Aug 31, 2013 12:02:36 AM CDT
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=pix&product=was-nd-zos&topic=txml_stopapplication
File name: txml_stopapplication.html