Aglets is a java based mobile agent platform and library for building mobile agents based applications. An aglet is a Java agent which can autonomously and spontaneously move from one host to another carrying a piece of code with it. It can be programmed to execute at a remote host and show different behaviours at different hosts. Java based security implementations take care of authorised access to local resources at the remote hosts.
Aglets was originally developed by Mitsuro Oshima and Danny Lange at the IBM Tokyo Research Laboratory. The original name of the project was AWB (Aglets WorkBench) and IBM was responsible for most of the 1.x release. However the project is now hosted at SourceForge.net as an open source project, where it is distributed under the IBM Public License. In the beginning, the SourceForge releases had been only bug-fix ones, but 2.x series(most of which came from open source community only) had better security and thread management. It now includes a log4j based logging system and a few bug-fixes of the older versions.
Aglets is completely written in Java, thus allowing a high portability of both the agents and the platform. Aglets includes both a complete Java mobile agent platform, with a stand-alone server called Tahiti, and a library that allows developers to build mobile agents and to embed the Aglets technology in their applications.
Aglets versus applets
The Java aglet extends the model of network-mobile code made famous by Java applets. Like an applet, the class files for an aglet can migrate across a network. But unlike applets, when an aglet migrates it also carries its state. An applet is code that can move across a network from a server to a client. An aglet is a running Java program (code and state) that can move from one host to another on a network. In addition, because an aglet carries its state wherever it goes, it can travel sequentially to many destinations on a network, including eventually returning back to its original host.
A Java aglet is similar to an applet in that it runs as a thread (or multiple threads) inside the context of a host Java application. To run applets, a Web browser fires off a Java application to host any applets it may encounter as the user browses from page to page. That application installs a security manager to enforce restrictions on the activities of any untrusted applets. To download an applet’s class files, the application creates class loaders that know how to request class files from an HTTP server. Likewise, an aglet requires a host Java application, an “aglet host,” to be running on a computer before it can visit that computer. When aglets travel across a network, they migrate from one aglet host to another. Each aglet host installs a security manager to enforce restrictions on the activities of untrusted aglets. Hosts upload aglets through class loaders that know how to retrieve the class files and state of an aglet from a remote aglet host.
Launch Your First Aglet
Step 1: Using a Single Aglet Server
- Run an aglet server
- There is no default port.
- You must always specify the "-port" flag of the aglet server (we recommend using port numbers above 8000).
- Start the HelloAglet.
- In “Address” text field, type the URL of the current host in which the aglet server is running.
Make the script Aglets1.0/bin/agletsd in the aglets package executable by updating the path or changing its directory.
Use a command prompt window to run an aglet server:
|Run the First Aglet Server|
|Windows 95/NT||agletsdThis aglet server uses a default port (434) to listen for aglet requests.|
|Solaris AIX||agletsd -port 9000NOTICE:
This aglet server will invoke an aglet viewer, named Tahiti, for managing aglets. The first time Tahiti is invoked, you will be asked to register. Please do so. You can find out more about the Tahiti in Tahiti User’s Guide. Instead of using Tahiti, you can invoke a command line aglet viewer by adding the -commandline option as a parameter for agletsd script. (The “help” command allows you to get more information on the command line viewer.)
As a first attempt, use the HelloAglet to send a message to yourself. To run it, press Tahiti’s Create button to get the “Create Aglet” window. Use the mouse to select its class name “examples.hello.HelloAglet“, and press the Create button in this window. Then, the HelloAglet is created and its dialog window is displayed.
- Type your message in the “Message” text field.
- Press the Go button. Then, a new aglet will be created to carry the message and display it at the target host.
- The HelloAglet will return to the server it came from and display a message it shows “I’m back.” Then it will destroy itself within 2 seconds.
The message will disappear within 5 seconds.
Step 2: Using Multiple Aglet Servers
- Run two aglet servers
- Send messages between the two aglet servers
- In the “Which URL” field, type the URL of the host of the second aglet server. It should be of the form:
- Type your message in the “Message” text field.
- Press the Go button. Watch the second Tahiti window for a new line indicating that a new aglet, carrying the message, has arrived.
Start a second aglet server (with a second Tahiti), running simultaneously with the one you have already started:
|Run the Second Aglet Server|
|Windows 95/NT||agletsd -port 500|
|Solaris AIX||agletsd -port 10000|
Try the Writer aglet from your first aglet server again. This time, try to send the aglet with the message to the second aglet server.
Step 3: Using Remote Servers
- If possible, run aglet servers on remote machines and play with the HelloAglet.
Learning Sample Aglets
- Learn (and run) our other sample aglets by reading their documentation (program description and source code), which can be found here.
Other example and you can find here.