SitefinderOracle and Sun
Secure Search

Core Jini

»   Search By Title
»   Search By Author
»   Search By Subject
»   Just Published
»   Soon to be Published
»   Notification Form
»   Listings
 
 
 

Core Jini

2nd Edition
By W. Keith Edwards
Second edition, 900 pages
ISBN 0-13-089408-7
Sample Chapter


buy now ยป


Active Tab Introduction

Introduction

This book provides a comprehensive guide to Jini technology, the new distributed systems technology from Sun Microsystems. Jini technology has the potential to revolutionize the way we build networked software. In a sense, Jini technology signals a change from a world in which devices are networked (meaning that computers simply have the ability to talk to one another) into one in which devices join together to form a true distributed system--a collection of networked components working together.

The distinction between networked devices and true distributed systems is an important one. Simple, networked systems have simple communication patterns (Usually peer-to-peer or client/server), and tend to be static, long-lived entities. Distributed systems, on the other hand, are composed of numerous constituent pieces. Any of these pieces can come or go without bringing down the whole system, and the system can respond to changes in its environment and its constituency in reliable and predictable ways. In a nutshell, Jini technology moves us from from a world in which the "system" is the collection of all these devices working together.

This book serves two purposes. First, it provides a broad introduction to the core technologies of Jini technology. This introduction will be useful to developers of Java technology who need to understand Jini technology, and to their technically-savvy readers who need to understand how Jini technology fits into the world, and why it is significant. Second, the book provides a deep understanding of how to build working software that leverages Jini technology. This second focus is intended for a range of developers, including those who are building Jini technology-enabled software for small devices such as Personal Digital Assistants (PDAs), to those building based (local are network) networked systems for the small-office/home-office (SOHO) or remote-office/home-office (ROHO), all the way up to those building enterprise wide network services and possibly software for the Internet itself.

These two goals of the book are largely represented by the book's two parts. Part I introduces the history of Jini technology, looks at this technology's place in the world--in particular, how Jini technology is different from what came before it--and provides some details on getting started with the technology and deploying it in actual use. Part II provides an in-depth look at the core concepts of Jini technology, such as leasing, lookup, discovery, and transactions, as well as some extensive examples that illustrate particular aspects of Jini technology. Finally, the remainder of the book provides appendices and reference materials.

The philosophy taken by this book is that developers learn by reading code. You will no doubt notice if you page through this book, especially the chapters in Part II, that there are a great many code examples here. Some of these are "stand alone" Jini programs--they typically introduce some concept in the smallest number of lines possible, in the interest of clarity. Others are utility programs that cover "holes" in the Jini technology API (Application Programming Interfaces). These programs will find their way into the tool chests of programmers working with Jini technology.

Throughout this book, though, I have provided a number of longer examples that share a common theme: Taken together, these examples can be used as applications in "live" Jini networks, and can interoperate with each other. This approach is very much in keeping with the design philosophy of Jinitechnology--large numbers of cooperating applications working together to provide some service--and happens to be a good way to illustrate the ideas in Jini technology by using discrete chunks of code rather than monolithic, multithousand-line applications. Each of these examples illustrates one or more key points of the Jini architecture. They can be extended by you, and applied to any number of domains, from small, intelligent devices all the way up to enterprise software systems.

One thing this book does not provide is an introduction to Java technology itself. Jini technology is a layer atop Java--much like the Java Foundation Classes (JFC) or Java Database Connectivity (JDBC). Like these other layers, Jini introduces some new concepts and extends the Java programming model; but at its core, Jini remains pure Java. This book assumes that you are familiar with Java programming and, with one exception, does not cover the facilities available in the core Java class libraries or language.

The one exception is the Java Remote Method Invocation system (RMI). RMI is used extensively in Jini technology. In Fact, Jini technology leverages new features in RMI that only appeared in Java 2 (also popularly known as the JDK 1.2 and later versions), such as the RMI activation framework. Thus, there is an RMI primer in Appendix A of this book that serves as an introduction to this technology for those who may be unfamiliar with it.

A Road Map

Part I of this book, "Foundations," provides some necessary background reading on Jini technology. This information will be useful for savvy readers who just need to understand Jini technology, what it does, and how it works. But it's also required reading for developers who want to build actual, running Jini programs--the chapters in this part highlight the philosophical differences between Jini technology and "classical" networked and distributed systems technologies. If you have a good understanding of this material, you're ready to build software that's consistent with the aesthetic of Jini technology.

Chapter 1, "A New Computing Paradigm," looks at the history and motivation of Jini technology. You'll see how Jini technology is really the fulfillment of the original promise of Java technology: of collections of software and hardware, working together simply and without administration. This chapter also covers the process of getting and installing the Jini software.

Chapter 2, "Distributed Systems," provides a glimpse at the basics of distributed systems, and how Jini technology differs from traditional distributed systems world, and it's interesting to see the roots of Jini technology and understand what problems it's good at solving.

Chapter 3, "The Jini Model," introduces the basic concepts in Jini technology. Fortunately there are only a handful of these. Understanding these concepts and how they connect with each other will make later reading much easier and help you understand how all the big pieces of the Jini design fit together.

Chapter 4, "Deployment Scenarios," covers some strategies for deploying Jini technology services. These are development targets, if you will--ways that you as a developer can deploy Jini code that you write. Jini technology is perhaps unique in all the Java technology libraries provided by Sun in that it is specifically designed to support devices which may not have Java Virtual Machines (JVMs) embedded in them. Jini technology can be used to connect to connect devices with only limited computational ability, just as it can be used to connect large servers and other machines running full-fledged JVMs. This chapter will help you understand the options available to you if you're designing for Jini technology.

These first four chapters comprise Part I of this book--they provide a broad introduction to the Jini technology and how it fits into the world. Part II, "Building with Jini," is a very in-depth look at particular at particular aspects of Jini technology. It is designed for the professional Java developer who is writing new Jini services or building devices enabled with Jini network technology. Some of the chapters in this part are In Depth chapters that dive deeply into a particular aspect of Jini network technology. Others are structured around large examples that show Jini network technology applied to real problems

Chapter 5, "Getting Started With Jini," begins with a series of programs designed to introduce you to the core concepts of Jini network technology. This series is a set of "Hello, World"-style programs that are evolved to illustrate ideas such as lookup, discovery, leasing, and remote events. This chapter is your first introduction to building Jini network technology software from scratch, and covers almost all the basic ideas of Jini network technology, as well as provides an example of using Java technology's RMI framework.

Chapter 6, "In Depth: Discovery," is an in-depth chapter looking at Jini network technology services notify the world of their existence, and Jini network technology client applications learn about the clusters or "communities" of services that are available to them. We'll look under the hood at these protocols well enough to be able to implement them "by hand" if you need to.

Chapter 7, "Attributes, Templates, and Service Matching," Talks about the Jini network technology notion of attributes, which are objects that can be associated with services to provide descriptive information about them. This chapter talks about how to use attributes, how the Jini network technology attribute model meshes nicely with JavaBean technology, and the rules for how clients search for services that they need to use.

Chapter 8, "The Service Join Protocol," moves on to the next major phase in the Jini network technology application's life cycle, the use of the Jini network technology lookup services by other services. Any service of Jini network technology will need to use the lookup service to join a community and make itself available to other members of that community. In this chapter, you'll learn about some of the responsibilities services have to be well-behaved, how they're assigned IDs that are unique over space and time, and some introductory details about how services are administered.

Chapter 9, "Using Low-Level Lookup Service Interfaces," continues the discussion of using lookup services started in Chapter 8. In this chapter, you'll learn how clients interact with with Jini network technology lookup services to find and use services. You'll also see how to write clients that can administer lookup services, and federate them into larger structures.

Chapter 10, "Using the Service Discovery Manager," discusses some new APIs introduced with Jini network technology version 1.1. If you've been programming with Jini network technology version 1.0, you'll want to pay special attention to this chapter; the ServiceDiscoveryManager provides a useful high-level interface to working with lookup services

At this point, you should understand the basics of what you need to know to build a very functional and useful Jini network technology client application that can participate in the discovery and lookup process, and allow you to find and browse any service on the network based on Jini network technology. Chapter 11, "A Jini Lookup Service Browser," introduces a long application that exercises the ideas in the previous chapters. This application is a browser that can find lookup services and the services registered there, and allow you to view and control the attributes of those registered services. The code in this chapter builds up a toolkit of useful components for displaying and using service information, which you can reuse in your own applications.

Chapter 12, "In Depth: Leasing," gives in-depth coverage of the notion of leasing, which is how Jini network technology manages resources held by remote systems. Leasing is also the key to Jini network technology's ability to "self-heal" a large distributed system. In this chapter, we'll talk about the benefits of leasing, and cover some common idioms that arise again and again when programming with leasing.

While Chapter 12's focus is on the ideas behind leasing, and in particular how clients can use leasing, Chapter 13, "Exporting Leased Resources," talks about how Jini services can implement leasing. This is the other half of the leasing equation that is started in Chapter 12. With these two chapters, you can "close the loop," exporting a leased resource to a client, which then uses the lease consumer APIs to control it.

While the chapters on discovery, lookup, and leasing provide the basics of what you have to do to write a functional Jini service, Chapter 14, "The Well-Behaved Service," provides a summary of the extra steps you can take to provide useful and useable service. This chapter talks about service administration, the join protocol--which governs how services interact with their communities--and how to provide user interfaces for services.

After this coverage of what it takes to be a "good" service, we're ready to build a complete, sophisticated application using Jini network technology. Chapter 15, "A Complete Example: The Print Service," presents a long example of a service that allows clients to connect to it to print documents. This program supports administration, persistence, and self-description through attributes, and can serve as the basis for many of the services.

Next, Chapter 16, "In Depth: Remote Events," provides a look at how Jini network technology supports asynchronous notifications between programs. Jini network technology extends the local Java technology event model with events that can be sent between objects in different JVMs. This remote event model has different semantics than the usual JavaBeans technology event model--this chapter looks at why this is, and explores some common idioms for using remote events. The remote event model lends itself to the creation of event "adapters" that can plug into the event pipeline to provide such services as forwarding or storage of events. One of the examples here looks at an "event mailbox" adapter that can be a useful service in many Jini network technology communities.

While the preceding chapters cover topics that are considered core and fundamental to Jini network technology, the next three chapters are a bit different. These last chapters cover topics that are actually implemented as services atop the core structure of Jini network technology.

Chapter 17, "JavaSpaces," provides an introduction to Sun's JavaSpaces service. This service provides an extremely useful object storage useful object storage engine. Many applications that use Jini will need a way to store persistent data, and share it for use by other applications. JavaSpaces provides an easy object-based way for them to do this. And JavaSpaces can even serve as the basis for new styles of distributed computation. This chapter looks at the JavaSpaces programming model and philosophy.

Chapter 18, "Distributed Transactions," covers transactions, which are one of the most technical concepts in Jini. Transactions are a way for cooperating processes to ensure the integrity of their data. Essentially, transactions are a way to make sure that either an entire set of operations happen completely, or that none of them happen at all. Those of you familiar with database programming are no doubt familiar with transactions and their power in preventing partial failures. The Jini model, while based on the familiar two-phase commit protocol used in database systems, is actually somewhat different. This chapter explores those differences, and shows how to build programs that can use transactions to safely group their operations.

Chapter 19, "Helper Services," covers some new services introduced in Jini 1.1 to aid in Jini development. Much like the Transaction Manager service, these are "utility" services that are meant to be used by other clients and services to simplify development. This chapter talks about the EventMailbox service, the LookupDiscoveryService, and the LeaseRenewalService. These are important new additions to Jini that should be in any programmer's toolbox.

Finally, the two appendices in this book provide some useful reference and background material. Appendix A is a primer on the RMI technology, in particular, the features that have been added as of the Java 2 release. The RMI activation framework, which provides a way for objects to be automatically reconstituted from persistent storage when needed, will be used heavily by many Jini applications, and is important to understand. In general, a good grounding in the ideas of RMI is necessary for getting the most from Jini.

Appendix B provides a reference to the various system properties that can be useful when developing with Jini. You can use these properties to control and tune the behavior of Jini, as well as some basic Java features, in your applications.

Conventions Used in This Book

This book follows a number of conventions to help you get the most out of it. Throughout the text, you'll see a number of callouts that designate particular items of interest. These callouts, called Core Note, Core Alert, and Core Tip, provide useful information that is important enough that it should not be lost in the text. Core Alerts are used for potential pitfalls in developing Jini applications. Examples might include portions of the Jini API that are unimplemented or perhaps behave differently than the specs indicate. Core Tips are pointers to common and useful ways to accomplish particular tasks. Examples might include common idioms or patterns that can make your life as a developer easier. Core Notes are extra information that might help you make sense of some aspects of Jini, or just provide fodder for Silicon Valley cocktail party conversations.

Getting Sample Code From the Internet

All code samples in this book have been collected together, and are available electronically from my Web site. To download the code, point your Web browser to http://www.kedwards.com/jini/dl/core4jini-2e.zip. Save the file to your computer's hard disk, and extract the contents. (You may also want to see the section "Further Information" below for details on other useful information at this Web site.) If you're on Windows, use your favorite unzipped utility, such as WinZip. On Solaris and other UNIX platforms, use a command like unzip corejini-2e.zip.

The unzip process will create a directory called corejini under whatever directory you ran the unzipper. For consistency with the rest of this book, I'd recommend unzipping unzipping the contents into C:\files\corejini (on Windows) and /files/corejini (on Solaris).

Under the corejini directory, you'll find separate subdirectories for each of the chapters in this book that contain code samples.

Feedback

No book is perfect, especially one that covers a topic as new and as rich as Jini. Even though this book has been thoroughly reviewed a number of times, I have no doubt that errors do remain, or that improvements can be made. If you find a "bug." either in the text or in one of the example programs, or other readers, please drop me a note:

kedwards@parc.xerox.com

Further Information

Many of the chapters in this book have a "Further Reading" section at the end of them, with pointers to books, papers, and resources on the Internet that may extend your Jini knowledge.

However, for resources to extend this book itself, you should check out the Core Jini Web page, where I'll post news on updates, fixes, revisions, and so forth.

http://www.kedwards.com/jini


Oracle is reviewing the Sun product roadmap and will provide guidance to customers in accordance with Oracle's standard product communication policies. Any resulting features and timing of release of such features as determined by Oracle's review of roadmaps, are at the sole discretion of Oracle. All product roadmap information, whether communicated by Sun Microsystems or by Oracle, does not represent a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. It is intended for information purposes only, and may not be incorporated into any contract.



Oracle - The Information Company