As mentioned previously, a client attempts to find one or more services that satisfy its requirements by creating a ServiceTemplate object and using this in a registrar's lookup() call. A ServiceTemplate object has three fields:
ServiceID serviceID; java.lang.Class serviceTypes; Entry attributeSetTemplates;
If the client is repeating a request, then it may have recorded the serviceID from an earlier request. The serviceID is a globally unique identifier, so it can be used to identify a service unambiguously. This serviceID can be used by the service locator as a filter to quickly discard other services.
Alternatively, a client may want to find a service satisfying several interface requirements at once. For example, a client may look for a service that implements both Toaster and FireAlarm (so that it can properly handle burnt toast ). The client will fill the serviceTypes array with all of the interface classes that the service has to implement.
And finally, the client will specify a set of attributes in the attrSetTemplates field that must be satisfied by each service. Each attribute required by the client is taken in turn and matched against the set offered by the service. For example, in addition to requesting a Toaster with a FireAlarm, a client entry may specify a location in GP South Building. This will be tried against all the variations of location offered by the service. A single match is good enough. An additional client requirement of, say, manufacturer would also have to be matched by the service.
The more formal description that follows comes from the ServiceTemplate API documentation: