通过编程启动应用程序

您可以通过管理控制台、wsadmin 工具或编程来启动应用程序。使用此示例,通过编程来启动应用程序。

开始之前

此任务假设您对 MBean 编程有基本的了解。有关 MBean 编程的信息,请参阅 MBean Java™ 应用程序编程接口 (API) 文档。 在此信息中心中,单击引用 > 编程接口 > Mbean 接口

您必须首先在 WebSphere® Application Server 上安装了应用程序,才能启动该应用程序。

关于此任务

执行以下各项任务,从而通过编程来启动应用程序。

过程

  1. 将管理客户机连接到 WebSphere Application Server
  2. 创建应用程序管理代理。
  3. 通过传递应用程序名以及传递启动此应用程序的目标的列表(后者是可选的)对代理调用 startApplication 方法。

结果

成功运行代码之后,就启动了应用程序。

示例

以下示例显示如何根据先前列示的步骤启动应用程序。为了便于打印,某些语句被拆分为几行。

//Do a get of the administrative client to connect to
//WebSphere Application Server.

AdminClient client = ...;
String appName = "myApp";
Hashtable prefs = new Hashtable();
// Use the AppManagement MBean to start and stop applications on all or some targets.
// The AppManagement MBean is on the deployment manager in the WebSphere Application Server Network Deployment product.

// Query and get the AppManagement MBean.
ObjectName on = new ObjectName ("WebSphere:type=AppManagement,*");
Iterator iter = client.queryNames (on, null).iterator();
ObjectName appmgmtON = (ObjectName)iter.next();
			
//Start the application on all targets.
AppManagement proxy = AppManagementProxy.getJMXProxyForClient(client);
String started = proxy.startApplication(appName, prefs, null);
System.out.println("Application started on folloing servers: " + started);
			
//Start the application on some targets.
//String targets = "WebSphere:cell=cellname,node=nodename,
server=servername+WebSphere:cell=cellname,cluster=clusterName";
//String started1 = proxy.startApplication(appName, targets, prefs, null);
//System.out.println("Application started on following servers: " + started1)

指示主题类型的图标 任务主题



时间戳记图标 最近一次更新时间: last_date
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=tjmx_start_app
文件名:tjmx_start_app.html