Class 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:
    1. XmlMailManager - used to load mail engine configuration using xml spring configuration files (generally applicationContext-Mail.xml)
    2. DaoMailManager - used by custom generated client application to that load mail engine configuration using database tables.
    • Field Summary

      • Fields inherited from class org.springframework.mail.javamail.JavaMailSenderImpl

        DEFAULT_PORT, DEFAULT_PROTOCOL
    • Constructor Summary

      Constructors 
      Constructor Description
      MailManagerImpl()
      Default constructor.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void afterPropertiesSet()
      Initialize all mail engine configurations and prepare java mail servers.
      org.springframework.context.ApplicationContext getApplicationContext()  
      java.lang.String getBaseUrl()  
      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.VelocityEngine getVelocityEngine()  
      protected abstract void initMailConfigs()
      Superclass must provide a way to initialize the given (initially empty) mail engine configuration map.
      protected abstract void initMailEvents()
      Superclass must provide a way to initialize the given (initially empty) mail events map.
      protected abstract void initMailStyle()
      Superclass must provide a way to initialize the given (initially empty) mail style map.
      protected abstract void initMailTemplates()
      Superclass must provide a way to initialize the given (initially empty) mail templates map.
      protected abstract void initMailVelocityEngine()
      Superclass must provide a way to initialize the given (initially empty) mail velocity engine.
      boolean isTestMode()  
      void sendEmailByEvent​(MailEvent event, java.util.Map objectMap, java.util.Map allegati)
      Send one or more emails associated to the given mail event object.
      void sendEmailByEvent​(java.lang.String eventId)
      Send one or more emails associated to the given eventId.
      void sendEmailByEvent​(java.lang.String eventId, java.util.Map objectMap)
      Send one or more emails associated to the given eventId.
      void sendEmailByEvent​(java.lang.String eventId, java.util.Map objectMap, java.util.Map allegati)
      Send one or more emails associated to the given eventId.
      void sendEmailByTemplate​(MailTemplate template, java.util.Map objectMap, java.util.Map allegati)
      Send an email by using the given mail template object.
      void sendEmailByTemplate​(java.lang.String templateId)
      Send an email by using the given templateId.
      void sendEmailByTemplate​(java.lang.String templateId, java.util.Map objectMap)
      Send an email by using the given templateId.
      void sendEmailByTemplate​(java.lang.String templateId, java.util.Map objectMap, java.util.Map allegati)
      Send an email by using the given templateId.
      void setApplicationContext​(org.springframework.context.ApplicationContext applicationContext)  
      void setBaseUrl​(java.lang.String baseUrl)  
      void setMailConfigs​(java.util.Map<java.lang.String,​MailConfig> mailConfigs)  
      void setMailEvents​(java.util.Map<java.lang.String,​MailEvent> mailEvents)  
      void setMailServers​(java.util.Map<java.lang.String,​MimeMailSenderImpl> mailServers)  
      void setMailTemplates​(java.util.Map<java.lang.String,​MailTemplate> mailTemplates)  
      void setTestMode​(boolean testMode)  
      void setVelocityEngine​(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
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MailManagerImpl

        public MailManagerImpl()
        Default constructor.
    • Method Detail

      • getVelocityEngine

        public org.apache.velocity.app.VelocityEngine getVelocityEngine()
        Specified by:
        getVelocityEngine in interface MailManager
        Returns:
        the velocityEngine
      • setVelocityEngine

        public void setVelocityEngine​(org.apache.velocity.app.VelocityEngine velocityEngine)
        Specified by:
        setVelocityEngine in interface MailManager
        Parameters:
        velocityEngine - the velocityEngine to set
      • setBaseUrl

        public void setBaseUrl​(java.lang.String baseUrl)
        Specified by:
        setBaseUrl in interface MailManager
      • isTestMode

        public boolean isTestMode()
        Specified by:
        isTestMode in interface MailManager
        Returns:
        the testMode
      • setTestMode

        public void setTestMode​(boolean testMode)
        Specified by:
        setTestMode in interface MailManager
        Parameters:
        testMode - the testMode to set
      • getApplicationContext

        public org.springframework.context.ApplicationContext getApplicationContext()
        Specified by:
        getApplicationContext in interface MailManager
        Returns:
        the applicationContext
      • setApplicationContext

        public void setApplicationContext​(org.springframework.context.ApplicationContext applicationContext)
                                   throws org.springframework.beans.BeansException
        Specified by:
        setApplicationContext in interface org.springframework.context.ApplicationContextAware
        Specified by:
        setApplicationContext in interface MailManager
        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
      • setMailConfigs

        public void setMailConfigs​(java.util.Map<java.lang.String,​MailConfig> mailConfigs)
        Specified by:
        setMailConfigs in interface MailManager
        Parameters:
        mailConfigs - the mailConfigs to set
      • setMailTemplates

        public void setMailTemplates​(java.util.Map<java.lang.String,​MailTemplate> mailTemplates)
        Specified by:
        setMailTemplates in interface MailManager
        Parameters:
        mailTemplates - the mailTemplates to set
      • setMailEvents

        public void setMailEvents​(java.util.Map<java.lang.String,​MailEvent> mailEvents)
        Specified by:
        setMailEvents in interface MailManager
        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:
        sendEmailByTemplate in interface MailManager
        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:
        sendEmailByTemplate in interface MailManager
        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:
        sendEmailByTemplate in interface MailManager
        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:
        sendEmailByTemplate in interface MailManager
        Parameters:
        template - MailTemplate object to process and send
        objectMap - 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:
        sendEmailByEvent in interface MailManager
        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:
        sendEmailByEvent in interface MailManager
        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:
        sendEmailByEvent in interface MailManager
        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:
        sendEmailByEvent in interface MailManager
        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.Exception
        Initialize all mail engine configurations and prepare java mail servers.
        Specified by:
        afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
        Specified by:
        afterPropertiesSet in interface MailManager
        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.