lumis.portal.sendmail
Class SendMailManager

Package class diagram package SendMailManager
java.lang.Object
  extended by lumis.portal.sendmail.SendMailManager
All Implemented Interfaces:
ISendMailManager

public class SendMailManager
extends Object
implements ISendMailManager

A implementation of the ISendMailManager interface.

Since:
4.0.4

Constructor Summary
SendMailManager()
           
 
Method Summary
 void addMailToSendQueue(SessionConfig sessionConfig, IMultipleMail mail, String queueId, ITransaction transaction)
          Adds an e-mail to the send queue.
 void addMailToSendQueue(SessionConfig sessionConfig, ISingleMail mail, String queueId, ITransaction transaction)
          Adds an e-mail to the send queue.
 IMailAttachment createMailAttachment()
          Factory method for creating a new mail attachment instance.
 IMailDestination createMailDestination()
          Factory method for creating a new mail destination instance.
 IMultipleMail createMultipleMail()
          Factory method for creating a new blank mail instance.
 ISingleMail createSingleMail()
          Factory method for creating a new blank mail instance.
 void deleteMail(SessionConfig sessionConfig, String mailId, ITransaction transaction)
          Deletes a mail and all its internal components (body, attachments, destinations).
 String generateNewQueueId()
          Returns a new generated queue id.
 IMailConfig getMailConfig(SessionConfig sessionConfig, ITransaction transaction)
          Returns the IMailConfig containing the configurations for sending e-mails.
protected  IMailSender getMailSender(SessionConfig sessionConfig, ITransaction transaction)
          Returns a new instance of the IMailSender to be used by this manager for sending e-mails.
 void pollMailQueueProcessing()
          Verifies the need to create another mail queue process thread, and create it if necessary.
 boolean processNextQueuedMail(String queueId)
          Gets the next queued mail and process it.
 void sendMail(SessionConfig sessionConfig, ISingleMail mail, ITransaction transaction)
          Sends an e-mail immediately.
 void setMailConfig(SessionConfig sessionConfig, IMailConfig mailConfig, ITransaction transaction)
          Sets the IMailConfig containing the configurations for sending e-mails.
 void threadTerminated(String queueId)
          Method called by the MailQueueProcessThread to indicate that it has terminated its processing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SendMailManager

public SendMailManager()
Method Detail

createMultipleMail

public IMultipleMail createMultipleMail()
                                 throws PortalException
Description copied from interface: ISendMailManager
Factory method for creating a new blank mail instance. Use this method to obtain an instance of IMultipleMail, to fill it with the required data and use it in the other methods in this manager.

Specified by:
createMultipleMail in interface ISendMailManager
Returns:
a new blank mail instance.
Throws:
PortalException
See Also:
ISendMailManager.createSingleMail(), ISendMailManager.createMailAttachment(), ISendMailManager.createMailDestination()

createSingleMail

public ISingleMail createSingleMail()
                             throws PortalException
Description copied from interface: ISendMailManager
Factory method for creating a new blank mail instance. Use this method to obtain an instance of ISingleMail, to fill it with the required data and use it in the other methods in this manager.

Specified by:
createSingleMail in interface ISendMailManager
Returns:
a new blank mail instance.
Throws:
PortalException
See Also:
ISendMailManager.createMultipleMail(), ISendMailManager.createMailAttachment()

createMailAttachment

public IMailAttachment createMailAttachment()
                                     throws PortalException
Description copied from interface: ISendMailManager
Factory method for creating a new mail attachment instance. Use this method to obtain an instance of IMailAttachment, to fill it with the required data and use it in the other methods in this manager.

Specified by:
createMailAttachment in interface ISendMailManager
Returns:
a new mail attachment instance.
Throws:
PortalException
See Also:
ISendMailManager.createSingleMail(), ISendMailManager.createMultipleMail(), IMailBody.getAttachments()

createMailDestination

public IMailDestination createMailDestination()
                                       throws PortalException
Description copied from interface: ISendMailManager
Factory method for creating a new mail destination instance. Use this method to obtain an instance of IMailDestination, to fill it with the required data and use it in the other methods in this manager.

Specified by:
createMailDestination in interface ISendMailManager
Returns:
a new mail destination instance.
Throws:
PortalException
See Also:
ISendMailManager.createMultipleMail(), IMultipleMail.getDestinations()

generateNewQueueId

public String generateNewQueueId()
                          throws PortalException
Description copied from interface: ISendMailManager
Returns a new generated queue id.

Specified by:
generateNewQueueId in interface ISendMailManager
Returns:
a new generated queue id.
Throws:
PortalException - if the queue id could not be generated.

getMailConfig

public IMailConfig getMailConfig(SessionConfig sessionConfig,
                                 ITransaction transaction)
                          throws PortalException
Description copied from interface: ISendMailManager
Returns the IMailConfig containing the configurations for sending e-mails.

Specified by:
getMailConfig in interface ISendMailManager
Parameters:
sessionConfig - the user session information.
transaction - the transaction for persistence access.
Returns:
the IMailConfig, never null.
Throws:
PortalException - if it was not possible to obtain the IMailConfig.

setMailConfig

public void setMailConfig(SessionConfig sessionConfig,
                          IMailConfig mailConfig,
                          ITransaction transaction)
                   throws PortalException
Description copied from interface: ISendMailManager
Sets the IMailConfig containing the configurations for sending e-mails.

Specified by:
setMailConfig in interface ISendMailManager
Parameters:
sessionConfig - the user session information.
mailConfig - the IMailConfig.
transaction - the transaction for persistence access.
Throws:
PortalException - if it was not possible to set the IMailConfig.
See Also:
#getMailConfig(ITransaction)

getMailSender

protected IMailSender getMailSender(SessionConfig sessionConfig,
                                    ITransaction transaction)
                             throws PortalException
Returns a new instance of the IMailSender to be used by this manager for sending e-mails.

Parameters:
sessionConfig - user session information.
transaction - transaction for persistence access.
Returns:
a new mail sender instance.
Throws:
PortalException
Since:
4.0.4

sendMail

public void sendMail(SessionConfig sessionConfig,
                     ISingleMail mail,
                     ITransaction transaction)
              throws PortalException
Description copied from interface: ISendMailManager
Sends an e-mail immediately. This method does not garantee rollback of the e-mail sending as a result of the transaction rollback.

Specified by:
sendMail in interface ISendMailManager
Parameters:
sessionConfig - the user session information.
mail - information about the e-mail to be sent.
transaction - the transaction for persistence access.
Throws:
PortalException - if it was not possible to send the e-mail.
See Also:
ISendMailManager.createSingleMail()

addMailToSendQueue

public void addMailToSendQueue(SessionConfig sessionConfig,
                               ISingleMail mail,
                               String queueId,
                               ITransaction transaction)
                        throws PortalException
Description copied from interface: ISendMailManager
Adds an e-mail to the send queue. The queue is processed in the background and the e-mail will be sent when it is processed.

Specified by:
addMailToSendQueue in interface ISendMailManager
Parameters:
sessionConfig - the user session information.
mail - information about the e-mail to be sent.
queueId - the id of the queue where the mail will be added to. If null a new queue will be generated. To generate a new queueId use ISendMailManager.generateNewQueueId().
transaction - the transaction for persistence access. If the transaction rollbacks the e-mail will not be added to the queue and not sent.
Throws:
PortalException - if it was not possible to queue the the e-mail.
See Also:
ISendMailManager.createSingleMail()

addMailToSendQueue

public void addMailToSendQueue(SessionConfig sessionConfig,
                               IMultipleMail mail,
                               String queueId,
                               ITransaction transaction)
                        throws PortalException
Description copied from interface: ISendMailManager
Adds an e-mail to the send queue. The queue is processed in the background and the e-mail will be sent when it is processed.

Specified by:
addMailToSendQueue in interface ISendMailManager
Parameters:
sessionConfig - the user session information.
mail - information about the e-mail to be sent.
queueId - the id of the queue where the mail will be added to. If null a new queue will be generated. To generate a new queueId use ISendMailManager.generateNewQueueId().
transaction - the transaction for persistence access. If the transaction rollbacks the e-mail will not be added to the queue and not sent.
Throws:
PortalException - if it was not possible to queue the e-mail.
See Also:
ISendMailManager.createMultipleMail()

processNextQueuedMail

public boolean processNextQueuedMail(String queueId)
                              throws PortalException
Gets the next queued mail and process it.

Parameters:
queueId - the id of the mail queue to be processed.
Returns:
true if there was a mail to process, false if there was no mail in the queue to process.
Throws:
PortalException - if it was not possible to process the mail queue.

threadTerminated

public void threadTerminated(String queueId)
Method called by the MailQueueProcessThread to indicate that it has terminated its processing.

Parameters:
queueId - the id of the mail queue the thread was responsible to process.

pollMailQueueProcessing

public void pollMailQueueProcessing()
                             throws PortalException
Description copied from interface: ISendMailManager
Verifies the need to create another mail queue process thread, and create it if necessary. This method is called at regular intervals by the portal framework to give the manager the opportunity to span processing threads.

Specified by:
pollMailQueueProcessing in interface ISendMailManager
Throws:
PortalException - if it was not possible to complete the operation.

deleteMail

public void deleteMail(SessionConfig sessionConfig,
                       String mailId,
                       ITransaction transaction)
                throws PortalException
Description copied from interface: ISendMailManager
Deletes a mail and all its internal components (body, attachments, destinations).

Specified by:
deleteMail in interface ISendMailManager
Parameters:
sessionConfig - the user session information.
mailId - the mail's id.
transaction - the transaction for persistence access.
Throws:
PortalException - if it was not possible to delete the mail.


Lumisportal  4.1.0.071221 - Copyright © 2001-2007, Lumis. All Rights Reserved.