프로그래밍을 통한 애플리케이션 시작
관리 콘솔, wsadmin 도구 또는 프로그래밍을 통한 애플리케이션을 시작할 수 있습니다. 이 예를 사용하여 프로그래밍을 통한 애플리케이션을 시작하십시오.
시작하기 전에
WebSphere® Application Server에서 애플리케이션을 시작하려면 먼저 애플리케이션을 설치해야 합니다.
이 태스크 정보
다음 태스크를 수행하여 프로그래밍을 통한 애플리케이션을 시작하십시오.
프로시저
- WebSphere Application Server에 관리 클라이언트를 연결하십시오.
- 애플리케이션 관리 프록시를 작성하십시오.
- 애플리케이션 이름과 선택적으로 애플리케이션을 시작할 대상 목록을 전달하여 프록시에서 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)