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:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler
-
Field Summary
Fields inherited from class lotus.domino.NotesThread
dummyObj, isLoaded
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addinCommand
(String command) This method is executed for every command entered at the Domino console, e.g.final void
addinInitialize
(JAddin mainThread, String args) This is the first method called by the main JAddin thread to initialize the JAddinThread.final boolean
Check if addin was interrupted by JAddin main thread.void
This method is called at the beginning of every new day.void
This method is called at the beginning of every hour.abstract void
This is the main entry point for the user add-in.abstract void
This method is executed when the command "Quit" or "Exit" is entered or during Domino server shutdown.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.final String
dbGetDocumentItem
(lotus.domino.Document document, String itemName) Get item in Domino document.final String
Return last error message from the dbXXXX methods.final lotus.domino.Session
Return the Domino session object.final lotus.domino.Document
dbGetSingleDocumentByKey
(lotus.domino.Database db, String viewName, String key) Get a single Domino document based on the passed key.final lotus.domino.Database
Open the Domino database.final boolean
dbRecycleObjects
(Object... dominoObjects) Recycle Domino object(s).final boolean
dbSaveDocument
(lotus.domino.Document document) Save the Domino document.final boolean
dbSendMessage
(String principal, String from, String to, String subject, String contentType, byte[] body) Create and send a message.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.final boolean
dbSetDocumentItem
(lotus.domino.Document document, String itemName, Object data) Set item in Domino document.final byte[]
decryptAES
(byte[] dataBuffer, byte[] secretKey) AES-128 decrypt the passed buffer with the passed secret key.final void
deleteDominoStatistic
(String statsName) Delete the Domino statistics show in response to 'Show Stat' command.final byte[]
encryptAES
(byte[] dataBuffer, byte[] secretKey) AES-128 encrypt the passed buffer with the passed secret key.final byte[]
fromBase64
(String data) Decode passed padded Base64 stringfinal byte[]
generateHash
(String hashType, byte[] buffer) Hash the passed byte arrayfinal String
Get the parameters passed to the add-in.final boolean
Get the debug statefinal boolean
isDbOpen
(lotus.domino.Database db) Check if Domino database is open.final boolean
Return live state of JAddin main thread .final void
Write debug message to the Domino console.final void
logMessage
(String message) Write a log message to the Domino console.final void
runNotes()
This method is called from the JAddin framework indirectly thru start().final void
setAddinState
(String message) Set the add-in status message text.final void
setDebugState
(boolean debugState) Set the debug statefinal void
setDominoStatistic
(String statsName, Double value) Set the Domino statistics show in response to 'Show Stat' command.final void
setDominoStatistic
(String statsName, String text) Set the Domino statistics show in response to 'Show Stat' command.final String
toBase64
(byte[] buffer) Encode passed buffer to padded Base64 stringfinal void
waitMilliSeconds
(long waitTime) Delay the execution of the threadMethods inherited from class lotus.domino.NotesThread
finalize, initThread, run, sDisablePerThreadTracking, sDisablePerThreadTracking, sDumpPerThreadInitTermStacks, sEnablePerThreadTracking, sEnablePerThreadTracking, sGetPerThreadCount, sGetPerThreadCount, sinitThread, stermThread, termThread
Methods inherited from class java.lang.Thread
activeCount, checkAccess, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, threadId, toString, yield
-
Constructor Details
-
JAddinThread
public JAddinThread()Dummy constructor
-
-
Method Details
-
addinCommand
This method is executed for every command entered at the Domino console, e.g."Tell AddinName xxxxxxxx"
.- Parameters:
command
- Passed command line
-
addinInitialize
-
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 databaseviewName
- Domino view namekey
- Key for lookup or null to return all documents- Returns:
- Documents (must use
dbRecycleObjects()
or null if error or empty
-
dbGetDocumentItem
-
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 databaseviewName
- Domino view namekey
- Lookup key- Returns:
- Domino document (must use
dbRecylceObjects()
) or null if error
-
dbOpen
Open the Domino database.- Parameters:
dbName
- Database name with path- Returns:
- Domino database object (must use
dbRecycleObject()
or null for errors
-
dbRecycleObjects
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 nullfrom
- Senders nameto
- Recipient namesubject
- SubjectcontentType
- 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 nullfrom
- Senders namereplyTo
- Reply address or nullto
- Recipient namecc
- Copy recipient or nullbcc
- Blind carbon copy recipient or nullsubject
- SubjectcontentType
- Content type of body, e.g. "text/html"body
- Body data- Returns:
- Success or failure indicator
-
dbSetDocumentItem
-
decryptAES
public final byte[] decryptAES(byte[] dataBuffer, byte[] secretKey) AES-128 decrypt the passed buffer with the passed secret key.- Parameters:
dataBuffer
- Clear text buffersecretKey
- Secret key for encryption- Returns:
- Encrypted buffer
-
deleteDominoStatistic
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 buffersecretKey
- Secret key for encryption- Returns:
- Encrypted buffer
-
fromBase64
Decode passed padded Base64 string- Parameters:
data
- Base64 string to decode- Returns:
- Decoded buffer
-
generateHash
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
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
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
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 classlotus.domino.NotesThread
-
setAddinState
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
-
setDominoStatistic
-
toBase64
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
-