Model Registry Model Resolver

The org.eclipse.gmt.umlx.registry.util.ModelResolver interface defines the API by which tools may locate models registered in the Model Registry.

The getURI(Accessor) supports resolution of an arbitrary accessor to its registered platform resource URI.

Example

A typical usage in an Eclipse context might be as follows, in which modelNameToBeResolved is resolved to resolvedResource using the model name definitions applicable to resolutionContext which is typically the IFile comprising a user model for edit, compilation, or execution.
	
String modelNameToBeResolved = ...;
ModelNameAccessor modelNameAccessor = new ModelNameAccessor(modelNameToBeResolved);
IResource resolutionContext = ...;
ModelResourceResolver resolver = new ModelResourceResolver(resolutionContext);
Registration<ModelNameAccessor> registration = resolver.getRegistration(modelNameAccessor);
if (registration != null) {
   try {
      Resource resolvedResource = resolver.getResource(registration);
      /* Do something with the resolvedResource or resolvedResource.getContents() */;
   } catch (IOException e) {
      /* Report failure to load model */;
   }
}
The required resolution is defined by constructing a ModelNameAccessor so that resolution locates a Model Name whose value is modelNameToBeResolved.

A resolver is constructed to perform resolutions with respect to the required context.

The resolver is instructed to return the registration (or null) for the required accessor.

If a registration is found, the resolver is instructed to load the corresponding resource.

Other Examples

Use the Java tooling to locate references to ModelResolver and ModelResourceResolver construction and usage.