이 샘플에서는 Rational® Developer for System z®에 등록된 특성 및 미리 정의된 특성의 값이 있는 특성 그룹을 프로그램 방식으로 작성하는 방법을 보여줍니다.
특성 그룹을 작성하려면 원격 시스템 보기에 있는 MVS 파일 노드의 팝업 메뉴에서 API 샘플 조치 -> 특성 그룹 작성 조치를 선택하십시오.
명령문은 특성 그룹이 작성될 때와 특성 값이 설정될 때 표시됩니다. 또한 오류 조건이 발견되면 오류 메시지도 표시됩니다. 워크벤치와 연관된 표준 출력에 표시되며, 워크벤치가 시작된 DOS 창이나 런타임 워크벤치의 경우 워크벤치를 호스트하는 콘솔 보기에서 볼 수 있습니다.
다음 그림은 특성 그룹 작성 및 값 설정의 결과를 보여줍니다.
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;
}
이 코드는 selectedItem이 ZOSSystemReference 클래스의 인스턴스인지 확인하고 시작됩니다. 이 경우, getReferent 메소드를 사용하여 ZOSSystemReference에서 ZOSSystemImage를 검색합니다.
각 시스템 연결의 경우 특성 그룹 컨테이너가 있습니다. 지정된 시스템 이름의 특성 그룹 컨테이너는 ZOSPropertyGroupManager 클래스의 getPropertyGroupContainer 메소드를 사용하여 검색할 수 있습니다.
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;
}
<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)에 미리 정의된 카테고리 및 특성의 이름이 포함되어 있습니다.