The Artima Developer Community
Sponsored Link

Finding Services with the Jini Lookup Service
The Power and Limitations of the ServiceRegistrar Interface
by Bill Venners
First Published in JavaWorld, February 2000

<<  Page 2 of 13  >>


The ServiceTemplate class

The ServiceTemplate class, which allows you to express search criteria for Jini lookups, consists solely of these three public fields:

public Entry[] attributeSetTemplates;
public ServiceID serviceID;
public Class[] serviceTypes;

ServiceTemplate has no methods and its instances merely serve as struct-like containers for lookup service queries. Matches are performed as described by the following excerpt from ServiceTemplate's javadoc page:

Items in the lookup service are matched using an instance of [ServiceTemplate]. A service item (item) matches a service template (tmpl) if:

An entry matches an entry template if the class of the template is the same as, or a superclass of, the class of the entry, and every non-null field in the template equals the corresponding field of the entry. Every entry can be used to match more than one template. Note that in a service template, for serviceTypes and attributeSetTemplates, a null field is equivalent to an empty array; both represent a wildcard.

As described here, the service template can include a reference to an array of Class objects. These Class objects indicate to the lookup service the Java type (or types) of the service object the client desires. The service template can also include a service ID, which uniquely identifies a service, and attributes, which must exactly match the attributes uploaded by the service provider in the service item. The service template can also contain wildcards for any of these fields. A wildcard in the service ID field, for example, will match any service ID.

<<  Page 2 of 13  >>

Sponsored Links

Copyright © 1996-2018 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use