org.ploin.pmf.impl
Class MailFactory

java.lang.Object
  extended by org.ploin.pmf.impl.MailFactory
All Implemented Interfaces:
java.io.Serializable, IMailFactory

public class MailFactory
extends java.lang.Object
implements java.io.Serializable, IMailFactory

Description: Implementation of the IMailFactory interface. This is the main class. This class control the MailReader, MailReplacer,
MailSender and the PropertiesLoader.

                                    ........
                                 .WHHUUVOOOOU&,
     dMMMMMMMMMMMa,   .MMMMF   .MHW0Oz+!``````?G.   .MMMM% .MMMMMMMMMMMN,
    .MMMMMMMMMMMMMMr  JMMMM   JHHXwOz;:^..```  `O,  JMMM#  dMMMMMMMMMMMMN
    JMMM#     ,MMMMF  MMMMF  .MHVXwOz++.^.````  +n .MMMM$ .MMMMt    dMMM#
   .MMMMt     .MMMMt .MMMM!  JMHWWXwOz++....  `.+X JMMMM  JMMMM    .MMMM%
   JMMM#     .MMMM@  dMMM#   ,MHHWWXwOzz+++....?df MMMMF .MMMMF    JMMM#
  .MMMMNNNNNMMMMMD   MMMMMNNm 4MHHWWXXwOOzzz1+1wX'.MMMM! .MMMM`   .MMMM$
  .MMMMMMMMMMMM"`    .YMMMMMF  TMHHHWWWXXXwwwwXK! MMMMF  MMMMF    JMMMM
  MMMMF                          TMMHHHHHWWWHY^
 .MMMM'                             `7""""^`
 dMMM#
 

$HeadURL: https://ploinscm.de/svn/ploinMailFactory/trunk/src/main/java/org/ploin/pmf/impl/MailFactory.java $
$LastChangedBy: r.reiz $
$Revision: 66 $
$Date: 2009-12-08 12:03:04 +0100 (Tue, 08 Dec 2009) $

See Also:
Serialized Form

Constructor Summary
MailFactory()
          Constructor
Reads the properties from the mail.properties file
 
Method Summary
 java.lang.String getDirectory()
          Returns the directory where the email-templates and the mandants are in.
 java.lang.String getHtmlExtension()
          returns the html extension.
 java.lang.String getHtmlMessage(TemplateConfig templateConfig)
          This method tries to find a HTML template file with the given name ("mailname"), fills it with the values from the map and returns the filled template.
 IMailReader getMailReader()
          Returns the IMailReader
 IMailReplacer getMailReplacer()
          Returns the IMailReplacer
 IMailSender getMailSender()
          Returns the IMailSender
 java.lang.String getPlainExtension()
          returns the plain extension.
 java.lang.String getPlainMessage(TemplateConfig templateConfig)
          This method tries to find a plain-text template file with the given name ("mailname"), fills it with the values from the map and returns the filled template.
 IPropertiesLoader getPropertiesLoader()
          Returns the IPropertiesLoader
 void init()
          Initialize the mail Factory
 boolean isSingleThread()
          returns the variable "singleThread"
 SendingResult sendMail(MailConfig mailConfig, TemplateConfig templateConfig)
          This is the main method.
 SendingResult sendMailFromTemplate(MailConfig mailConfig, TemplateConfig templateConfig)
           
 SendingResult sendMailWithContent(MailConfig mailConfig, TemplateConfig templateConfig, java.lang.String plainReplaced, java.lang.String htmlReplaced)
          This method sends an e-mail with the given plainReplaced content and htmlReplaced content.
 void setDirectory(java.lang.String directory)
          Set teh directory where the email-templates and the mandants are in.
 void setHtmlExtension(java.lang.String htmlExtension)
          Set the html extension.
 void setMailReader(IMailReader mailReader)
          Set the IMailReader
 void setMailReplacer(IMailReplacer mailReplacer)
          Set the IMailReplacer
 void setMailSender(IMailSender mailSender)
          Set the IMailSender
 void setPlainExtension(java.lang.String plainExtendsion)
          Set the plain extension.
 void setPropertiesLoader(IPropertiesLoader propertiesLoader)
          Set the IPropertiesLoader
 void setSingleThread(boolean singleThread)
          Set the singleThread
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MailFactory

public MailFactory()
Constructor
Reads the properties from the mail.properties file

Method Detail

init

public void init()
Description copied from interface: IMailFactory
Initialize the mail Factory

Specified by:
init in interface IMailFactory

sendMail

public SendingResult sendMail(MailConfig mailConfig,
                              TemplateConfig templateConfig)
Description copied from interface: IMailFactory
This is the main method. It tries to find an e-mail template with the name "mailname" and fills the template with the values from the map. If template has been filled successfully, the framework sends the mail to the receiver.

Specified by:
sendMail in interface IMailFactory
Parameters:
mailConfig - the object containing the recipients and the mandant
templateConfig - containing mandant/client, locale, template-name and map.
Returns:
A SendingResult object containing the result from the commons-email-api and the MimeMessage

sendMailWithContent

public SendingResult sendMailWithContent(MailConfig mailConfig,
                                         TemplateConfig templateConfig,
                                         java.lang.String plainReplaced,
                                         java.lang.String htmlReplaced)
                                  throws java.lang.Exception
Description copied from interface: IMailFactory
This method sends an e-mail with the given plainReplaced content and htmlReplaced content. A template is not necessary.

Specified by:
sendMailWithContent in interface IMailFactory
Parameters:
mailConfig - the mailConfig object
templateConfig - containing mandant/client, locale, template-name and map.
plainReplaced - the plain text content to be send in the email.
htmlReplaced - the HTML content to be send in the email.
Returns:
A SendingResult object containing the result from the commons-email-api and the MimeMessage
Throws:
java.lang.Exception

getPlainMessage

public java.lang.String getPlainMessage(TemplateConfig templateConfig)
Description copied from interface: IMailFactory
This method tries to find a plain-text template file with the given name ("mailname"), fills it with the values from the map and returns the filled template.

Specified by:
getPlainMessage in interface IMailFactory
Parameters:
templateConfig - containing mandant/client, locale, template-name and map.
Returns:
filled template file, or null

getHtmlMessage

public java.lang.String getHtmlMessage(TemplateConfig templateConfig)
Description copied from interface: IMailFactory
This method tries to find a HTML template file with the given name ("mailname"), fills it with the values from the map and returns the filled template.

Specified by:
getHtmlMessage in interface IMailFactory
Parameters:
templateConfig - containing mandant/client, locale, template-name and map.
Returns:
filled template file, or null

sendMailFromTemplate

public SendingResult sendMailFromTemplate(MailConfig mailConfig,
                                          TemplateConfig templateConfig)

getMailReader

public IMailReader getMailReader()
Description copied from interface: IMailFactory
Returns the IMailReader

Specified by:
getMailReader in interface IMailFactory
Returns:
IMailReader

setMailReader

public void setMailReader(IMailReader mailReader)
Description copied from interface: IMailFactory
Set the IMailReader

Specified by:
setMailReader in interface IMailFactory

getMailReplacer

public IMailReplacer getMailReplacer()
Description copied from interface: IMailFactory
Returns the IMailReplacer

Specified by:
getMailReplacer in interface IMailFactory
Returns:
IMailReplacer

setMailReplacer

public void setMailReplacer(IMailReplacer mailReplacer)
Description copied from interface: IMailFactory
Set the IMailReplacer

Specified by:
setMailReplacer in interface IMailFactory

getMailSender

public IMailSender getMailSender()
Description copied from interface: IMailFactory
Returns the IMailSender

Specified by:
getMailSender in interface IMailFactory
Returns:
IMailSender

setMailSender

public void setMailSender(IMailSender mailSender)
Description copied from interface: IMailFactory
Set the IMailSender

Specified by:
setMailSender in interface IMailFactory

getPropertiesLoader

public IPropertiesLoader getPropertiesLoader()
Description copied from interface: IMailFactory
Returns the IPropertiesLoader

Specified by:
getPropertiesLoader in interface IMailFactory
Returns:
IPropertiesLoader

setPropertiesLoader

public void setPropertiesLoader(IPropertiesLoader propertiesLoader)
Description copied from interface: IMailFactory
Set the IPropertiesLoader

Specified by:
setPropertiesLoader in interface IMailFactory

getDirectory

public java.lang.String getDirectory()
Description copied from interface: IMailFactory
Returns the directory where the email-templates and the mandants are in.

Specified by:
getDirectory in interface IMailFactory
Returns:
String, directroy

setDirectory

public void setDirectory(java.lang.String directory)
Description copied from interface: IMailFactory
Set teh directory where the email-templates and the mandants are in.

Specified by:
setDirectory in interface IMailFactory

getHtmlExtension

public java.lang.String getHtmlExtension()
Description copied from interface: IMailFactory
returns the html extension.

Specified by:
getHtmlExtension in interface IMailFactory
Returns:
String, htmlExtension

getPlainExtension

public java.lang.String getPlainExtension()
Description copied from interface: IMailFactory
returns the plain extension.

Specified by:
getPlainExtension in interface IMailFactory
Returns:
String, plainExtension

setHtmlExtension

public void setHtmlExtension(java.lang.String htmlExtension)
Description copied from interface: IMailFactory
Set the html extension. The standard is ".html"

Specified by:
setHtmlExtension in interface IMailFactory

setPlainExtension

public void setPlainExtension(java.lang.String plainExtendsion)
Description copied from interface: IMailFactory
Set the plain extension. The standard is ".txt"

Specified by:
setPlainExtension in interface IMailFactory

isSingleThread

public boolean isSingleThread()
Description copied from interface: IMailFactory
returns the variable "singleThread"

Specified by:
isSingleThread in interface IMailFactory
Returns:
boolean

setSingleThread

public void setSingleThread(boolean singleThread)
Description copied from interface: IMailFactory
Set the singleThread

Specified by:
setSingleThread in interface IMailFactory


Copyright © 2009 PLOIN GmbH. All Rights Reserved.