Agents on the move
Bolster your client apps by adding agent mobility
By Todd Sundsted, JavaWorld.com, 07/01/98
Last month we delved into the world of agents. We learned what they are and what problems they solve. We also developed the
foundation for a simple agent architecture in Java. I promised that we'd build on that foundation in the coming months, and
here I am, making good on that promise.
Recall that agents typically possess one or more of the following characteristics; they can be:
- Autonomous
- Adaptive/learning
- Mobile
- Persistent
- Goal oriented
- Communicative/collaborative
- Flexible
- Active/proactive
We've got a lot of ground to cover, so we'd best get started. We're going to start our agent adventure with an up-close look
at agent mobility. Agent mobility provides a good starting point because the problems associated with mobile (and potentially
untrustworthy) code are well-known, and robust solutions are readily available. In addition, Java (via remote method invocation
-- or RMI -- and object serialization) provides prefabricated tools that make the job of moving objects easier.
Location, location, location
To better understand mobile agents and their behavior, we must first look briefly at traditional network architectures. The
following figure illustrates the network behavior of a typical client/server application.

The typical client/server application communicates via requests and responses, which require a round trip trek across the
network.
A client/server application typically consists of two pieces: a client piece and a server piece. Often, the client and server
pieces are on separate machines and they communicate over a common network. When the client needs data or access to resources
that the server provides, the client sends a request to the server over the network. The server in turn sends a response to
the request. This "handshake" occurs again and again in a traditional client/server architecture. Each request/response requires
a complete round trip across the network.
Now compare the client/server architecture I just described to the mobile agent architecture illustrated in the next figure.

In the mobile agent architecture, the client actually migrates to the server to make a request directly, rather than over
the network.
Just as in the client/server architecture, there is a client piece and a server piece. The difference lies in how the two
communicate. When the client in the mobile agent architecture needs data or access to a resource that the server provides,
the client doesn't talk to the server over the network. Instead, the client actually migrates to the server's machine. Once
on the server's machine, the client makes its requests of the server directly. When the entire transaction is complete, the
mobile agent returns home with the results.
A mobile agent's travel habits
One distinguishing characteristic of a mobile agent architecture is (surprise, surprise) the mobility of the code. However,
while this characteristic is necessary, it alone is not sufficient. That's because the idea of moving code and computation
to the location of the data and resources is not unique to the mobile agent architecture. In fact, such mobility has been
a feature of many commercial databases for some time. In the database world, mobile code goes by the name of a stored procedure. A stored procedure is a piece of client code that executes on the server. In some applications, the client piece of the
application can dynamically upload stored procedures to the server. Once there, they can do their work and return the results
of their calculations back to the client.
Resources
- Find out all you can on remote method invocation including a tutorial, the specification, the API reference, tools, and release
notes from Sun's RMI Web page http://www.javasoft.com/products/jdk/1.1/docs/guide/rmi/index.html
- Get complete information on object serialization, including the specification, the API reference, tools, and release notes
from Sun's Object Serialization Web page http://www.javasoft.com/products/jdk/1.1/docs/guide/serialization/index.html
- Cetus Links provides gobs of information on mobile agents http://www.cetus-links.org/oo_mobile_agents.html
- The Distributed Systems Group (Technical University of Vienna) includes an interesting look at mobile code, agents, and Java
http://www.infosys.tuwien.ac.at/Research/Agents/
- Check out the Centre for Advanced Learning Technologies' Information TechnologiesAgent Technologies page for everything related
to agent technology http://www.insead.fr/CALT/Encyclopedia/ComputerSciences/Agents/
- IBM Aglets SDK (formerly Aglets Workbench) is an environment for programming mobile Internet agents in Java http://www.trl.ibm.co.jp/aglets/
- Mitsubishi's Concordia is a framework for development and management of network-efficient mobile agent applications http://www.meitca.com/HSL/Projects/Concordia/
- JATLite is a package of programs written in Java that allow users to quickly create new software agents that communicate robustly
over the Internet http://java.stanford.edu/
- Previous How-To Java articles
- "An introduction to agents" Find out what agents are and what they can do for us, and take the first steps toward building your own simple agent architecture
in Java.
- "Unfurling Java's data transfer API" Learn to share data among applications with Java's data transfer classes.
- "MVC meets Swing" Explore the underpinnings of the JFC's Swing components.
- "Put your user interface on a diet" Replace those heavyweight components with leaner, meaner lightweight components.
- "Internationalize dynamic messages" Build flexible formatters for international applications with Java 1.1.
- "Localize this!" Use resource bundles to make your applications multicultural.
- "Write world-class applications" From Chicago to Copenhagen, Colombia to Cameroon -- Java provides the tools for writing truly international applications.
- "Use the two "R"s of Java 1.1 -- Readers and Writers" Learn how to use the two new additions to the
java.io package -- class Reader and class Writer -- to filter out unwanted e-mail.
- "Waging war on electronic junk mail" Put Java on the front line in the war against electronic junk mail.
- "Build dynamically extensible applications" Find out how to build programs that you can extend dynamically -- even while they execute.
- "3D computer graphicsGetting the hang of VRML" Learn about VRML and how you can use it to define your own virtual world.
- "3D computer graphicsMoving from wire-frame drawings to solid, shaded models" Find out how to create surfaces and add illumination to make your models more realistic.
- "3D computer graphicsSlide it, spin it, make it move -- transforming your virtual world" Learn how to make your virtual world satisfy even the toughest customer.
- "3D computer graphicsModel your world" From its start as an exotic research topic in government and university labs, virtual reality is making its move into the
mainstream of corporate America -- find out how you can gain entry into this elite club.
- "When static images just don't make the cut" Learn how to spice up your applets and applications with animated images.
- "How Java uses the the producer/consumer model to handle images -- An insider's look" Learn more about Java's powerful image-handling technique, then follow my simple procedures for building your own producer
and consumer components.
- "Learn how applets load network-based images asynchronously" Here's a close look at the way Java applets handle images in a network-based environment.
- "Drawing text is easy with three Java classes" Find out how to create text that's visually appealing through this explanation of what classes to use and how they work
together.
- "Examining HotSpot, an object-oriented drawing program" Learn how the pieces of the Java language and class library fit together through a study of this Java program
- "Using the Graphics class" A close look at the Graphics class and the drawing primitives it provides, and a demonstration of its use.
- "Observer and Observable" An introduction to the Observer interface and Observable class using the Model/View/Controller architecture as a guide.
- "The effective user interface" Five ways to enhance the appearance and effectiveness of your user interface
- "Java and event handling" How events are passed to user interface components, how to create event handlers, and more.
- "Introduction to the AWT" A description of Java's user interface toolkit.