ejel
Class SenderThread

java.lang.Object
  extended by java.lang.Thread
      extended by ejel.SenderThread
All Implemented Interfaces:
java.lang.Runnable

public class SenderThread
extends java.lang.Thread

A dedicated thread for sending incoming emails from the sender engine


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
SenderThread()
          SenderThread default constructor
 
Method Summary
 void exitThread()
          This will terminate the thread loop and finish it
 Attachment[] getAttachments()
          Get the Attachment array representing attached files to the current email
 boolean getDebug()
          Get the current debug flag of the SenderThread object
 Email getEmail()
          Get the Email object used to send the current email
 EmailAccount getEmailAccount()
          Get the EmailAccount object used to send the current email
 java.lang.Exception getException()
          Get the exception object occured while sending the current email or null on success
 Recipient[] getRecipients()
          Get the Recipient array representing the recipients of the current email
 SenderEngine.RecipientsType getRecipientsType()
          Gets the recipients type of the emails to be sent
 java.lang.Boolean isBusy()
          true if the SenderThread is busy because it's sending now an email
 boolean isChecked()
           
 boolean isFinished()
          Returns true if the internal loop thread is finished
 java.lang.Boolean isReady()
          true if the SenderThread is ready to send the next email, false if not
 java.lang.Boolean isSuccess()
          true if the current email was sent, false if an exception occured.
 void run()
          The internal thread loop for sending emails
 void sendEmail(EmailAccount server, Recipient[] rcpts, Email email, Attachment[] atchmnts)
          Enqueue a new email objects to be sent by the internal thread loop
 void sendEmailAgain()
          Try to send the same email again after an exception
 void setChecked()
           
 void setDebug(boolean dbg)
          Set or unset the debug flag of the object.
 void setRecipientsType(SenderEngine.RecipientsType rcptsType)
          Sets the recipients type of the emails to be sent
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SenderThread

public SenderThread()
SenderThread default constructor

Method Detail

isChecked

public boolean isChecked()

setChecked

public void setChecked()

setRecipientsType

public void setRecipientsType(SenderEngine.RecipientsType rcptsType)
Sets the recipients type of the emails to be sent

Parameters:
rcptsType - Type of the recipients TO, CC or BCC

getRecipientsType

public SenderEngine.RecipientsType getRecipientsType()
Gets the recipients type of the emails to be sent

Returns:
the recipients type of the emails to be sent

isFinished

public boolean isFinished()
Returns true if the internal loop thread is finished

Returns:
true if the internal loop thread is finished

setDebug

public void setDebug(boolean dbg)
Set or unset the debug flag of the object.

Parameters:
dbg - If set to true, SenderThread will print debug information

getDebug

public boolean getDebug()
Get the current debug flag of the SenderThread object

Returns:
true if the object is in debug mode, false if it's not.

sendEmail

public void sendEmail(EmailAccount server,
                      Recipient[] rcpts,
                      Email email,
                      Attachment[] atchmnts)
               throws java.lang.IllegalArgumentException
Enqueue a new email objects to be sent by the internal thread loop

Parameters:
server - The email account to be used to send the email
rcpts - The Recipient array of recipients email addresses
email - The email object representing the email to send
atchmnts - The Attachment array of the email attached files
Throws:
java.lang.IllegalArgumentException

sendEmailAgain

public void sendEmailAgain()
Try to send the same email again after an exception


run

public void run()
The internal thread loop for sending emails

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

exitThread

public void exitThread()
This will terminate the thread loop and finish it


getEmail

public Email getEmail()
Get the Email object used to send the current email

Returns:
The current Email object

getEmailAccount

public EmailAccount getEmailAccount()
Get the EmailAccount object used to send the current email

Returns:
The EmailAccount object used to send the current email

getRecipients

public Recipient[] getRecipients()
Get the Recipient array representing the recipients of the current email

Returns:
The Recipient array representing the recipients of the current email

getAttachments

public Attachment[] getAttachments()
Get the Attachment array representing attached files to the current email

Returns:
The Attachment array representing attached files to the current email

isSuccess

public java.lang.Boolean isSuccess()
true if the current email was sent, false if an exception occured.

Returns:
true if the current email was sent, false if an exception occured.

getException

public java.lang.Exception getException()
Get the exception object occured while sending the current email or null on success

Returns:
The exception object occured while sending the current email or null on success

isReady

public java.lang.Boolean isReady()
true if the SenderThread is ready to send the next email, false if not

Returns:
true if the SenderThread is ready to send the next email, false if not

isBusy

public java.lang.Boolean isBusy()
true if the SenderThread is busy because it's sending now an email

Returns:
true if the SenderThread is busy because it's sending now an email