Rational Developer for System z

특성 그룹 작성

이 샘플에서는 Rational® Developer for System z®에 등록된 특성 및 미리 정의된 특성의 값이 있는 특성 그룹을 프로그램 방식으로 작성하는 방법을 보여줍니다.

샘플 시나리오

특성 그룹을 작성하려면 원격 시스템 보기에 있는 MVS 파일 노드의 팝업 메뉴에서 API 샘플 조치 -> 특성 그룹 작성 조치를 선택하십시오.

명령문은 특성 그룹이 작성될 때와 특성 값이 설정될 때 표시됩니다. 또한 오류 조건이 발견되면 오류 메시지도 표시됩니다. 워크벤치와 연관된 표준 출력에 표시되며, 워크벤치가 시작된 DOS 창이나 런타임 워크벤치의 경우 워크벤치를 호스트하는 콘솔 보기에서 볼 수 있습니다.

주: 표준 Eclipse 아이콘을 사용하여 시작된 워크벤치의 표준 출력은 워크벤치의 런타임 설정에 따라 표시되지 않을 수 있습니다.

다음 그림은 특성 그룹 작성 및 값 설정의 결과를 보여줍니다.

createPropertyGroupResults의 아트워크

샘플 코드 설명

시스템의 특성 그룹 컨테이너 검색

CreatePropertyGroupAction 클래스의 다음 코드 스니펫은 선택된 시스템의 특성 그룹 컨테이너를 검색하는 방법을 보여줍니다.
  
if (selectedItem == null) {
  System.err.println("Create Property Group Action - Selected resource must be an MVS File subsystem.");
  return;
}
if (selectedItem instanceof ZOSSystemReference) {
  System.out.println("");
  System.out.println("-----------------------");
  System.out.println("Beginning Create Property Group Action...");
  ZOSSystemReference reference = (ZOSSystemReference) selectedItem;
  ZOSSystemImage system = (ZOSSystemImage) reference.getReferent();
  // Get the property group container for this system.
  ZOSPropertyGroupManager manager = ZOSPropertyGroupManager.getZOSPropertyGroupManager();
  IPropertyGroupContainer container = manager.getPropertyGroupContainer(system.getName());
  if (container == null) {
    System.err.println("Create Property Group Action - No container for system: " + system.getName());
    return;
  }

이 코드는 selectedItemZOSSystemReference 클래스의 인스턴스인지 확인하고 시작됩니다. 이 경우, getReferent 메소드를 사용하여 ZOSSystemReference에서 ZOSSystemImage를 검색합니다.

각 시스템 연결의 경우 특성 그룹 컨테이너가 있습니다. 지정된 시스템 이름의 특성 그룹 컨테이너는 ZOSPropertyGroupManager 클래스의 getPropertyGroupContainer 메소드를 사용하여 검색할 수 있습니다.

특성 그룹 작성

CreatePropertyGroupAction 클래스의 다음 코드 스니펫은 미리 정의된 카테고리의 카테고리 인스턴스는 물론 사용자 정의 카테고리의 카테고리 인스턴스를 구성하는 특성 그룹을 작성하는 방법을 보여줍니다.
 
IPropertyGroup group = null;
try {
  group = container.createPropertyGroup(PROPERTY_GROUP_NAME, "");
  System.out.println(PROPERTY_GROUP_NAME + " created.");
} catch (DuplicatePropertyGroupException e1) {
  System.err.println("Create Property Group Action - Property group already exists.");
  return;
}

특성 그룹은 createPropertyGroup 메소드를 사용하여 작성됩니다. 특성 그룹이 이미 있으면 DuplicatePropertyGroupException이 발생하고 오류 메시지가 표시됩니다.

사용자 정의 카테고리 사용

다음 코드 스니펫은 사용자 정의 카테고리의 카테고리 인스턴스를 작성하여 특성 그룹에 추가하는 방법을 보여줍니다.
// Create an instance of the user-defined category, set properties,
// and add the instance to the property group. These properties will not appear
// in the UI, but they are available through the API.
try {
  ICategory category = manager.getCategory("SAMPLE_CATEGORY");
  if (category == null) {
    System.err.println("Create Property Group Action - Could not find category SAMPLE_CATEGORY.");
    return;
  }
  ICategoryInstance instance = category.makeInstance();
  instance.setValue("PROPERTY_1", "value1");
  System.out.println("PROPERTY_1 set to value1");
  instance.setValue("PROPERTY_2", "value2");
  System.out.println("PROPERTY_2 set to value2");
  group.addCategoryInstance(instance);
} catch (UnregisteredPropertyException e) {
  System.err.println("Create Property Group Action - Unregistered property: " + e.getName());
  return;
} catch (DuplicateInstanceException e) {
  System.err.println("Create Property Group Action - Duplicate instance of category: " + e.getCategoryInstance().getCategory().getName());
  return;
}
SAMPLE_CATEGORY 카테고리의 인스턴스는 이전 코드 스니펫을 사용하여 작성됩니다. 이 카테고리는 다음 Eclipse 확장점을 사용하여 Rational Developer for System z에 등록됩니다.
<extension point="com.ibm.ftt.properties.api.category">
  <category name="SAMPLE_CATEGORY">
    <property name="PROPERTY_1" />
    <property name="PROPERTY_2" />
  </category>
</extension>

사용자 인터페이스는 확장할 수 없으므로 이러한 특성 값이 Rational Developer for System z 사용자 인터페이스에 표시되지 않지만 API를 통해 사용할 수 있습니다.

미리 정의된 카테고리 사용

다음 코드 스니펫은 미리 정의된 카테고리의 카테고리 인스턴스를 작성하여 특성 그룹에 추가하는 방법을 보여줍니다.
// Create an instance of a pre-defined category, set properties,
// and add the instance to the property group. The values are not
// realistic values, this is just an example of how to work with
// pre-defined properties.
try {
  ICategory category = manager.getCategory(IPropertyGroupConstants.JCL_OPTIONS);
  if (category == null) {
    System.err.println("Create Property Group Action - Could not find category " + IPropertyGroupConstants.COBOL_SETTINGS);
    return;
  }
  ICategoryInstance instance = category.makeInstance();
  instance.setValue(IPropertyGroupConstants.JOBCARD, "//sample jobcard");
  System.out.println(IPropertyGroupConstants.JOBCARD + " set to //sample jobcard");
  instance.setValue(IPropertyGroupConstants.GENERATED_JCL_DATASET, "sample.test.jcl");
  System.out.println(IPropertyGroupConstants.GENERATED_JCL_DATASET + " set to sample.test.jcl");
  group.addCategoryInstance(instance);
} catch (UnregisteredPropertyException e) {
  System.err.println("Create Property Group Action - Unregistered property: " + e.getName());
  return;
} catch (DuplicateInstanceException e) {
  System.err.println("Create Property Group Action - Duplicate instance of category: " + e.getCategoryInstance().getCategory().getName());
}

(IPropertyGroupConstants)에 미리 정의된 카테고리 및 특성의 이름이 포함되어 있습니다.


이용 약관 | 피드백

이 Information Center는 Eclipse 기술로 구현됩니다. (http://www.eclipse.org 웹사이트 참조)