Class MailManagerImpl
- java.lang.Object
-
- org.springframework.mail.javamail.JavaMailSenderImpl
-
- it.micegroup.voila2runtime.mail.manager.MailManagerImpl
-
- All Implemented Interfaces:
MailManager,org.springframework.beans.factory.Aware,org.springframework.beans.factory.InitializingBean,org.springframework.context.ApplicationContextAware,org.springframework.mail.javamail.JavaMailSender,org.springframework.mail.MailSender
public abstract class MailManagerImpl extends org.springframework.mail.javamail.JavaMailSenderImpl implements MailManager
Mail manager that is able to send email based on templates and events. This abstract mail manager must be extended by concrete subclasses in order to provide a way to initialize the entire mail engine. Two base concrete subclasses ae provided by default:- XmlMailManager - used to load mail engine configuration using xml spring configuration files (generally applicationContext-Mail.xml)
- DaoMailManager - used by custom generated client application to that load mail engine configuration using database tables.
-
-
Constructor Summary
Constructors Constructor Description MailManagerImpl()Default constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidafterPropertiesSet()Initialize all mail engine configurations and prepare java mail servers.org.springframework.context.ApplicationContextgetApplicationContext()java.lang.StringgetBaseUrl()java.util.Map<java.lang.String,MailConfig>getMailConfigs()java.util.Map<java.lang.String,MailEvent>getMailEvents()java.util.Map<java.lang.String,MimeMailSenderImpl>getMailServers()java.util.Map<java.lang.String,MailTemplate>getMailTemplates()org.apache.velocity.app.VelocityEnginegetVelocityEngine()protected abstract voidinitMailConfigs()Superclass must provide a way to initialize the given (initially empty) mail engine configuration map.protected abstract voidinitMailEvents()Superclass must provide a way to initialize the given (initially empty) mail events map.protected abstract voidinitMailStyle()Superclass must provide a way to initialize the given (initially empty) mail style map.protected abstract voidinitMailTemplates()Superclass must provide a way to initialize the given (initially empty) mail templates map.protected abstract voidinitMailVelocityEngine()Superclass must provide a way to initialize the given (initially empty) mail velocity engine.booleanisTestMode()voidsendEmailByEvent(MailEvent event, java.util.Map objectMap, java.util.Map allegati)Send one or more emails associated to the given mail event object.voidsendEmailByEvent(java.lang.String eventId)Send one or more emails associated to the given eventId.voidsendEmailByEvent(java.lang.String eventId, java.util.Map objectMap)Send one or more emails associated to the given eventId.voidsendEmailByEvent(java.lang.String eventId, java.util.Map objectMap, java.util.Map allegati)Send one or more emails associated to the given eventId.voidsendEmailByTemplate(MailTemplate template, java.util.Map objectMap, java.util.Map allegati)Send an email by using the given mail template object.voidsendEmailByTemplate(java.lang.String templateId)Send an email by using the given templateId.voidsendEmailByTemplate(java.lang.String templateId, java.util.Map objectMap)Send an email by using the given templateId.voidsendEmailByTemplate(java.lang.String templateId, java.util.Map objectMap, java.util.Map allegati)Send an email by using the given templateId.voidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext)voidsetBaseUrl(java.lang.String baseUrl)voidsetMailConfigs(java.util.Map<java.lang.String,MailConfig> mailConfigs)voidsetMailEvents(java.util.Map<java.lang.String,MailEvent> mailEvents)voidsetMailServers(java.util.Map<java.lang.String,MimeMailSenderImpl> mailServers)voidsetMailTemplates(java.util.Map<java.lang.String,MailTemplate> mailTemplates)voidsetTestMode(boolean testMode)voidsetVelocityEngine(org.apache.velocity.app.VelocityEngine velocityEngine)-
Methods inherited from class org.springframework.mail.javamail.JavaMailSenderImpl
connectTransport, createMimeMessage, createMimeMessage, doSend, getDefaultEncoding, getDefaultFileTypeMap, getHost, getJavaMailProperties, getPassword, getPort, getProtocol, getSession, getTransport, getUsername, send, send, send, send, send, send, setDefaultEncoding, setDefaultFileTypeMap, setHost, setJavaMailProperties, setPassword, setPort, setProtocol, setSession, setUsername, testConnection
-
-
-
-
Method Detail
-
getVelocityEngine
public org.apache.velocity.app.VelocityEngine getVelocityEngine()
- Specified by:
getVelocityEnginein interfaceMailManager- Returns:
- the velocityEngine
-
setVelocityEngine
public void setVelocityEngine(org.apache.velocity.app.VelocityEngine velocityEngine)
- Specified by:
setVelocityEnginein interfaceMailManager- Parameters:
velocityEngine- the velocityEngine to set
-
getBaseUrl
public java.lang.String getBaseUrl()
- Specified by:
getBaseUrlin interfaceMailManager
-
setBaseUrl
public void setBaseUrl(java.lang.String baseUrl)
- Specified by:
setBaseUrlin interfaceMailManager
-
isTestMode
public boolean isTestMode()
- Specified by:
isTestModein interfaceMailManager- Returns:
- the testMode
-
setTestMode
public void setTestMode(boolean testMode)
- Specified by:
setTestModein interfaceMailManager- Parameters:
testMode- the testMode to set
-
getApplicationContext
public org.springframework.context.ApplicationContext getApplicationContext()
- Specified by:
getApplicationContextin interfaceMailManager- Returns:
- the applicationContext
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException- Specified by:
setApplicationContextin interfaceorg.springframework.context.ApplicationContextAware- Specified by:
setApplicationContextin interfaceMailManager- Throws:
org.springframework.beans.BeansException
-
getMailServers
public java.util.Map<java.lang.String,MimeMailSenderImpl> getMailServers()
- Returns:
- the mailServers
-
setMailServers
public void setMailServers(java.util.Map<java.lang.String,MimeMailSenderImpl> mailServers)
- Parameters:
mailServers- the mailServers to set
-
getMailConfigs
public java.util.Map<java.lang.String,MailConfig> getMailConfigs()
- Specified by:
getMailConfigsin interfaceMailManager- Returns:
- the mailConfigs
-
setMailConfigs
public void setMailConfigs(java.util.Map<java.lang.String,MailConfig> mailConfigs)
- Specified by:
setMailConfigsin interfaceMailManager- Parameters:
mailConfigs- the mailConfigs to set
-
getMailTemplates
public java.util.Map<java.lang.String,MailTemplate> getMailTemplates()
- Specified by:
getMailTemplatesin interfaceMailManager- Returns:
- the mailTemplates
-
setMailTemplates
public void setMailTemplates(java.util.Map<java.lang.String,MailTemplate> mailTemplates)
- Specified by:
setMailTemplatesin interfaceMailManager- Parameters:
mailTemplates- the mailTemplates to set
-
getMailEvents
public java.util.Map<java.lang.String,MailEvent> getMailEvents()
- Specified by:
getMailEventsin interfaceMailManager- Returns:
- the mailEvents
-
setMailEvents
public void setMailEvents(java.util.Map<java.lang.String,MailEvent> mailEvents)
- Specified by:
setMailEventsin interfaceMailManager- Parameters:
mailEvents- the mailEvents to set
-
sendEmailByTemplate
public void sendEmailByTemplate(java.lang.String templateId)
Send an email by using the given templateId. The mail has no dynamic parts and no attachments.- Specified by:
sendEmailByTemplatein interfaceMailManager- Parameters:
templateId- mail template to process and send.
-
sendEmailByTemplate
public void sendEmailByTemplate(java.lang.String templateId, java.util.Map objectMap)Send an email by using the given templateId. The mail can have dynamic parts but no attachments.- Specified by:
sendEmailByTemplatein interfaceMailManager- Parameters:
templateId- mail template to process and send.objectMap- map of business objects to be used to resolve dynamic parts.
-
sendEmailByTemplate
public void sendEmailByTemplate(java.lang.String templateId, java.util.Map objectMap, java.util.Map allegati)Send an email by using the given templateId. The mail can have dynamic parts and attachments.- Specified by:
sendEmailByTemplatein interfaceMailManager- Parameters:
templateId- mail template to process and send.objectMap- map of business objects to be used to resolve dynamic parts.allegati- map of attachments.
-
sendEmailByTemplate
public void sendEmailByTemplate(MailTemplate template, java.util.Map objectMap, java.util.Map allegati)
Send an email by using the given mail template object. The mail can have dynamic parts and attachments.- Specified by:
sendEmailByTemplatein interfaceMailManager- Parameters:
template- MailTemplate object to process and sendobjectMap- map of business objects to be used to resolve dynamic parts.allegati- map of attachments.
-
sendEmailByEvent
public void sendEmailByEvent(java.lang.String eventId)
Send one or more emails associated to the given eventId. Mails have no dynamic parts and no attachments.- Specified by:
sendEmailByEventin interfaceMailManager- Parameters:
eventId- the event to process in order to send related emails.
-
sendEmailByEvent
public void sendEmailByEvent(java.lang.String eventId, java.util.Map objectMap)Send one or more emails associated to the given eventId. Mails can have dynamic parts but no attachments.- Specified by:
sendEmailByEventin interfaceMailManager- Parameters:
eventId- the event to process in order to send related emails.objectMap- map of business objects to be used to resolve dynamic parts.
-
sendEmailByEvent
public void sendEmailByEvent(java.lang.String eventId, java.util.Map objectMap, java.util.Map allegati)Send one or more emails associated to the given eventId. Mails can have dynamic parts and attachments.- Specified by:
sendEmailByEventin interfaceMailManager- Parameters:
eventId- the event to process in order to send related emails.objectMap- map of business objects to be used to resolve dynamic parts.allegati- map of attachments.
-
sendEmailByEvent
public void sendEmailByEvent(MailEvent event, java.util.Map objectMap, java.util.Map allegati)
Send one or more emails associated to the given mail event object. Mails can have dynamic parts and attachments.- Specified by:
sendEmailByEventin interfaceMailManager- Parameters:
event- the mail event object to process in order to send related emails.objectMap- map of business objects to be used to resolve dynamic parts.allegati- map of attachments.
-
afterPropertiesSet
public void afterPropertiesSet() throws java.lang.ExceptionInitialize all mail engine configurations and prepare java mail servers.- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Specified by:
afterPropertiesSetin interfaceMailManager- Throws:
java.lang.Exception- See Also:
InitializingBean.afterPropertiesSet()
-
initMailConfigs
protected abstract void initMailConfigs()
Superclass must provide a way to initialize the given (initially empty) mail engine configuration map.
-
initMailTemplates
protected abstract void initMailTemplates()
Superclass must provide a way to initialize the given (initially empty) mail templates map.
-
initMailEvents
protected abstract void initMailEvents()
Superclass must provide a way to initialize the given (initially empty) mail events map.
-
initMailVelocityEngine
protected abstract void initMailVelocityEngine()
Superclass must provide a way to initialize the given (initially empty) mail velocity engine.
-
initMailStyle
protected abstract void initMailStyle()
Superclass must provide a way to initialize the given (initially empty) mail style map.
-
-