Page 3 of 5
The discovery process
Discovery works like this: Imagine you have a Jini technology-enabled disk drive capable of offering the service of "persistent
storage" to a Jini federation. As soon as you connect the drive to the network, it broadcasts a "presence announcement" by
dropping a multicast packet onto a well-known port. Embedded in the presence announcement are two important pieces of information:
the IP address and port number where the disk drive can be contacted by a lookup service, and a list of names of groups the
device is interested in joining. Assume, for example, that the drive you just plugged into the network declares in its presence
announcement packet that it dreams of joining the "Way Cool Storage Devices" group.
Lookup services monitor the well-known port for presence announcement packets. When a lookup service receives a presence announcement,
it inspects the list of group names contained in the packet. If the lookup service maintains any of those groups, it contacts
the sender of the packet directly (using the IP address and port number from the packet) and sends it an RMI stub that will
allow it to interact with the lookup service. Thus, in the disk drive example, assume a lookup service that maintains a group
named "Way Cool Storage Devices" receives the disk drive's announcement packet. Because the announcement packet mentions the disk drive's ambition to become
part of the "Way Cool Storage Devices" group, the lookup service will contact the originator of the announcement packet -- the disk drive -- directly at the specified
IP address and port number. The lookup service will send to the disk drive an object that implements an interface through
which the disk drive can register itself, via the join process, as a member of the "Way Cool Storage Devices" group.
The join process
Once a device has discovered a lookup service, it can register its own services on that lookup service via the join process.
The join process begins when a service connects to a lookup service via the object it received from that lookup service during
the discovery process. Through the stub, the service sends information about itself to the lookup service. The lookup service
stores the information uploaded from the service and associates that service with the requested group. At that point, the
service has joined the group on that lookup service.
The information sent includes an instance of a class that implements a "service interface." It can also include other attributes, including applets that provide graphical user interfaces through which users can directly interact with the service.
The service is identified by the type of the "service interface" uploaded to the lookup service via the join process. Each kind of service is associated with one such Java technology-based interface. The lookup service stores and locates a service based on the type of that interface; clients interact with the service by invoking methods on an object that implements that interface. Thus, a storage service, for example, would upload during the join process an interface that enables clients to interact with the storage service.