Taken from http://www.javaworld.com/javaworld/jw-11-1999/jw-11-jiniology.html. See this page for more resources on JavaSpaces
SummaryBy Eric Freeman and Susanne Hupfer
This article teaches you about a simple, yet powerful, new network and distributed programming tool: JavaSpaces. It's the first in a series of articles on JavaSpaces that will be featured every other month in this column. JavaSpaces is a new Jini service that is based on a persistent object store and exchange mechanism. If you're writing Jini applications, you'll want to know how to use JavaSpaces so that you can coordinate the participants in a Jini federation; you can also use JavaSpaces outside of Jini to create sophisticated distributed applications. In either case, JavaSpaces can significantly reduce the time and effort required to design and implement your network applications. If you're working on these types of applications, you'll want to read about JavaSpaces and add it to your programming repertoire. (3,800 words)
This article begins a second thread of the Jiniology series. In June, Bill Venners launched Jiniology with an overview of Jini technology -- a powerful new infrastructure for building and deploying distributed systems that are organized as federations of services. This thread, which will be featured every other month in this column, focuses on JavaSpaces, a core Jini service from Sun Microsystems that provides a high-level means of creating collaborative and distributed applications. If you're building applications with Jini, you'll want to know how to use JavaSpaces to coordinate the participants in a Jini federation. But it's also important to remember that you can use JavaSpaces separately from Jini, as a tool for building general distributed systems in Java. In either case, JavaSpaces is worth a look, because it can significantly ease the design and coding of distributed applications.
| Make room for JavaSpaces: Read the whole series! | |
|---|---|
|
|
Let's get started.
A new distributed computing model
Building distributed applications with conventional network tools usually entails passing messages between processes or invoking methods on remote objects. In JavaSpaces applications, in contrast, processes don't communicate directly, but instead coordinate their activities by exchanging objects through a space, or shared memory. A process can write new objects into a space, take objects from a space, or read (make a copy of) objects in a space; Figure 1 depicts several processes (represented by Dukes) interacting with spaces using these operations. When taking or reading objects, processes use simple matching, based on the values of fields, to find the objects that matter to them. If a matching object isn't found immediately, then a process can wait until one arrives. In JavaSpaces, unlike conventional object stores, processes don't modify objects in the space or invoke their methods directly -- while there, objects are just passive data. To modify an object, a process must explicitly remove it, update it, and reinsert it into the space.
|
|
Spaces are object stores with several important properties that contribute to making JavaSpaces a powerful, expressive tool. Let's take a closer look:
null to act as wildcards). An object in the space matches a template if it matches the template's specified fields exactly. You'll see that, with associative lookup, you can easily express queries for objects such as "Are there any tasks to compute?" or "Are there any answers to the prime factor I asked for?"
As this series progresses, we will show you how these properties play a key part in letting you create distributed applications that work well in the Jini environment, where networking is often spontaneous, and processes join and leave the computation dynamically, sometimes because of device or network failure.
Page 1 of 3, continued...
|
Page 1. Page 2. Origins of JavaSpaces Page 3. 'Hello World,' JavaSpaces style Printer-friendly (all-in-one) version |