Project Wonder 5.0

er.javamail
Class ERMailSender

java.lang.Object
  extended by er.javamail.ERMailSender
All Implemented Interfaces:
java.lang.Runnable

public class ERMailSender
extends java.lang.Object
implements java.lang.Runnable

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 , Tatsuya Kawano , Max Muller

Nested Class Summary
static class ERMailSender.SizeOverflowException
          Exception class for alerting about a stack overflow
 class ERMailSender.Stats
          This class is about logging mail event for stats purposes.
 
Field Summary
static java.lang.String InvalidEmailNotification
           
 
Method Summary
protected  javax.mail.Transport _connectedTransportForSession(javax.mail.Session session, java.lang.String smtpProtocol, boolean _throwExceptionIfConnectionFails)
          Utility method that gets the SMTP Transport method for a session and connects the Transport before returning it.
protected  void _sendMessageNow(ERMessage message, javax.mail.Transport transport)
          Common method used by 'sendMessageNow' and 'sendMessageDeffered' (actully the 'run' method when the thread is running) to send a message.
 ERQueue<ERMessage> messages()
           
protected  void notifyInvalidEmails(com.webobjects.foundation.NSArray<java.lang.String> invalidEmails)
          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)
          Sends a message in a non-blocking way.
 void sendMessageNow(ERMessage message)
          Sends a message immediately.
static ERMailSender sharedMailSender()
           
 ERMailSender.Stats stats()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

InvalidEmailNotification

public static final java.lang.String InvalidEmailNotification
See Also:
Constant Field Values
Method Detail

sharedMailSender

public static ERMailSender sharedMailSender()
Returns:
the shared instance of the singleton ERMailSender object

stats

public ERMailSender.Stats stats()
Returns:
the stats associated with this ERMailSender object

sendMessageDeffered

public 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.

Throws:
ERMailSender.SizeOverflowException

sendMessageNow

public void sendMessageNow(ERMessage message)
Sends a message immediately. This means that the thread could be blocked if the message takes time to be delivered.


_sendMessageNow

protected void _sendMessageNow(ERMessage message,
                               javax.mail.Transport transport)
                        throws javax.mail.MessagingException
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.

Throws:
javax.mail.MessagingException

_connectedTransportForSession

protected javax.mail.Transport _connectedTransportForSession(javax.mail.Session session,
                                                             java.lang.String smtpProtocol,
                                                             boolean _throwExceptionIfConnectionFails)
                                                      throws javax.mail.MessagingException
Utility method that gets the SMTP Transport method for a session and connects the Transport before returning it.

Throws:
javax.mail.MessagingException

run

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

Specified by:
run in interface java.lang.Runnable

messages

public ERQueue<ERMessage> messages()

notifyInvalidEmails

protected void notifyInvalidEmails(com.webobjects.foundation.NSArray<java.lang.String> invalidEmails)
Executes the callback method to notify the calling application of any invalid emails.


Last updated: Tue, Feb 21, 2017 • 05:45 PM CET

Copyright © 2002 – 2007 Project Wonder.