Object mobility in the Jini environment
Reduce the complexity of installation and configuration of complex Jini applications with mobile code
By Frank Sommers, JavaWorld.com, 01/05/01
Sir Thomas More, the English philosopher, published a book in 1516 about an imaginary island. Inhabitants of this distant
land lived the most ideal life imaginable: the citizens were educated, work was not overbearing and could still provide for
a good living, society and government were just, and equality and peace ruled. He named this island Utopia.
If Sir Thomas were to write in the present day, he surely would consider an ideal computing landscape for his island as well.
We can also surmise that he would seldom mention software installation, version upgrades, or system configuration. Fortunately,
we do not have to imagine a utopian world without these chores, because we can take advantage of technologies like Java, Jini,
and code mobility to create a more ideal computing environment here and now.
Alan Cooper, inventor of Visual Basic, mentioned in an online ITworld.com interview (see Resources) that the complexity of software installation and the capabilities of software are typically inversely proportional: the
more capable a software package, the more difficult its installation. Anyone who has ever set up an operating system or database-management
system would instantly agree with Cooper.
An important Jini promise is to disrupt this trend. As Jini architect Jim Waldo put it: "I dream of a world in which my children
will never have to use InstallShield." In a recent JavaWorldinterview (see Resources), Waldo referred to Java's ability to download code and objects on an as-needed basis from anywhere on the network.
Jini turns this capability into a practical benefit, providing a simple mechanism to locate objects on the network based on
their functionality and download them to a client. Once a client obtains a reference to an object, it can use that reference
to benefit from the object's functionality -- by calling methods on it, for instance. Anything that can be represented by
a Java object (which includes practically any device or legacy code as well as Java programs) on the network can participate
in a federation of such objects -- or services, as they are called in the Jini world.
To effectively use mobile objects, you must gain an understanding of how objects are located on the network, how they are
loaded into a running application and participate in the application's execution, and the techniques used to make the object's
class files available for downloading.
A class loader refresher
The Java Virtual Machine's (JVM) job is to execute Java bytecode. Bytecode is stored in Java classfiles, which are loaded
into the JVM via a class loader. Loading a class means locating a classfile that contains the desired type, based on the type's name, and then creating the
class from that file (see the Java Virtual Machine Specification, Chapter 5). Once a class is loaded into a VM, it is linked into the VM's execution state, which means that it becomes part of the program's
execution. Finally, the VM initializes the class by calling a special initialization method, which essentially corresponds
to static initialization of the class.
Resources
- Allen Holub talks with Alan Cooper in ITworld.com's Interviews forum
http://www.itworld.com/jump/jw-0105-jiniology/forums.itworld.com/webx?7@@.ee6cff8/2!skip=-22
- The Java Virtual Machine Specification, Second Edition, Chapter 5
http://java.sun.com/docs/books/vmspec/2nd-edition/html/ConstantPool.doc.html
- The Java Object Serialization Specification
http://java.sun.com/j2se/1.3/docs/guide/serialization/spec/serialTOC.doc.html
- The Java Remote Method Invocation Specification
http://java.sun.com/j2se/1.3/docs/guide/rmi/spec/rmiTOC.html
- Section 10.3.1 describes codebase annotation
http://java.sun.com/j2se/1.3/docs/guide/rmi/spec/rmi-protocol4.html
- Section 3.4 describes dynamic class loading
http://java.sun.com/j2se/1.3/docs/guide/rmi/spec/rmi-arch5.html
- Section 7.4.9 describes the
MarshalledObject class
http://java.sun.com/j2se/1.3/docs/guide/rmi/spec/rmi-activation5.html
- Section 7 describes activatable RMI objects
http://java.sun.com/j2se/1.3/docs/guide/rmi/spec/rmi-activation.html
- The Jini Architecture Specification, Version 1.1
http://www.sun.com/jini/specs/jini1.1html/jini-title.html
- Jini Technology Glossary
http://www.sun.com/jini/specs/jini1.1html/glossary-title.html
- The Jini Core Platform Specification
http://www.sun.com/jini/specs/jini1.1html/core-title.html
- The Jini Core Platform Specification, Section DJ2, explains discovery
http://www.sun.com/jini/specs/jini1.1html/discovery-spec.html#19702
- "Activatable Jini Services", Frank Sommers (JavaWorld, September 15, 2000)
http://www.javaworld.com/javaworld/jw-09-2000/jw-0915-jinirmi.html
- Gosling speaks about the important of knowing the semantic contract specified by a Java object in "An Interview with James
Gosling," Bill Venners (JavaWorld, June 6, 2000)
http://www.javaworld.com/javaworld/jw-06-2000/jw-0608-gosling.html
- "Jini Community Pattern Language" Richard P. Gabriel and Ron Goldman
http://jini.org/JiniCommunityPL.html
- "Sun Lets Jini Starter Kit 1.1 Out of the Bottle" (JavaWorld, December 8, 2000) -- Jini architect Jim Waldo talks to Frank Sommers about the importance of having the Java service interface
available to both client and service
http://www.javaworld.com/javaworld/jw-12-2000/jw-1208-waldo.html
- The Jini ServiceUI project home page
http://developer.jini.org/exchange/projects/serviceui
- Object-Oriented Software Construction, Second Edition, Bertrand Meyer (Prentice Hall, March 2000)
http://www.amazon.com/exec/obidos/ASIN/0136291554/o/qid=978025334/sr=2-1/104-2016221-1893530
- An electronic edition of Thomas More's Utopia: http://www.d-holliday.com/tmore/utopia.htm
- The Jini Printing working group homepage contains the printing APIs
http://developer.jini.org/exchange/users/jpgwg/
- "Dynamic Code Downloading Using RMI" -- an excellent short tutorial at the RMI homepage
http://java.sun.com/j2se/1.3/docs/guide/rmi/codebase.html
- Specifying the codebase requires the use of URLs. To learn about properly constructing URLs, see RFC 1738
http://www.rfc-editor.org/rfc/rfc1738.txt
- In addition, RFC 1808 describes the use of relative URLs
http://www.rfc-editor.org/rfc/rfc1808.txt
- Adrian Colley from Sun posted this message to the RMI mailing list on the use of URLs in codebase specifications
http://archives.java.sun.com/cgi-bin/wa?A2=ind0009&L=rmi-users&O=A&P=23120
- Bill Venners's Under the Hood series in JavaWorldprovides a wealth of information on the internals of the Java Virtual Machine, including class loading
http://www.javaworld.com/javaworld/topicalindex/jw-ti-hood.html
- You can also purchase Venners's book on the same topic, Inside the Java Virtual Machine:http://www.artima.com/insidejvm/blurb.html
- Complete listing of all previous Jiniology articles
http://www.javaworld.com/javaworld/topicalindex/jw-ti-jiniology.html
- Sign up for the JavaWorld This Week free weekly email newsletter and keep up with what's new at JavaWorld
http://www.idg.net/jw-subscribe
- Talk about Jini and other distributed Java services in JavaWorld's Java in the Enterprise discussion
http://www.itworld.com/jump/jw-0105-jiniology/forums.itworld.com/webx?14@@.ee6b80a