Make room for JavaSpaces, Part 1
Ease the development of distributed apps with JavaSpaces
By Eric Freeman and Susanne Hupfer, JavaWorld.com, 11/20/99
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.
TEXTBOX: TEXTBOX_HEAD: Make room for JavaSpaces: Read the whole series!
:END_TEXTBOX
In this series, we will begin by introducing you to the unique JavaSpaces programming model, which is quite different from
other network and distributed tools with which you might be familiar. In subsequent articles, we will cover the details of
the JavaSpaces API and how you can use it to glue processes together into a distributed application, and describe how JavaSpaces
interacts with other components of Jini. Throughout the series, you'll see that JavaSpaces is simple (the API consists of
only a handful of operations), expressive (a large number of problems can be solved using JavaSpaces), and powerful (you can
build sophisticated distributed systems with small amounts of JavaSpaces code).
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.
Resources
- For an exploration of space-based programming and an in-depth look at the JavaSpaces technology APIs, refer to JavaSpaces Principles, Patterns, and Practice, Eric Freeman, Susanne Hupfer, and Ken Arnold (Addison-Wesley, 1999)
http://www1.fatbrain.com/asp/bookinfo/bookinfo.asp?theisbn=0201309556
- "The Nuts and Bolts of Compiling and Running JavaSpaces Programs," Susanne Hupfer
http://developer.java.sun.com/developer/technicalArticles/Programming/javaspaces/index.html
- The Jini forum's discussion topic is currently on this Jiniology article about JavaSpaces. To participate, visit http://www.artima.com/jini/jf/javaspaces/index.html
- Once you start programming, you'll want to join the official JavaSpaces-users mailing list in order to share ideas with other
developers and the engineers that developed the technology
http://archives.java.sun.com/archives/javaspaces-users.html
- The Jini-users mailing list also has a fair amount of JavaSpaces-related discussion
http://archives.java.sun.com/archives/jini-users.html
- For nitty-gritty API details, the definitive references are the Jini specifications from Sun Microsystems (starting with the
Jini Entry Specification and the JavaSpaces Specification)
http://www.sun.com/jini/specs/
- The Jini specs are also conveniently provided in The Jini Specification (The Jini Technology Series), Ken Arnold, Bryan O'Sullivan, Robert W. Scheifler, Jim Waldo, and Ann Wollrath (Addison-Wesley, 1999)
http://www1.fatbrain.com/asp/bookinfo/bookinfo.asp?theisbn=0201616343
- Core Jini, W. Keith Edwards (Prentice-Hall, 1999) provides a more general treatment of every aspect of Jini technology
http://www1.fatbrain.com/asp/bookinfo/bookinfo.asp?theisbn=013014469x
- For pointers to the JavaSpaces FAQ and other documentation, visit the Sun Microsystems JavaSpaces page
http://java.sun.com/products/javaspaces/
- Details on installing the JavaSpaces technology and compiling and running JavaSpaces programs can be found at the JavaSpaces
book page
http://java.sun.com/docs/books/jini/javaspaces
- To gain insight into the philosophy that underlies Sun's approach to distributed computing, read "A Note on Distributed Computing,"
Jim Waldo, Geoff Wyant, Ann Wollrath, and Sam Kendall, Sun Microsystems TR-94-29
http://www.sunlabs.com/technical-reports/1994/abstract-29.html