The Artima Developer Community
Jiniology | Jini Books | Print | Email | First Page | Previous | Next
Sponsored Link

Make Room for JavaSpaces, Part III
Coordinate your Jini Apps with JavaSpaces
by Susan Hupfer
First Published in JavaWorld, March 2000

Page 1 of 10  >>


In this article, author Suzanne Hupfer uses a simple game service example to show you how to use spaces and their operations to coordinate your Jini applications.

The first article in this JavaSpaces thread presented an overview of the JavaSpaces programming model and its simple API. You'll recall that the model is based on spaces -- shared, network-accessible object storage and exchange areas -- through which processes communicate and synchronize their activities. Indeed, coordination is a crucial component of distributed programs, just as it is in any distributed activity.

Consider cars speeding through an intersection, workers assembling a car, or athletes playing a basketball game: each of those real-world distributed systems requires coordination to function smoothly. So with distributed applications, the processes need to synchronize with one another to succeed at a common task. For example, distributed applications often need to mediate access to a limited set of shared resources, guarantee fair access to those resources, or prevent processes from terminating as they wait for resources that may never become available.

This month I'll show you how to use JavaSpaces to coordinate processes in a networked environment. At the same time, I'll start tying JavaSpaces and Jini closer together. If you've experimented with JavaSpaces, you already know that it is implemented on top of Jini. In fact, a new article, "The Nuts and Bolts of Compiling and Running JavaSpaces Programs" (see Resources), can help you get your JavaSpaces programs up and running, which can be a frustrating task, given all the Jini machinery needed underneath. What may not be as clear is that JavaSpaces is a powerful tool for communication and coordination between a Jini federation's entities. In particular, space-based communication and coordination works well in the Jini networked environment, where entities may rapidly appear and disappear at will (or against their will, in the case of machine, software, or network failures).

In this article, I'll investigate how you can achieve some simple forms of distributed synchronization by using a space. To illustrate, I'll build a distributed multiplayer game, provided as a Jini service, that permits access by a limited number of players at a time. You'll see how to mediate players' access to the game through a space. Before diving into the game service, let's start by taking a quick look at an important concept that you'll use to build synchronization into your distributed programs: how the JavaSpaces API provides basic synchronization on entries for free.

Page 1 of 10  >>

Jiniology | Jini Books | Print | Email | First Page | Previous | Next

Sponsored Links

Copyright © 1996-2018 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use