130 likes | 345 Views
Object Spaces. History. Object spaces is a computing paradigm originated by Dr. David Gelernter at Yale University. A language called Linda was developed to support the concept of global object coordination.
E N D
History • Object spaces is a computing paradigm originated by Dr. David Gelernter at Yale University. A language called Linda was developed to support the concept of globalobject coordination. • A space is a shared, network-accessiblerepository for objects. Instead of communicating with each other, processescoordinate by exchanging objectsthrough one or more spaces.
ObjectSpace - concept • A space may be transient, or it may be persistent. • An object may be identified usingpropertieslookup; if a desired object is not currently available, a process can wait until one arrives. • Objects deposited in a space are passive. Unlike other models, processes don’t modify objectsin the space or invoke an object’s methods directly. • Tomodify an object, a process must explicitlyremove it, update it, and reinsert itinto the space.
Distributed applications using object spaces • Applications based on object spaces-- • A distributeddata structure: is composed of multiple objects that are stored in one or more spaces. • A distributedprotocol: defines the way participantsshare and modify these data structures in a coordinated way.
Distributed applications using object spaces - 2 Example: • The participants are a set of controllersfor printers. • The data structure is a queue of printing tasks for multiple printers • The protocol may be that each participant will try to coordinate with each other to avoidduplicating the same task and to handle errors.
Distributed applications using object spaces - 3 Example applications - chatroom: – auction: – animation production house (see JavaSpaces TM Principles, Patterns, and Practice:Chapter 1--Introduction)
JavaSpaces • Is an implementation which supports the object spaceparadigm. • Is based on Jini – it runs on top ofJini, as a service. • To install the package, you need: • jdk1.2.x • Jini1_0_1 (jini toolkit) • Jstk1_0_1 (java space toolkit)
JavaSpaces - 2 To run JavaSpaces, you need an infrastructure in place: • An HTTP server, used to download code to JavaSpaces clients. • An RMI Activation Daemon, for managing the states of Jini services. • A Lookup service: for Jini service location (reggie). • A JavaSpaces service (outrigger). • Optionally, a transaction service (mahalo).
JavaSpaces API import net.jini.core.lease.Lease; import net.jini.space.JavaSpace; // to access a JavaSpace JavaSpace space = SpaceAccessor.getSpace(); // to deposit a net.jini.core.entry.Entryobject into the JavaSpace SpaceObject msg=new SpaceObject(“SWE622”); space.write(msg, null, Lease.FOREVER); // to read an object from the JavaSpace SpaceObject template=new SpaceObject(); SpaceObject result = (SpaceObject)space.read( template, null, Long.MAX_VALUE); ref: textbook, p. 406
Samples From: JAVASPACES PRINCIPLES, PATTERNS, AND PRACTICE http://java.sun.com/docs/books/jini/javaspaces/ Chapter1/HelloWorld, HelloWorld2
Advantages of using JavaSpaces(Freeman, et al) • Simplicity. • Expressive: “Using a smallsetof operations, wecan build a large class of distributed applications without writing a lot of code.” • It supports loosely coupled protocols. • It eases the burden of writing client/server systems: the functionalities of the server are provided for free, via the spaces; in most cases only theclient code needs to be written.
Sources of information • The Nuts and Bolts of Compiling and Running JavaSpaces Programs: have links for downloading packages and installation instructions. http://www.jiniworld.net/document/javaspace/The Nuts and Bolts of Compiling and Running JavaSpaces(TM).htm • O'Reilly Network: First Contact: Is There Life in JavaSpace? [Apr. 05, 2001]