How are service IDs assigned?

Tim Rohaly

A service ID is generated by a lookup service when a service registers with that lookup but doesn't specify a service ID.

A lookup service is an implementation of the ServiceRegistrar interface. The register() method of this interface accepts a ServiceItem as one of its parameters - ServiceItem encapsulates the service object. If the serviceID field stored in the ServiceItem is null, the lookup service will generate a new ServiceID and assign it to that service. The service should obtain this assigned service ID using the getServiceID() method of the ServiceRegistration object returned from register(), then store that service ID for future use.