例: remove method (Agent - Java™)

次のエージェントは、現在のデータベースの「Agent To Delete」という名前のエージェントを削除します。

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();
      Vector agents = db.getAgents();
      Enumeration e = db.getAgents().elements();
      String msg = "Agent not found";
      while (e.hasMoreElements()) {
        Agent agent = (Agent)e.nextElement();
        String name = agent.getName();
        if (name.compareTo("Agent To Delete") == 0){
          agent.remove();
          msg = "Agent found and deleted";
          break;
          }
        }
      System.out.println(msg);
    } catch(Exception e) {
      e.printStackTrace();
    }
  }
}