Examples: Target and Trigger properties
This agent prints the target and trigger of each agent in the current database.
import lotus.domino.*;
import java.util.*;
public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext =
session.getAgentContext();
// (Your code goes here)
Database db = agentContext.getCurrentDatabase();
Enumeration agents = db.getAgents().elements();
while (agents.hasMoreElements())
{
Agent agent = (Agent)agents.nextElement();
String target="", trigger="";
switch (agent.getTarget()) {
case Agent.TARGET_ALL_DOCS:
target = "all documents";
case Agent.TARGET_ALL_DOCS_IN_VIEW:
target = "all documents in view";
case Agent.TARGET_NEW_DOCS:
target = "all new documents";
case Agent.TARGET_NEW_OR_MODIFIED_DOCS:
target = "all new or modified documents";
case Agent.TARGET_NONE:
target = "none";
case Agent.TARGET_SELECTED_DOCS:
target = "selected documents";
case Agent.TARGET_UNREAD_DOCS_IN_VIEW:
target = "unread documents in view"; }
switch (agent.getTrigger()) {
case Agent.TRIGGER_AFTER_MAIL_DELIVERY:
trigger = "after mail delivery";
case Agent.TRIGGER_BEFORE_MAIL_DELIVERY:
trigger = "before new mail";
case Agent.TRIGGER_DOC_PASTED:
trigger = "document pasted";
case Agent.TRIGGER_DOC_UPDATE:
trigger = "document updated";
case Agent.TRIGGER_SERVERSTART:
trigger = "when server starts";
case Agent.TRIGGER_MANUAL:
trigger = "manual";
case Agent.TRIGGER_NONE:
trigger = "none";
case Agent.TRIGGER_SCHEDULED:
trigger = "scheduled"; }
System.out.println(agent.getName() +
": target is " + target +
"; trigger is " + trigger);
} } catch(Exception e) {
e.printStackTrace();
}
}
}