전개된 애플리케이션의 추가 속성 조작

관리 콘솔, wsadmin 도구 또는 프로그래밍을 통해 전개된 애플리케이션의 속성을 조작할 수 있습니다. AppDeploymentTask 오브젝트를 통한 애플리케이션 설치 후 또는 설치 과정에서 노출되지 않은 속성을 조작하려면 이 예제를 사용하십시오.

시작하기 전에

이 태스크에서는 사용자가 MBean 프로그래밍 및 ConfigService 인터페이스의 기본사항을 알고 있다고 가정합니다. API(Application Programming Interface) 문서에서 MBean 프로그래밍 및 ConfigService 인터페이스에 대한 내용을 참조하십시오.

이 태스크 정보

AppDeploymentTask 오브젝트를 통해 노출되지 않은 속성을 조작하려면 배치된 애플리케이션에 대해 다음 태스크를 수행하십시오. 해당 속성은 전개된 각 애플리케이션의 구성 저장소에 작성되는 deployment.xml 파일에 저장됩니다.

프로시저

  1. 세션을 작성하십시오.
  2. WebSphere® Application Server에 연결하십시오.
  3. ApplicationDeployment 오브젝트를 찾으십시오.
  4. 속성을 조작하십시오.
  5. 변경사항을 저장하십시오.
  6. 세션을 정리하십시오.

결과

코드를 실행하면 배치된 애플리케이션의 deployment.xml 파일에서 속성이 업데이트됩니다.

예

다음 예제는 이전 단계를 기반으로 startingWeight, warClassLoaderPolicy 및 classloader 속성을 조작하는 방법을 보여 줍니다.

import java.util.Properties; 

import javax.management.Attribute;
import javax.management.AttributeList;
import javax.management.ObjectName;

import com.ibm.websphere.management.AdminClient;
import com.ibm.websphere.management.AdminClientFactory;
import com.ibm.websphere.management.Session;
import com.ibm.websphere.management.configservice.ConfigService;
import com.ibm.websphere.management.configservice.ConfigServiceHelper;
import com.ibm.websphere.management.configservice.ConfigServiceProxy;
import com.ibm.websphere.management.exception.ConfigServiceException;
import com.ibm.websphere.management.exception.ConnectorException;

public class AppManagementSample1 {

	public static void main(String[] args) {
				String hostName = "localhost";
		String port = "8880";
				String appName = "ivtApp";

				ConfigService configService = null;

				// create a session.
		Session session = new Session();

				// establish connection to the server.
		try {
			Properties props = new Properties();
						props.setProperty(AdminClient.CONNECTOR_TYPE, 
										AdminClient.CONNECTOR_TYPE_SOAP);
						props.setProperty(AdminClient.CONNECTOR_HOST, hostName);
						props.setProperty(AdminClient.CONNECTOR_PORT, port);
						AdminClient adminClient = 
								AdminClientFactory.createAdminClient(props);

						// create a config service proxy object.
						configService = new ConfigServiceProxy(adminClient);

						// Locate the application object.
						ObjectName rootID = configService.resolve(session,
										"Deployment="+appName)[0];
						System.out.println ("rootID is: " + rootID);

						// Locate the ApplicationDeployment object from the root. 
						ObjectName appDeplPattern = ConfigServiceHelper.createObjectName
												(null, "ApplicationDeployment");
			/*
						ObjectName appDeplID = configService.queryConfigObjects(session, 
										rootID, appDeplPattern, null)[0];
			*/
						AttributeList list1 = configService.getAttributes(session, 
										rootID, new String[]{"deployedObject"}, false);
						ObjectName appDeplID = (ObjectName)
								ConfigServiceHelper.getAttributeValue(list1, "deployedObject");
						System.out.println ("appDeplID: " + appDeplID);
			
						// Locate the class loader.
			
						// Change the starting weight through the startingWeight attribute. The starting weight 
       // affects the order in which applications start.
						AttributeList attrList = new AttributeList();
						Integer newWeight = new Integer (10);
						attrList.add(new Attribute("startingWeight", newWeight));

						// Change the WAR class loader policy through the warClassLoaderPolicy attribute by 
       // specifying SINGLE or MULTIPLE.
						// SINGLE=one classloader for all WAR modules
						attrList.add(new Attribute("warClassLoaderPolicy", "SINGLE"));

						// Set the class loader mode to PARENT_FIRST or PARENT_LAST.
						AttributeList clList = (AttributeList) configService.getAttribute
								(session, appDeplID, "classloader");
						ConfigServiceHelper.setAttributeValue (clList, "mode",
								"PARENT_LAST");
						attrList.add (new Attribute ("classloader", clList));

						// Set the new values.
						configService.setAttributes(session,  appDeplID, attrList);

						// Save your changes.
			configService.save(session, false);

		} catch (Exception ex) {
			            ex.printStackTrace();
		  } finally {
            // Clean up the session.
			try {
								configService.discard(session);
			}
						catch (ConfigServiceException csEx)
			{
								csEx.printStackTrace();
			}
						catch (ConnectorException cnEx)
			{
								cnEx.printStackTrace();
			}
		}		
	}
}

주제 유형을 표시하는 아이콘 태스크 주제



시간소인 아이콘 마지막 업데이트 날짜: last_date
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-base-dist&topic=tjmx_config_appdeploy
파일 이름:tjmx_config_appdeploy.html