例: lock method (Form - Java™)

次のエージェントは、「Guys」グループのメンバー全員について「Main」という名のフォームをロックします。フォームがロックされていない場合、またはロックされているが有効なユーザーが Guys のメンバーに含まれている場合は、ロックに成功します。システム管理サーバーが使用できない場合は、暫定ロックが許可されます。

import lotus.domino.*;

public class JavaAgent extends AgentBase {

  public void NotesMain() {

    try {
      Session session = getSession();
      AgentContext agentContext = session.getAgentContext();

      // (Your code goes here) 
      Database db = agentContext.getCurrentDatabase();
      
      // Design locking must be enabled
      if (db.isDesignLockingEnabled()) {
        // Get form and lock
        // Not locked if return is false or exception thrown
        Form form = db.getForm("Main");
        if (form.lock("Guys", true))
          System.out.println("Form locked");
        else
          System.out.println("Form not locked");
      }
      else
        System.out.println("Design locking not enabled");

    } catch(NotesException e) {
      if (e.id == NotesError.NOTES_ERR_LOCKED)
        System.out.println("Form not locked (exception)");
      else
        e.printStackTrace();

    } catch(Exception e) {
      e.printStackTrace();
    }
  }
}