Chapter 23: Architecture

This chapter looks at internal structures of Jini. This is heavily based on the 1.0 implementation by Sun, and may not be valid for any future implementations either by Sun or other vendors.

23.1. LookupLocator

This is a simple class. The constructors perform some simple sanity checking on their parameters. The method getRegistrar() attempts a socket connection to the host on port 4160 for a period of 1 minute, after which it times out if no connection has been made. If it can connect, it reads an object from the socket and coerces it to a ServiceRegistrar which it returns.

23.2. Threads

Jini uses many threads in its internal workings. The knowledge of these is not important to using Jini, but some may find it valuable to know what is going on under the hood.

23.2.1 LookupDiscovery threads

A multicast request is made by creating a new LookupDiscovery object with a non-empty set of groups, or by calling setGroups(). This must broadcast the service, looking for service locators. This is done using a thread of type Requestor. This creates a MulticastSocket, sets its time-to-live field and sends out a number (currently eight) of announcements

A class ResponseListener is used to handle replies. This runs as its own thread. It listens on a socket for responses and adds them to a list of service locators. If a new locator is found, then it calls each DiscoveryListener. (The implementation is slightly more complex due to timing issues - see the source code.)

Both of these run as daemon threads. That means they run as background threads. A user thread is needed to keep the application alive: an application will terminate if there are only daemon threads alive.

23.2.2 LeaseRenewalManager threads

A LeaseRenewalManager uses a thread of class RenewThread. This thread looks after all aspects of renewal.

23.3. Copyright

If you found this chapter of value, the full book is available from APress or Amazon . There is a review of the book at Java Zone . The current edition of the book does not yet deal with Jini 2.0, but the next edition will.

This file is Copyright (©) 1999, 2000, 2001, 2003, 2004 by Jan Newmarch (http://jan.netcomp.edu.au) jan@newmarch.name.

Creative Commons License This work is licensed under a Creative Commons License, the replacement for the earlier Open Content License.