New to Java? We'll help you get started with our revised beginner's tutorial, or our free online textbook.


Get the latest Java books
h t t p : / /w w w . j a v a c o f f e e b r e a k . c o m /

Java Coffee Break

Chapter 21: Architecture

Contents

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.

21.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.

21.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.

21.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.

21.2.2 LeaseRenewalManager threads

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


This file is Copyright (©) 1999, 2000 by Jan Newmarch (http://pandonia.canberra.edu.au) jan@ise.canberra.edu.au.
This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, v0.4 or later (the latest version is presently available at http://www.opencontent.org/openpub/). Distribution of the work or derivative of the work in any standard (paper) book form is prohibited unless prior permission is obtained from the copyright holder.

Back to main


Copyright 1998, 1999, 2000 David Reilly

Privacy | Legal | Linking | Advertise!

Last updated: Monday, June 05, 2006