Sample: Intro Agent Using the Domino AgentRunner

Objective
The objective of this sample is to demonstrate how to use the AgentRunner.

Time Required
You should allow 20 minutes to build and run this sample.

Before You Begin
To build and run this sample you need to have Notes 4.6 or higher installed.

Set up your Workbench for using the samples by following the steps in the Domino Samples Overview.

Set up your Lotus Notes and VisualAge for Java environments to support the Domino AgentRunner by following the steps in the task file Setting up for the AgentRunner and return to this sample.

Description
This sample is a simple agent that will tell you the title of the database on which the agent is running.

Running the Sample
Once you have set up your Lotus Notes and VisualAge for Java environments you have to:

  1. Export your class file to the file system.
  2. Create and run the agent in notes to create an AgentContext document.
  3. Return to the AgentRunner to run and debug the agent.

1. Export the .class File
To export the .class file from the com.ibm.ivj.examples.intro package in VisualAge for Java to the file system so it can be read by Notes:

  1. Open the IBM Domino Examples project in the Workbench and expand the com.ibm.ivj.examples.domino.intro package. 
  2. Click the Intro class with mouse button 2.
  3. Select Export.  The Export SmartGuide will open.
  4. Select the Directory radio button as your export destination.  Click Next.
  5. In the Directory text field, enter a location in the file system where you want to export the .class file.
  6. Select the .class checkbox and click Details
  7. Select the IBM Domino Examples and the Intro::com.ibm.ivj.examples.domino.intro checkboxes.  Click OK.
  8. Deselect the .java and resource checkboxes if they are selected.
  9. Click Finish.

When you export files to the file system, the directory path of the file is maintained.   For example, if you entered X:\VAJexport as your export destination, the Intro.class file will be in X:\VAJexport\com\ibm\ivj\examples\domino\intro.

2. Create the Agent in Notes
For the AgentRunner to work in the IDE you have to provide it with a context for running your agent.  To create an AgentContext document:

  1. Open any database
  2. From the Create menu, select Agent.
  3. Enter a name for your agent, such as MyIntro.
  4. Select Manually From Actions Menu for When should this agent run.
  5. Select All documents in database for Which document(s) should it act on.
  6. Select the Java radio button for What should this agent run.
  7. Click the Import Class Files button.
  8. Locate and select the Intro.class file that you exported from VisualAge for Java and click Add.
  9. Click OK.
  10. Press the Esc key to close the Create Agent window.  You will be asked if you want to save your changes.  Click Yes.

Running the Agent in Notes
From the Actions menu of the Domino database, select MyIntro.  The agent will run but the session will return Null. An AgentContext document will be created in the AgentRunner.nsf

3. Using the AgentRunner
Now you are ready to run the agent in the AgentRunner.

To run your agent from the Workbench:

  1. Open the Console window by selecting Window - Console.  This window will show the status of your agent.
  2. Select the Intro class with mouse button 2.
  3. Select Tools - Domino AgentRunner - Run.

The Domino AgentRunner will run your agent using the AgentContext document that you created in Notes.  The Console will give you a message that the Intro Agent is running.  When it has run against your Notes database, it will return the title of the database in which you created the agent in Notes.