Java(tm) Agent Template, Version 0.3

Example 1: Basic agents and resource retrieval.


All JAT agents maintain both class and data resources using objects which are subclasses of JavaAgent.resource.Resource. Java class resources include languages (essentially protocol handlers, enable a message to be parsed and provide some high level semantics) and interpreters (essentially content handlers, provide a procedural specification of how a message, constructed according to a specific ontology, should be interpreted). (The interpreter is specified using the KQML "ontology" field). It is assumed that the implementation of each Interpreter class is based on some formal specification ("ontology") of the message semantics. One property of the JAT enables these resources to be dynamically exchanged between Agents in a "just-in-time" fashion (a subclass of Resource, RetrievalResource is utilized for this purpose). This allows an agent to correctly process a message, whose language and interpreter are both unknown, by dynamically acquiring the necessary Language and Interpreter classes. The following sequence of steps will illustrate this functionality. (Keep in mind that although these examples have all of the agents running on the same machine, the agents can theoretically run on any Internet host which is not inside a firewall.)


Perform the following steps:

  1. You need to have an ANS and at least two agents started. One agent will act as "Agent 1" and the other as "Agent 2" (regardless of their actual names).

    The standard agent GUI includes a menu bar and a text area for displaying system messages, each system message is also written to a log file (the log files are contained in the working directory for each Agent and are titled with a time stamp). The ANS, when created, will automatically bind a ServerSocket to the host/port listed in the init_file. Each Agent will bind a ServerSocket to either the user specified port or to an automatically determined port, after which the Agent will attempt to send a registration message to the ANS. If you have been successful, each Agent, including the ANS, will have received a single message from the init_file and each Agent will have sent one message to the ANS. You can look at the contents of the sent/received message buffers using the menu bar command "Message->View". Go ahead and check out the other commands, but if you decide to try the "Action->Quit" command, be prepared for the obvious consequences.

  2. Select the "View" command under the "Resource" menu of the ANS. You should see the addresses for the two Agents you started. You should also see the "KQML" language and the "agent" interpreter.
  3. Select the "Load" command under the "Resource" menu of Agent 1.
  4. Load the TestInterpreter interpreter. (Resource Name: test , Class/File Name: test.TestInterpreter, URL: <location of the classes directory>). Execution of this command will use the NetworkClassLoader to open an input stream to the TestInterpreter.class file, read in the byte codes and load the class into the current run time.
  5. Select the "Compose" command under the "Message" menu of Agent 1.
  6. Send the following message: performative: "evaluate", sender: will be filled-in automatically, receiver: Agent 2's name, language: "KQML", ontology: "test", content: "(test2)".
  7. A top-level window containing the label "Test 2" should appear.

Although this may seem like a very simple exercise, a somewhat complex series of synchronized transactions were necessary to implement this functionality. Here is what actually happened:


frost@cdr.stanford.edu