org.umber.core.email
Class EmailFactory

java.lang.Object
  extended byorg.umber.core.email.EmailFactory

public class EmailFactory
extends java.lang.Object

Instantiator for email implementations.

Author:
jsheets

Method Summary
static void checkDependencies()
          Ensures that all JavaMail dependencies are available on the CLASSPATH.
static IEmailManager getEmail(java.util.Map properties)
          Instantiates an email manager.
static IEmailManager getEmail(java.lang.String path)
          Instantiates an email manager from the properties file at the given path on the CLASSPATH.
static boolean isDebug()
           
static boolean isJavaMailAvailable()
          Determines if a JavaMail implementation is available on the classpath.
static void main(java.lang.String[] args)
          Diagnostic method to test invocation of isVelocityAvailable(), getRunner(), and new VelocityRunner().
static void setDebug(boolean debug)
          Sets email debug mode.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isDebug

public static boolean isDebug()

setDebug

public static void setDebug(boolean debug)
Sets email debug mode. A value of true activates debug mode, which prevents all email activity from going through the JavaMail API; false deactivates debug mode, causing all email traffic to use the JavaMail API. By default, debug mode is false.

Debug mode is useful for unit-testing Umber components and applications that use the Umber email API.

Parameters:
debug - true to activate debug mode; false to deactivate

checkDependencies

public static void checkDependencies()
                              throws UmberClassException
Ensures that all JavaMail dependencies are available on the CLASSPATH. Returns quietly if all dependencies exist; throws an exception with a description of missing libraries.

Throws:
UmberClassException - if a JavaMail dependency is missing

isJavaMailAvailable

public static boolean isJavaMailAvailable()
Determines if a JavaMail implementation is available on the classpath.

Returns:
true if JavaMail is on classpath

getEmail

public static IEmailManager getEmail(java.util.Map properties)
                              throws UmberEmailException
Instantiates an email manager. If setDebug() has been called with a true, returns DebugEmailManager; if JavaMail is available on the CLASSPATH, returns JavaMailEmailManager; otherwise, throws an exception. The properties define the email connection parameters.

The properties match JavaMail properties):

Protocol Properties

Default Properties For All Protocols SMTP Properties POP3 Properties IMAP Properties Finally to use an alternate, custom implementation of IEmailManager, you can set the property mail.manager.class to the fully qualified class of the implementation. If that class is not found, or cannot be instantiated, this method will throw an exception.

Parameters:
properties - email connection properties, can be Map or Properties
Returns:
email manager instance
Throws:
UmberEmailException - if unable to instantiate an email manager

getEmail

public static IEmailManager getEmail(java.lang.String path)
                              throws UmberEmailException
Instantiates an email manager from the properties file at the given path on the CLASSPATH. The properties define the email connection parameters.

Parameters:
path - path to email connection properties file, on CLASSPATH
Returns:
email manager instance
Throws:
UmberEmailException - if unable to instantiate an email manager
See Also:
getEmail(Map)

main

public static void main(java.lang.String[] args)
Diagnostic method to test invocation of isVelocityAvailable(), getRunner(), and new VelocityRunner().

Parameters:
args - command-line arguments