wt.jmx.core.mbeans
Class Emailer

java.lang.Object
  extended by wt.jmx.core.StandardMBeanFix
      extended by wt.jmx.core.StandardMBean
          extended by wt.jmx.core.SelfAwareMBean
              extended by wt.jmx.core.mbeans.Emailer
All Implemented Interfaces:
DynamicMBean, MBeanRegistration, BaseObjectNamed, EmailerMBean, SelfEmailingMBean

public final class Emailer
extends SelfAwareMBean
implements EmailerMBean

This MBean acts as an e-mailing utility service for other MBeans and provides centralized configuration of MBean e-mailing.

Supported API: true

Extendable: false


Nested Class Summary
static interface Emailer.DestroyableProvider
          Emailer will call destroy() method on any EmailContentProvider that implements this method.
static class Emailer.EmailBodyProvider
          Convenience implementation of EmailContentProvider interface for use when the e-mail is to consist of a single, simple body part.
static interface Emailer.EmailContentProvider
          Wrapper interface for e-mail content which allows just-in-time determination of content, i.e.
static class Emailer.SimpleMultipartProvider
          Simple implementation of EmailContentProvider which returns a predesignated Multipart object.
static class Emailer.SimpleTextProvider
          Specialization of EmailBodyProvider for text whose type and contents are known at time of construction.
static class wt.jmx.core.mbeans.Emailer.SingleUrlProvider
          For e-mailing single, uncompressed files as attachments.
static class wt.jmx.core.mbeans.Emailer.SingleZippedUrlProvider
          For e-mailing single file as a zipped attachment.
static class wt.jmx.core.mbeans.Emailer.ZipProvider
          For e-mailing multiple files as a zipped attachment.
 
Method Summary
 void emailTextFile(File file, String addressesOrEmailList, String subject, long maxLines, long maxChars)
          E-mail last portion of text file

Supported API: true
 void emailZipOfFiles(URL baseURL, URL[] urls, String addressesOrEmailList, String subject)
          E-mail zip of files.
static Emailer getInstance(StandardMBean mbeanContext, boolean throwExceptionOnNoInstance)
          Return the Emailer associated by MBeanLoader with 'mbeanContext' or the Emailer started and still not stopped within this classloader.
 void sendEmail(InternetAddress[] recipients, String subject, Emailer.EmailContentProvider contents)
          Send e-mail to array of e-mail addresses

Supported API: true
 void sendEmail(InternetAddress[] recipients, String subject, Emailer.EmailContentProvider contents, String fromAddress)
          Send e-mail to array of e-mail addresses

Supported API: true
 void sendEmail(String toEmailAddresses, String subject, Emailer.EmailContentProvider contents)
          Send e-mail to a list of e-mail addresses

Supported API: true
 void sendEmailToAddressesOrList(String addressesOrEmailList, String subject, Emailer.EmailContentProvider contents)
          Send e-mail to an e-mail address or list

Supported API: true
 void sendEmailToList(String toEmailListName, String subject, Emailer.EmailContentProvider contents)
          Send e-mail to e-mail list

Supported API: true
 
Methods inherited from class wt.jmx.core.SelfAwareMBean
deregister, destroy, getBaseObjectName, getObjectName, getObjectNameOnPreRegister, getOwnerMBean, getSelfAwareMBean, init, isInited, isRegistered, isStarted, onDestroy, onInit, postDeregister, postRegister, preDeregister, preRegister, register, register, register, resetObjectName, setOwnerMBean, start, stop
 
Methods inherited from class wt.jmx.core.StandardMBean
cacheMBeanInfo, cacheMBeanInfoInInstance, createMBeanInfo, emailThisMBean, getCachedInstanceMBeanInfo, getCachedMBeanInfo, getDescription, getDescription, getDescription, getDescription, getImpact, getMBeanInfo, getParameterName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface wt.jmx.core.mbeans.SelfEmailingMBean
emailThisMBean
 

Method Detail

getInstance

public static Emailer getInstance(StandardMBean mbeanContext,
                                  boolean throwExceptionOnNoInstance)
Return the Emailer associated by MBeanLoader with 'mbeanContext' or the Emailer started and still not stopped within this classloader.

Supported API: true

Parameters:
mbeanContext - MBean to use as a lookup context for the given MBean (currently ignored unless SelfAwareMBean)
throwExceptionOnNoInstance - Whether a NullPointerException should be thrown when no started instance is available

sendEmailToAddressesOrList

public void sendEmailToAddressesOrList(String addressesOrEmailList,
                                       String subject,
                                       Emailer.EmailContentProvider contents)
                                throws IllegalArgumentException
Send e-mail to an e-mail address or list

Supported API: true

Parameters:
addressesOrEmailList - List of e-mail addresses or name of e-mail list to send e-mail to
subject - Subject of e-mail
contents - Contents of e-mail
Throws:
IllegalArgumentException

sendEmail

public void sendEmail(String toEmailAddresses,
                      String subject,
                      Emailer.EmailContentProvider contents)
               throws IllegalArgumentException
Send e-mail to a list of e-mail addresses

Supported API: true

Parameters:
toEmailAddresses - List of e-mail addresses to send e-mail to
subject - Subject of e-mail
contents - Contents of e-mail
Throws:
IllegalArgumentException

sendEmailToList

public void sendEmailToList(String toEmailListName,
                            String subject,
                            Emailer.EmailContentProvider contents)
                     throws IllegalArgumentException
Send e-mail to e-mail list

Supported API: true

Parameters:
toEmailListName - E-mail list to send e-mail to
subject - Subject of e-mail
contents - Contents of e-mail
Throws:
IllegalArgumentException

sendEmail

public void sendEmail(InternetAddress[] recipients,
                      String subject,
                      Emailer.EmailContentProvider contents)
               throws IllegalArgumentException
Send e-mail to array of e-mail addresses

Supported API: true

Parameters:
recipients - Array of e-mail addresses to send e-mail to
subject - Subject of e-mail
contents - Contents of e-mail
Throws:
IllegalArgumentException

sendEmail

public void sendEmail(InternetAddress[] recipients,
                      String subject,
                      Emailer.EmailContentProvider contents,
                      String fromAddress)
               throws IllegalArgumentException
Send e-mail to array of e-mail addresses

Supported API: true

Parameters:
recipients - Array of e-mail addresses to send e-mail to
subject - Subject of e-mail
contents - Contents of e-mail
fromAddress - From address for this e-mail; will use FromAddress attribute if this is null/unspecified
Throws:
IllegalArgumentException

emailZipOfFiles

public void emailZipOfFiles(URL baseURL,
                            URL[] urls,
                            String addressesOrEmailList,
                            String subject)
                     throws IOException
E-mail zip of files.

Supported API: true

Parameters:
baseURL - Base URL which jar entry names are formed relative to, must be parent URL to all other URLs specified
urls - URLs of files
addressesOrEmailList - List of e-mail addresses or name of e-mail list to send e-mail to
subject - Subject to give e-mail
Throws:
IOException

emailTextFile

public void emailTextFile(File file,
                          String addressesOrEmailList,
                          String subject,
                          long maxLines,
                          long maxChars)
                   throws IOException
E-mail last portion of text file

Supported API: true

Parameters:
file - File to e-mail
addressesOrEmailList - List of e-mail addresses or name of e-mail list to send e-mail to
subject - Subject to give e-mail
maxLines - Maximum number of lines to include; non-positive numbers imply no limit
maxChars - Maximum number of characters to include; non-positive numbers imply no limit
Throws:
IOException