 |
One of the Java virtual machine's most powerful capabilities is the ability to load code from any network location. Yet, most Java applications load code from a local code base only, and never extend that codebase to the network during a program's execution. For instance, if your program's codebase is /home/mydir/myapp.jar, all the classes for your program load from that JAR file.
In addition to class or JAR files residing locally to a client application, an application can create its own classloader instances to load code from any network URL. For instance, an application's code might partially reside on http://myserver.com/myotherclasses.jar; When starting an application, that application can create a class loader capable of loading classes from http://myserver.com/myotherclasses.jar. As the application needs to create classes, both myapp.jar and myotherclasses.jar will be searched, downloading myotherclasses.jar from the network. All the classes in myotherclasses.jar load into the VM from the network - i..e, those classes represent network-mobile code.
Java applets build on network-mobile code: An HTML page specifying an applet designates a URL as the applet's code base, causing the applet container (Web browser) to download that code dynamically. However, mobile code is not limited to applets, and provides many advantages to developers and deployers/administrators of any type of Java application. Instead of having to deploy all of an application's code to clients, a system administrator might distribute only a small part of an application to users, and let that small application skeleton load classes dynamically as needed from the network. As developers add capabilities to that application (perhaps in an iterative fashion, following the tenets of agile development methodologies), the fresh and updated code downloads to all the users from the network. That reduces software administration efforts.
In the three cases just mentioned - the local-only codebase, the Java applets, and the Java app loading code from the network - an administrator or developer must know the network locations where code should download in advance of deploying an application. But what if you don't know those network locations in advance, and would like your app to determine at runtime where to load code from? Java object serialization enables that possibility. With object serialization, the codebase for a Java object is stamped onto that object's serialized byte stream as a String. The String contains a space-delimited list of URLs where code for the object should be loaded from. The Java serialization infrastructure creates the needed class loaders and loads the code from the annotated codebase. Java RMI builds on that codebase annotation mechanism to create an infrastructure for mobile objects.
I have spent nearly five years refining and optimizing a framework for distributed collaborative computing using RMI. After a lot of soul searching, I decided to make the culmination of my 20+ years of software development experience free. The site for this project is hosted here at java.net, it is called the cajo rel="nofollow" project. Like any distributed methodology, it becomes more powerful only by adoption.
I would greatly appreciate visitors, and comments. It's a little scary, it's my life's work (so far), I hope somebody likes it.
|