Accessing agents using Java

Two classes provide access to agents: AgentContext and Agent.

AgentContext

The AgentContext class provides a means to access attributes of the current agent environment for programs that are running as agents. Call getAgentContext in Session to get the current agent context; getAgentContext returns null if the program is not running as an agent.

The following methods access the AgentContext properties:

  • getCurrentAgent returns an Agent object representing the current agent.
  • getCurrentDatabase returns a Database object representing the database containing the current agent.
  • getDocumentContext returns a Document object representing the in-memory document when the agent starts.
  • getEffectiveUserName returns a String value containing the user name that is in effect for the agent.
  • getLastExitStatus returns an int value containing the exit status for the last time the agent ran.
  • getLastRun returns a DateTime object representing the last time the agent ran.
  • getSavedData returns a Document object representing information stored between invocations of the agent.
  • getUnprocessedDocuments returns a DocumentCollection object representing the documents in the database that the agent considers "unprocessed."

The unprocessedFTSearch, unprocessedFTSearchRange, and unprocessedSearch methods return DocumentCollection objects representing "unprocessed" documents that meet search criteria. The updateProcessedDoc method marks documents as "processed" for future searches for new and modified documents.

Agent

The Agent class represents an agent. You can access the current agent through getCurrentAgent in AgentContex. You can access all agents in a database through getAgents in Database. You can access a specified agent through getAgent in Database.

The following methods access the Agent properties:

  • getComment returns a String value containing the comment associated with the agent.
  • getCommonOwner returns a String value containing the common name of the user who last modified the agent.
  • getHttpURL returns a String value containing the Domino® URL of the agent when HTTP protocols are in effect.

  • getLastRun returns a DateTime object representing the last time the agent ran.
  • getName returns a String value containing the name of the agent.
  • getNotesURL returns a String value containing the Domino® URL of the agent when Notes® protocols are in effect.

  • getOnBehalfOf property returns a String value containing the name of the user under whose identity the agent runs.

  • getOwner returns a String value containing the name of the person who last modified the agent.
  • getParameterDocID returns the NoteID of a document passed in by run or runOnServer.
  • getParent returns a Database object representing the database that contains the agent.
  • getQuery returns a String value containing the query used by the agent to select documents.
  • getServerName returns a String value containing the name of the server on which the agent runs; setServerName sets the server name to a string value (including * for all servers).
  • getTarget returns an int value defining what documents the agent runs on.
  • getTrigger returns an int value defining when the agent runs.
  • isActivatable returns true if user activation is in effect for enabling the agent.

  • isEnabled returns true if the agent is enabled; setEnabled enables (true) or disables (false) a scheduled agent.
  • isNotesAgent returns true if the agent can be activated from a Notes® client.
  • isPublic returns true if the agent is public.
  • isWebAgent returns true if the agent can be activated from a browser.

The Agent class contains a remove method to remove the agent from the database; a run method to run the agent on the computer running the program; a runOnServer method to run the agent on the computer containing the agent's database; and a save method to save changes made by setServerName and setEnabled.