Getting resource proxies

The Provider class builds proxies in response to client requests. The client can then invoke methods on the proxy to work with the represented resource.

Clients can get a proxy for a resource at a specific location by requesting that the Provider build and return a proxy for the resource at that location. For example, each of the following examples creates a proxy for a resource at the location specified by the location variable:
Resource my_resource = provider.resource(location);
 
CcActivity my_activity = ccProvider.ccActivity(location);

The proxy factory methods provide a means to obtain a proxy that implements one of its interfaces. Each domain-specific provider defines methods for creating proxies for resources in its domain. The naming convention for each factory method is that the method name has the same spelling as the proxy class except that the first letter is lowercase rather than upper case. For example, CqProvider.cqRecord() returns a CqRecord instance.

There is also the Provider.buildProxy method that is an alternative method for creating a new proxy of a given type for a resource at a specified location, and there is also the StpProvider.buildProxy(Class, String) method, which is a convenient way to get a proxy directly from a string representation of its location rather than going through StpLocation.

Proxies are not designed to be long-lived caches of information about a resource on the server. Their purpose is to marshal the data needed to perform a server operation before initiating it and to provide a container in which to return the results of the operation to a client. In a client/server application, holding data on the client introduces the risk that the data will be out of sync with the server. For this reason, the CM API always returns a new proxy for each do method operation.

See Location syntax for more information.