Resolving a Custom Target Object

A custom target object for a query is identified by a Uniform Resource Identifiers (URI) string, which is a unique identifier for a specific custom object type. In your Data Provider Adapter, you must resolve the URI for a query target object to the correct custom object type.

Implementing a Resource Type Resolver

A best practice is to use a Resource Type Resolver to resolve a URI to the correct custom object type. To use a Resource Type Resolver, you must create a Java class that implements the interface
com.vmware.vise.data.uri.ResourceTypeResolver
.
The class you create to implement
ResourceTypeResolver
must support the following methods.
  • String getResourceType(URI uri)
    - The
    getResourceType()
    method must parse a URI and return a String containing the type of custom object to which the URI pertains. For example, for a URI that referred to a custom
    Chassis
    object, the
    getResourceType()
    method must return the String
    samples:Chassis
    .
  • String getServerGuid(URI uri)
    - The
    getServerGuid()
    method must parse a URI and return a String containing the server global unique identifier for the URI target object. For example, for the URI string
    urn:cr:samples:Chassis:server1/ch-2
    , the
    getServerGuid()
    method must return the string
    server1
    .

Registering a Resource Type Resolver

To use your Resource Type Resolver, you must register the resolver with the Data Service. You typically register the Resource Type Resolver in your Data Provider Adapter class constructor by using the Resource Type Resolver Registry service, an OSGi service included within the service layer of the
vSphere Web Client
and
vSphere Client
. You must use the Spring framework to pass the Resource Type Resolver Registry OSGi service as an argument to your class constructor method. See Passing Arguments to Your Class Constructor.
Data Provider Adapter Example shows an example of how to register a Resource Type Resolver.