Class JAddinThread

java.lang.Object
java.lang.Thread
lotus.domino.NotesThread
JAddinThread
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
HelloWorld

public abstract class JAddinThread extends lotus.domino.NotesThread
This abstract class must be implemented by the user add-in. JAddinThread is started as an separate thread by JAddin. It establishes the JAddin user framework and calls the user code. The code running in this thread should avoid any long-running or blocking code to prohibit delays in processing of the IBM Domino message queue.
Author:
andy.brunner@k43.ch
See Also:
  • Constructor Details

    • JAddinThread

      public JAddinThread()
      Dummy constructor
  • Method Details

    • addinCommand

      public void addinCommand(String command)
      This method is executed for every command entered at the Domino console, e.g. "Tell AddinName xxxxxxxx".
      Parameters:
      command - Passed command line
    • addinInitialize

      public final void addinInitialize(JAddin mainThread, String args)
      This is the first method called by the main JAddin thread to initialize the JAddinThread.
      Parameters:
      mainThread - JAddin thread
      args - Passed arguments or null ("Load RunJava JAddin AddinName xxxxxxxx")
    • addinInterrupted

      public final boolean addinInterrupted()
      Check if addin was interrupted by JAddin main thread.
      Returns:
      True (of JAddin issued interrupt), false otherwise
    • addinNextDay

      public void addinNextDay()
      This method is called at the beginning of every new day.
    • addinNextHour

      public void addinNextHour()
      This method is called at the beginning of every hour.
    • addinStart

      public abstract void addinStart()
      This is the main entry point for the user add-in. It is called by JAddinThread after all initialization work is done.
    • addinStop

      public abstract void addinStop()
      This method is executed when the command "Quit" or "Exit" is entered or during Domino server shutdown. After this method returns, the add-in must terminate immediately.
    • dbGetAllDocuments

      public final Vector<lotus.domino.Document> dbGetAllDocuments(lotus.domino.Database db, String viewName, String key)
      Get all documents or documents matching a key from a view.
      Parameters:
      db - Domino database
      viewName - Domino view name
      key - Key for lookup or null to return all documents
      Returns:
      Documents (must use dbRecycleObjects() or null if error or empty
    • dbGetDocumentItem

      public final String dbGetDocumentItem(lotus.domino.Document document, String itemName)
      Get item in Domino document.
      Parameters:
      document - Domino document
      itemName - Domino item name
      Returns:
      Item value converted to string or null if error
    • dbGetLastErrorMessage

      public final String dbGetLastErrorMessage()
      Return last error message from the dbXXXX methods.
      Returns:
      String Error message
    • dbGetSession

      public final lotus.domino.Session dbGetSession()
      Return the Domino session object.
      Returns:
      Session Domino session object
    • dbGetSingleDocumentByKey

      public final lotus.domino.Document dbGetSingleDocumentByKey(lotus.domino.Database db, String viewName, String key)
      Get a single Domino document based on the passed key.
      Parameters:
      db - Domino database
      viewName - Domino view name
      key - Lookup key
      Returns:
      Domino document (must use dbRecylceObjects()) or null if error
    • dbOpen

      public final lotus.domino.Database dbOpen(String dbName)
      Open the Domino database.
      Parameters:
      dbName - Database name with path
      Returns:
      Domino database object (must use dbRecycleObject() or null for errors
    • dbRecycleObjects

      public final boolean dbRecycleObjects(Object... dominoObjects)
      Recycle Domino object(s).
      Parameters:
      dominoObjects - ... Domino object(s) to be recycled (supports arrays and Vectors)
      Returns:
      Indicator (Success or failure)
    • dbSaveDocument

      public final boolean dbSaveDocument(lotus.domino.Document document)
      Save the Domino document.
      Parameters:
      document - Domino document
      Returns:
      Indicator (success or failure)
    • dbSendMessage

      public final boolean dbSendMessage(String principal, String from, String to, String subject, String contentType, byte[] body)
      Create and send a message. If the message delivery fails, a message will be written to the Domino console.
      Parameters:
      principal - Principal name or null
      from - Senders name
      to - Recipient name
      subject - Subject
      contentType - Content type of body, e.g. "text/html"
      body - Body data
      Returns:
      Success or failure indicator
    • dbSendMessage

      public final boolean dbSendMessage(String principal, String from, String replyTo, String to, String cc, String bcc, String subject, String contentType, byte[] body)
      Create and send a message. If the message delivery fails, a message will be written to the Domino console.
      Parameters:
      principal - Principal name or null
      from - Senders name
      replyTo - Reply address or null
      to - Recipient name
      cc - Copy recipient or null
      bcc - Blind carbon copy recipient or null
      subject - Subject
      contentType - Content type of body, e.g. "text/html"
      body - Body data
      Returns:
      Success or failure indicator
    • dbSetDocumentItem

      public final boolean dbSetDocumentItem(lotus.domino.Document document, String itemName, Object data)
      Set item in Domino document.
      Parameters:
      document - Domino document
      itemName - Domino item name
      data - Item to be set
      Returns:
      Success or error
    • decryptAES

      public final byte[] decryptAES(byte[] dataBuffer, byte[] secretKey)
      AES-128 decrypt the passed buffer with the passed secret key.
      Parameters:
      dataBuffer - Clear text buffer
      secretKey - Secret key for encryption
      Returns:
      Encrypted buffer
    • deleteDominoStatistic

      public final void deleteDominoStatistic(String statsName)
      Delete the Domino statistics show in response to 'Show Stat' command.
      Parameters:
      statsName - Name of statistics
    • encryptAES

      public final byte[] encryptAES(byte[] dataBuffer, byte[] secretKey)
      AES-128 encrypt the passed buffer with the passed secret key.
      Parameters:
      dataBuffer - Clear text buffer
      secretKey - Secret key for encryption
      Returns:
      Encrypted buffer
    • fromBase64

      public final byte[] fromBase64(String data)
      Decode passed padded Base64 string
      Parameters:
      data - Base64 string to decode
      Returns:
      Decoded buffer
    • generateHash

      public final byte[] generateHash(String hashType, byte[] buffer)
      Hash the passed byte array
      Parameters:
      hashType - Hash type (MD5, SHA-1, SHA-256)
      buffer - Buffer to hash
      Returns:
      Hash code or empty byte array for errors
    • getAddinParameters

      public final String getAddinParameters()
      Get the parameters passed to the add-in.
      Returns:
      Arguments passed to this add-in or null
    • getDebugState

      public final boolean getDebugState()
      Get the debug state
      Returns:
      Status of debug logging
    • isDbOpen

      public final boolean isDbOpen(lotus.domino.Database db)
      Check if Domino database is open.
      Parameters:
      db - Domino database
      Returns:
      True if database is open, false otherwise
    • isJAddinAlive

      public final boolean isJAddinAlive()
      Return live state of JAddin main thread .
      Returns:
      Indicator if JAddin main thread is alive or not
    • logDebug

      public final void logDebug(String message)
      Write debug message to the Domino console. The message string will be prepended with the debugging information, e.g. "DEBUG: AddinName.MethodName(LineNumber) xxxxxxxx".
      Parameters:
      message - Message to be displayed
    • logMessage

      public final void logMessage(String message)
      Write a log message to the Domino console. The message string will be prepended with the add-in name followed by a column, e.g. "HelloWorld: xxxxxxxx"
      Parameters:
      message - Message to be displayed
    • runNotes

      public final void runNotes()
      This method is called from the JAddin framework indirectly thru start(). Its main purpose is to call the user code thru addinStart().
      Overrides:
      runNotes in class lotus.domino.NotesThread
    • setAddinState

      public final void setAddinState(String message)
      Set the add-in status message text. This text is shown in response to the Domino console command "show tasks".
      Parameters:
      message - Status message
    • setDebugState

      public final void setDebugState(boolean debugState)
      Set the debug state
      Parameters:
      debugState - Debug state
    • setDominoStatistic

      public final void setDominoStatistic(String statsName, Double value)
      Set the Domino statistics show in response to 'Show Stat' command.
      Parameters:
      statsName - Name of statistics
      value - Statistics value
    • setDominoStatistic

      public final void setDominoStatistic(String statsName, String text)
      Set the Domino statistics show in response to 'Show Stat' command.
      Parameters:
      statsName - Name of statistics
      text - Statistics text
    • toBase64

      public final String toBase64(byte[] buffer)
      Encode passed buffer to padded Base64 string
      Parameters:
      buffer - Buffer to convert
      Returns:
      Base64 encoded string in upper-case
    • waitMilliSeconds

      public final void waitMilliSeconds(long waitTime)
      Delay the execution of the thread
      Parameters:
      waitTime - Wait time in milliseconds