Package lumis.portal.sendmail
Class SendMailManager
- java.lang.Object
-
- lumis.portal.sendmail.SendMailManager
-
- All Implemented Interfaces:
ISendMailManager
public class SendMailManager extends java.lang.Object implements ISendMailManager
A implementation of theISendMailManager
interface.- Since:
- 4.0.4
- Version:
- $Revision$ $Date$
-
-
Constructor Summary
Constructors Constructor Description SendMailManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addMailToSendQueue(SessionConfig sessionConfig, IMultipleMail mail, java.lang.String queueId, ITransaction transaction)
Adds an e-mail to the send queue.void
addMailToSendQueue(SessionConfig sessionConfig, ISingleMail mail, java.lang.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, java.lang.String mailId, ITransaction transaction)
Deletes a mail and all its internal components (body, attachments, destinations).void
deleteMailDestination(SessionConfig sessionConfig, java.lang.String mailDestinationId, ITransaction transaction)
Deletes a mail destination.java.lang.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 theIMailSender
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(java.lang.String queueId)
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(java.lang.String queueId)
-
-
-
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 ofIMultipleMail
, to fill it with the required data and use it in the other methods in this manager.- Specified by:
createMultipleMail
in interfaceISendMailManager
- 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 ofISingleMail
, to fill it with the required data and use it in the other methods in this manager.- Specified by:
createSingleMail
in interfaceISendMailManager
- 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 ofIMailAttachment
, to fill it with the required data and use it in the other methods in this manager.- Specified by:
createMailAttachment
in interfaceISendMailManager
- 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 ofIMailDestination
, to fill it with the required data and use it in the other methods in this manager.- Specified by:
createMailDestination
in interfaceISendMailManager
- Returns:
- a new mail destination instance.
- Throws:
PortalException
- See Also:
ISendMailManager.createMultipleMail()
,IMultipleMail.getDestinations()
-
generateNewQueueId
public java.lang.String generateNewQueueId() throws PortalException
Description copied from interface:ISendMailManager
Returns a new generated queue id.- Specified by:
generateNewQueueId
in interfaceISendMailManager
- 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 interfaceISendMailManager
- 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 interfaceISendMailManager
- 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 theIMailSender
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 interfaceISendMailManager
- 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, java.lang.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 interfaceISendMailManager
- 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 useISendMailManager.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, java.lang.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 interfaceISendMailManager
- 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 useISendMailManager.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(java.lang.String queueId) throws PortalException
- Throws:
PortalException
-
threadTerminated
public void threadTerminated(java.lang.String queueId)
-
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 interfaceISendMailManager
- Throws:
PortalException
- if it was not possible to complete the operation.
-
deleteMail
public void deleteMail(SessionConfig sessionConfig, java.lang.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 interfaceISendMailManager
- 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.
-
deleteMailDestination
public void deleteMailDestination(SessionConfig sessionConfig, java.lang.String mailDestinationId, ITransaction transaction) throws PortalException
Description copied from interface:ISendMailManager
Deletes a mail destination.- Specified by:
deleteMailDestination
in interfaceISendMailManager
- Parameters:
sessionConfig
- the user session information.mailDestinationId
- the mail destination's id.transaction
- the transaction for persistence access.- Throws:
PortalException
- if it was not possible to delete the mail destination.
-
-