public class MailFinalizer extends AbstractErrorFinalizer
ErrorEvent.MAIL_LOCAL and
ErrorEvent.MAIL_HOME. Note that the type of error handled is defined
in the KEY_FOLLOWUP property, in principle there is no difference in
mailing to a local or remote person, except that the KEY_TO fields
should differ.This class relies on the mailin API provided by Sun. Ensure that the required extension, at time of writing mail.jar and activation.jar are in the CLASSPATH.
| Modifier and Type | Class and Description |
|---|---|
static class |
MailFinalizer.Test
A class to test mail sending after an error.
|
PropertyResources.Load, PropertyResources.URLResource| Modifier and Type | Field and Description |
|---|---|
private static boolean |
DEFDEBUG
The default debuggin mode.
|
private static String |
DEFFROM
The default from address.
|
private static String |
DEFPASSWORD
Default password name.
|
private static String |
DEFSMTPHOST
The default smtphost.
|
private static int |
DEFSMTPPORT
The default port.
|
private static String |
DEFTO
The default to address.
|
private static String |
DEFUSERNAME
Default user name.
|
private static boolean |
DEFUSESSL
Default we use ssl.
|
private javax.mail.Address |
from
The from-address may not change.
|
static String |
KEY_BCC
Address list of the recipients, bcc-type.
|
static String |
KEY_CC
Address list of the recipients, cc-type.
|
static String |
KEY_DEBUG
If true, mail-delivery is blocked for debugging mode.
|
static String |
KEY_FOLLOWUP
One of the two follow-ups a mail finalizer can handle.
|
static String |
KEY_FROM
Address of the sender, with or without domain.
|
static String |
KEY_TELESCOPE
The issuing telescope.
|
static String |
KEY_TO
Address list of the recipients, to-type.
|
private Mailer |
mail
The mail-session object used for transporting mails.
|
KEY_NOINITONCREATE, POSTFIX_ALPHABET, POSTFIX_BYTES, POSTFIX_DIR, POSTFIX_EXT, POSTFIX_FILE, POSTFIX_LIST, POSTFIX_MODTIME, POSTFIX_URLKEY_LISTSEPARATOR, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATORCONFIG, KEY_CLASSKEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME| Constructor and Description |
|---|
MailFinalizer(Map<String,String> prop)
Constructs a new mail-finalizer with the distinct properties.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
finalizeError(TargetDefinition ignore,
ErrorEvent occur,
CommandLaunching[] servers,
Sequencing<?> dummy,
ParameterClustering set)
Handles a send-mail error follow-up.
|
String |
getFollowUp()
Returns the follow-up this finalizer deals with.
|
void |
init()
On init, we try to parse the from field.
|
boolean |
isFinalizing()
This error finalizer is threadless, so it's
finalizeError(target.TargetDefinition, stella.ErrorEvent, stella.CommandLaunching[], stella.Sequencing<?>, stella.ParameterClustering) method
is blocking. |
createErrorFinalizer, isAborting, setMonitor, wakeclone, createFrom, createFrom, createFrom, createInstance, getApplet, getAsResources, getLocate, getPropertiesToKey, getPropertiesToKey, getResource, getResourceAsStream, getResourceFromKey, getResources, hasLocalURLs, initProperties, keyCreate, keyCreate, reload, setAppletaugment, augment, augment, augment, augment, defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsEnums, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, isNew, parseObject, parseObject, reload, removeProperty, requires, rescanned, setObject, setProperties, setProperty, stringProperties, toStringequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitdefaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, parseObject, removeProperty, setObject, setProperty, stringPropertiespublic static final String KEY_TELESCOPE
public static final String KEY_FROM
public static final String KEY_TO
public static final String KEY_CC
public static final String KEY_BCC
public static final String KEY_DEBUG
public static final String KEY_FOLLOWUP
private static final String DEFFROM
private static final String DEFSMTPHOST
private static final int DEFSMTPPORT
private static final boolean DEFUSESSL
private static final String DEFUSERNAME
private static final String DEFPASSWORD
private static final String DEFTO
private static final boolean DEFDEBUG
private Mailer mail
private javax.mail.Address from
public MailFinalizer(Map<String,String> prop)
KEY_FOLLOWUP, the KEY_TO and the
#KEY_SMTPHOST are present. The latter key's value is directly
copied to the JavaMail required property mail.smtp.kost.
For efficiency, the mail session is initialized at finalizer construction, while the actual mail-transportation is done on error finalizing.
We use my properties to construct the Mailer instance to use.
public void init()
init in interface Initializableinit in class AbstractErrorFinalizerpublic String getFollowUp()
public boolean finalizeError(TargetDefinition ignore, ErrorEvent occur, CommandLaunching[] servers, Sequencing<?> dummy, ParameterClustering set)
KEY_TO, KEY_CC, and KEY_BCC
keys, the mail subject is the class name of the error and the mail body
the human-readable part of the error. The mail date is set to the error-
occurence date. If the mail was sent correctly, true is returned.public boolean isFinalizing()
finalizeError(target.TargetDefinition, stella.ErrorEvent, stella.CommandLaunching[], stella.Sequencing<?>, stella.ParameterClustering) method
is blocking. This method always returns false.