ERMailSender Class Reference

Collaboration diagram for ERMailSender:

Collaboration graph
[legend]

List of all members.

Classes

class  SizeOverflowException
class  Stats

Public Member Functions

ERQueue< ERMessagemessages ()
void run ()
void sendMessageDeffered (ERMessage message) throws ERMailSender.SizeOverflowException
void sendMessageNow (ERMessage message)
Stats stats ()

Static Public Member Functions

static synchronized ERMailSender sharedMailSender ()

Static Public Attributes

static final String InvalidEmailNotification = "InvalidEmailNotification"

Protected Member Functions

Transport _connectedTransportForSession (javax.mail.Session session, String smtpProtocol, boolean _throwExceptionIfConnectionFails) throws MessagingException
void _sendMessageNow (ERMessage message, Transport transport) throws MessagingException
void notifyInvalidEmails (NSArray< String > invalidEmails)

Static Package Attributes

static Logger log = Logger.getLogger(ERMailSender.class)

Private Member Functions

 ERMailSender ()

Private Attributes

ERQueue< ERMessage_messages
int _milliSecondsWaitRunLoop = 5000
Thread _senderThread
Stats _stats

Static Private Attributes

static ERMailSender _sharedMailSender


Detailed Description

This class is used to send mails in a threaded way.

This is needed in WebObjects because if sending 20 mails takes 40 seconds, then the user must wait 40 seconds before attempting to use the application.

Author:
Camille Troillard <tuscland@mac.com>

Tatsuya Kawano <tatsuyak@mac.com>

Max Muller <maxmuller@mac.com>


Constructor & Destructor Documentation

ERMailSender (  )  [private]


Member Function Documentation

Transport _connectedTransportForSession ( javax.mail.Session  session,
String  smtpProtocol,
boolean  _throwExceptionIfConnectionFails 
) throws MessagingException [protected]

Utility method that gets the SMTP Transport method for a session and connects the Transport before returning it.

void _sendMessageNow ( ERMessage  message,
Transport  transport 
) throws MessagingException [protected]

Common method used by 'sendMessageNow' and 'sendMessageDeffered' (actully the 'run' method when the thread is running) to send a message.

This method sends the message and increments the processed mail count. If an exception occurs while sending the mail, and if a callback object has been given, the notifyInvalidEmails method is called.
If a MessagingException is thrown, then the exception is catched and rethrown immediately, thus letting us to process another callbacks or not. For example, This is used when sendMessageNow is used, the MessagingException is encapsulated in a ERMailSender.ForwardException, and thrown to the user.

ERQueue<ERMessage> messages (  ) 

void notifyInvalidEmails ( NSArray< String invalidEmails  )  [protected]

Executes the callback method to notify the calling application of any invalid emails.

void run (  ) 

Don't call this method, this is the thread run loop and is automatically called.

void sendMessageDeffered ( ERMessage  message  )  throws ERMailSender.SizeOverflowException

Sends a message in a non-blocking way.

This means that the thread won't be blocked, but the message will be queued before being delivered.

void sendMessageNow ( ERMessage  message  ) 

Sends a message immediately.

This means that the thread could be blocked if the message takes time to be delivered.

static synchronized ERMailSender sharedMailSender (  )  [static]

Returns:
the shared instance of the singleton ERMailSender object

Stats stats (  ) 

Returns:
the stats associated with this ERMailSender object


Member Data Documentation

ERQueue<ERMessage> _messages [private]

int _milliSecondsWaitRunLoop = 5000 [private]

Thread _senderThread [private]

ERMailSender _sharedMailSender [static, private]

Stats _stats [private]

final String InvalidEmailNotification = "InvalidEmailNotification" [static]

Logger log = Logger.getLogger(ERMailSender.class) [static, package]


The documentation for this class was generated from the following file:

Generated on Sat May 26 06:43:22 2012 for Project Wonder by  doxygen 1.5.8