IBM Agent Building Environment Developer's Toolkit


Chapter 10. Adding an Agent to Your Application

Note: This section is still under construction (incomplete). In the meantime, please refer to Chapter 3. "Agent Server Sample" while illustrates in quite a bit of detail how to build your own agent program (in a multi-client server environment.

The section "Writing Your Own Agent Program" introduces the topic of writing your own agent program. That section has much in common with this section, adding an agent program to your application. In fact this section is a little redundant with that section but this section will be eventually expanded to include a more comprehensive tutorial for marrying your application with an agent program. The purpose of "Writing Your Own Agent Program" is to put writing your own agent in context with using the sample agents and to introduce the basic tasks that are needed for any agent program (yours or the samples).

You add an agent to your application by creating an agent class that inherits from the IAAgent class of the IBM Agent Building Environment Developer's Toolkit, and invoking methods on that class to configure and control the agent. Sample agent programs, iagent for C++ and ibm.AgentBuilder.samples.agent.JavaAgent for Java are provided for reference. See Chapter 6. "Building and Starting Your Agent" for more information on the sample agent.

Note that the sample agent has the option to be run as a background program (a "daemon"). If your application supplies a configuration file and then starts the agent program with the -d option, the agent will be configured and executed on a background thread to your program.

Compiling and Linking Your Application with IAAgent

The IAAgent interfaces used by your application to control the agent are described in Chapter 2. "Agent Reference" of the Components and Adapter Reference book. Refer to Chapter 1. "Building ABE-Related Components" for assistance in compiling and linking with the IAAgent and associated classes.

Using IAAgent to Create an Agent

To create an agent object, you must create a class that inherits from the IAAgent class. Refer to Chapter 2. "Agent Reference" of the Components and Adapter Reference book for details on the IAAgent class, including descriptions of its member functions. There are several operations that you must do to the agent. First, you must configure the agent with the components that you desire (engine, adapters ...). Once the agent is configured, then it can be started. After the agent is started, it is able to handle events from the adapters. Finally, once you are done with the agent, you must stop it. Those operations are discussed in the next sections.

Configuring Your Agent

After the agent object is created, you need to use the IAAgent member functions to configure the different parts of the agent (the library, the engine, the adapters and so on). Here are the configuration requirements that your agent object must satisfy to configure a fully functional agent.

Starting Your Agent

After the agent has been configured, use the start() member function of IAAgent to start the agent. As part of start() processing, the agent will cause the "AGENT:CONFIG" and "AGENT:STARTING" events to be inferenced on all loaded conduct sets. After inferencing on those events have completed, all the adapters in your agent are free to use notify() to pass other events to the agent for processing.

Stopping the agent

When you want to stop your agent, use the stop() member function of the IAAgent object. As part of the stopping process, the agent will call the stop() member function of each component in the agent.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]