Rational Developer for System z

Finding a resource given its qualified name

This sample demonstrates how to obtain the reference to a remote object, given its fully qualified name, using the Finder objects. The remote objects can then be used to manipulate the remote artifacts as appropriate.

Sample Scenario

To retrieve information about the specified resource, make sure the fully qualified name, of the form system.name datasetname(membername) is in the current selection, then select the API Samples > Find Resource action.

The name, full path, modification time stamp, and compiler options of the resource are displayed in the standard output associated with the workbench. This can be found in the DOS window from which the workbench was started, or in the Console view of the hosting workbench in the case of the runtime workbench.

Note: The standard output for a workbench started with the standard Eclipse icon may not be visible.

Artwork for findResourceResults

Sample Code Walk-through

Finding a Resource Object Given its Name

The following code snippet from the sample method findResource in the FindResourceAction class demonstrates how to obtain a resource object given its data set/member name.

    ZOSResourceIdentifier identifier = ZosfactoryFactory.eINSTANCE.
		createZOSResourceIdentifier();

    identifier.setDataSetName(dataset);
    identifier.setMemberName(member);
    identifier.setSystem(systemName);
    IPhysicalResource res = ZOSPhysicalResourceFinder.eINSTANCE.
		findPhysicalResource(identifier);

The code starts by creating an ZOSResourceIdentifier object. A ZOSResourceIdentifier encapsulates the name information needed to uniquely specify an MVS™ resource. After setting the data set name, member name, and system name as appropriate, the code passes that information to the findPhysicalResource method in ZOSPhysicalResourceFinder. This method is responsible for retrieving and returning an IPhysicalResource object representing the resource.

Obtaining Information on the Resource Object

Once you have the IPhysicalResource objects, you can perform various operations on them. In this example, the code retrieves various information about the resource, such as the name, modification time stamp, and system name, using the getter methods getName, getFullPath, getModificationStamp and getSystem.

 System.out.println("Name of the resource is " +
		resource.getName());
	System.out.println("Fullpath of the resource is "
		+ resource.getFullPath());
	System.out.println("Modification time stamp is "
		+ resource.getModificationStamp() + " ("
		+ new Date(resource.getModificationStamp()) + ")");
	System.out.println("Name of the associated system is "
		+ resource.getSystem().getName());

Responding to Eclipse Selection Events

This example also demonstrates how to react to selection change events in Eclipse. The FindResourceAction class implements the ISelectionListener interface. Its selectionChanged reacts to ITextSelection by extracting the text in the current selection using the getText method.

public void selectionChanged(IAction action, ISelection selection) {
	fSelectedText = null;
	if (selection instanceof ITextSelection) {
		ITextSelection textSelection = (ITextSelection) selection;
		fSelectedText = textSelection.getText();
	}
}

Feedback