|
jacquard 1.12.0 by The Web Engineering Factory and Toolworks | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectuk.co.weft.alert.Alert
An agent which can send a message to a user based on a template. This class (and consequently all classes which inherit from this class) knows about the following configuration parameters, which may be loaded from a file 'alert.properties' on the class path or passed into the constructor in a Map:
This class may be invoked as an application. In this configuration the class knows about the following command line switches:
Any argument which is not protected by a -a or -s switch will be treated as the filename or URL of a template file. If a template file is specified on the command line that will over-ride that specified in the configuration. If more than one template file is specified on the command line they will be concatenated in the order specified.
It's desirable that in the future Alert should be able to distinguish between email addresses and other forms of contact address - perhaps including IM addresses and phone numbers, and direct messages via instant messaging or SMS where appropriate. The present incarnation, however, knows only about email.
| Field Summary | |
protected java.lang.String |
addressDelimiter
the delimiter which may be used to separate mail addresses |
static java.lang.String |
ADDRESSDELIMITERTOKEN
a token to identify the address delimiter in the configuration or alert context |
static java.lang.String |
BCCADDRESSTOKEN
a token to identify any bcc address in the configuration context |
static java.lang.String |
CCADDRESSTOKEN
a token to identify any cc address in the configuration context |
protected java.lang.String |
charset
the character set in which to encode the mail |
protected boolean |
debug
whether or not I'm in debug mode |
static java.lang.String |
DEBUGTOKEN
a token to identify whether I'm in debug mode in the configuration context |
static java.lang.String |
FROMADDRESSTOKEN
a token to identify the from address in the configuration context |
protected boolean |
logMail
whether or not to log mail |
static java.lang.String |
LOGMAILTOKEN
A token to identify whether to log mail as it is sent |
protected InternetAddress |
mailBCCAddress
the BCC address for emails, if any |
protected InternetAddress |
mailCCAddress
the BCC address for emails, if any |
static java.lang.String |
MAILCHARSETTOKEN
a token to identify the character set for the mail which should be sent in the alert context |
protected InternetAddress |
mailFromAddress
the from address for emails |
protected java.lang.String |
mailHost
a host to send mail via |
static java.lang.String |
MAILHOSTTOKEN
a token to identify the host via which mail should be sent in the alert context |
protected Session |
mailSession
a mailer session |
protected java.lang.String |
mailSubject
the default subject |
static java.lang.String |
MAILSUBJECTTOKEN
a token to identify the subject for the mail which should be sent in the alert context |
static java.lang.String |
MAILTEMPLATETOKEN
a token to identify the template for the mail which should be sent in the alert context |
protected java.lang.String |
mailTemplateURL
the URL of the mail template file, if any |
static java.lang.String |
TOADDRESSTOKEN
a token to identify the address to which the alert should be sent in the alert context |
| Constructor Summary | |
Alert()
create a new alert agent with configuration from the properties file |
|
Alert(java.util.Map config)
create a new alert agent with this configuration |
|
| Method Summary | |
java.lang.Object |
getResource(java.lang.String key)
return the value of the resource with the given key as whatever sort of object it happens to be. |
java.lang.String |
getResourceString(java.lang.String key)
return as a string the value of the resource with the given key. |
java.lang.String |
grs(java.lang.String key)
shorthand for getResourceString; identical to it. |
protected void |
init(java.util.Map config)
initialise me from this configuration |
static void |
main(java.lang.String[] args)
Main: in case you want to use the alerter from the command line |
boolean |
sendAlert(InternetAddress toAddress,
java.util.Map context)
send an alert to this address, using my default template and subject, and substituting values in from this context. |
boolean |
sendAlert(InternetAddress toAddress,
java.lang.String subject,
java.util.Map context)
send an alert to this address, using my default template and substituting values in from this context. |
boolean |
sendAlert(InternetAddress toAddress,
java.lang.String subject,
java.lang.String templateName,
java.util.Map context)
send an alert to this addresses, using the template specified by this string and substituting values in from this context. |
boolean |
sendAlert(SMSAddress toAddress,
java.util.Map context)
send an alert to this address, using my default template and subject, and substituting values in from this context. |
boolean |
sendAlert(SMSAddress toAddress,
java.lang.String subject,
java.util.Map context)
send an alert to this address, using my default template and substituting values in from this context. |
boolean |
sendAlert(SMSAddress toAddress,
java.lang.String subject,
java.lang.String templateName,
java.util.Map context)
send an alert to this addresses, using the template specified by this string and substituting values in from this context. |
boolean |
sendAlert(java.lang.String toAddress,
java.util.Map context)
send an alert to this address, using my default template and subject, and substituting values in from this context. |
boolean |
sendAlert(java.lang.String toAddress,
java.lang.String subject,
java.util.Map context)
send an alert to this address, using my default template and substituting values in from this context. |
boolean |
sendAlert(java.lang.String toAddress,
java.lang.String subject,
MessageBuffer template,
java.util.Map context)
send an alert to this address using this template and sustituting values in from this context. |
boolean |
sendAlert(java.lang.String toAddress,
java.lang.String subject,
java.lang.String templateName,
java.util.Map context)
send an alert to this addresses, using the template specified by this string and substituting values in from this context. |
boolean |
sendAlert(java.util.Vector toAddresses,
java.util.Map context)
send an alert to this address, using my default template and subject, and substituting values in from this context. |
boolean |
sendAlert(java.util.Vector toAddresses,
java.lang.String subject,
MessageBuffer template,
java.util.Map context)
send an identical alert to each of these addresses using this template and sustituting values in from this context. |
boolean |
sendAlert(java.util.Vector toAddresses,
java.lang.String subject,
java.lang.String templateName,
java.util.Map context)
send an an identical alert to each of these addresses, using the template specified by this string and substituting values in from this context. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final java.lang.String FROMADDRESSTOKEN
public static final java.lang.String BCCADDRESSTOKEN
public static final java.lang.String CCADDRESSTOKEN
public static final java.lang.String MAILTEMPLATETOKEN
public static final java.lang.String MAILHOSTTOKEN
public static final java.lang.String MAILSUBJECTTOKEN
public static final java.lang.String MAILCHARSETTOKEN
public static final java.lang.String TOADDRESSTOKEN
public static final java.lang.String LOGMAILTOKEN
public static final java.lang.String DEBUGTOKEN
public static final java.lang.String ADDRESSDELIMITERTOKEN
protected InternetAddress mailBCCAddress
protected InternetAddress mailCCAddress
protected InternetAddress mailFromAddress
protected Session mailSession
protected java.lang.String addressDelimiter
protected java.lang.String charset
protected java.lang.String mailHost
protected java.lang.String mailSubject
protected java.lang.String mailTemplateURL
protected boolean debug
protected boolean logMail
| Constructor Detail |
public Alert(java.util.Map config)
throws AlertingException
public Alert()
throws AlertingException
| Method Detail |
public static void main(java.lang.String[] args)
throws java.lang.Exception
java.lang.Exception
public java.lang.Object getResource(java.lang.String key)
throws java.util.MissingResourceException
key - the key to search for
java.util.MissingResourceException - if the key cannot be found.public java.lang.String getResourceString(java.lang.String key)
key - the key to search forpublic java.lang.String grs(java.lang.String key)
getResourceString(String)
public boolean sendAlert(java.util.Vector toAddresses,
java.lang.String subject,
MessageBuffer template,
java.util.Map context)
throws AlertingException
toAddresses - a vector of Strings, InternetAddresses or
SMSAddresses. If strings each must be pareseable as a valid
email address or SMS addresssubject - the subject of the emails to send, or null to use the
default. May incorporate substitutable tokens.template - the template into which substitutions should be made.context - a map containing substitutions to make into the
template, such that the tokens to be substituted for are the
keys and the values to be substituted in are the associated
values
AlertingException
public boolean sendAlert(java.lang.String toAddress,
java.lang.String subject,
MessageBuffer template,
java.util.Map context)
throws AlertingException
toAddress - a String which is a valid email or SMS address, or a
sustitution token, or a delimiter separated list of such
addresses and tokenssubject - the subject of the emails to send, or null to use the
default. May incorporate substitutable tokens.template - the template into which substitutions should be madecontext - a map containing substitutions to make into the
template, such that the tokens to be substituted for are the
keys and the values to be substituted in are the associated
values
AlertingException
public boolean sendAlert(java.util.Vector toAddresses,
java.lang.String subject,
java.lang.String templateName,
java.util.Map context)
throws AlertingException
toAddresses - a vector of Strings each of which is a valid email
addresssubject - the subject of the emails to send, or null to use the
default. May incorporate substitutable tokens.templateName - a URL or filename from which the template can be
fetchedcontext - a map containing substitutions to make into the
template, such that the tokens to be substituted for are the
keys and the values to be substituted in are the associated
values
AlertingException
public boolean sendAlert(java.lang.String toAddress,
java.lang.String subject,
java.lang.String templateName,
java.util.Map context)
throws AlertingException
toAddress - a String which is a valid email addresssubject - the subject of the emails to send, or null to use the
default. May incorporate substitutable tokens.templateName - a URL or filename from which the template can be
fetched, or null to use the defaultcontext - a map containing substitutions to make into the
template, such that the tokens to be substituted for are the
keys and the values to be substituted in are the associated
values
AlertingException
public boolean sendAlert(InternetAddress toAddress,
java.lang.String subject,
java.lang.String templateName,
java.util.Map context)
throws AlertingException
toAddress - an InternetAddresssubject - the subject of the emails to send, or null to use the
default. May incorporate substitutable tokens.templateName - a URL or filename from which the template can be
fetched, or null to use the defaultcontext - a map containing substitutions to make into the
template, such that the tokens to be substituted for are the
keys and the values to be substituted in are the associated
values
AlertingException
public boolean sendAlert(SMSAddress toAddress,
java.lang.String subject,
java.lang.String templateName,
java.util.Map context)
throws AlertingException
toAddress - an SMSAddresssubject - the subject of the emails to send, or null to use the
default. May incorporate substitutable tokens.templateName - a URL or filename from which the template can be
fetched, or null to use the defaultcontext - a map containing substitutions to make into the
template, such that the tokens to be substituted for are the
keys and the values to be substituted in are the associated
values
AlertingException
public boolean sendAlert(java.lang.String toAddress,
java.lang.String subject,
java.util.Map context)
throws AlertingException
toAddress - a String which is a valid email or SMS address, or a
sustitution token, or a delimiter separated list of such
addresses and tokenssubject - the subject of the emails to send, or null to use the
default. May incorporate substitutable tokens.context - a map containing substitutions to make into the
template, such that the tokens to be substituted for are the
keys and the values to be substituted in are the associated
values
AlertingException
public boolean sendAlert(InternetAddress toAddress,
java.lang.String subject,
java.util.Map context)
throws AlertingException
toAddress - an InternetAddresssubject - the subject of the emails to send, or null to use the
default. May incorporate substitutable tokens.context - a map containing substitutions to make into the
template, such that the tokens to be substituted for are the
keys and the values to be substituted in are the associated
values
AlertingException
public boolean sendAlert(SMSAddress toAddress,
java.lang.String subject,
java.util.Map context)
throws AlertingException
toAddress - an SMSAddress which is a valid email addresssubject - the subject of the emails to send, or null to use the
default. May incorporate substitutable tokens.context - a map containing substitutions to make into the
template, such that the tokens to be substituted for are the
keys and the values to be substituted in are the associated
values
AlertingException
public boolean sendAlert(java.util.Vector toAddresses,
java.util.Map context)
throws AlertingException
toAddresses - a Vector of usable addressescontext - a map containing substitutions to make into the
template, such that the tokens to be substituted for are the
keys and the values to be substituted in are the associated
values
AlertingException
public boolean sendAlert(java.lang.String toAddress,
java.util.Map context)
throws AlertingException
toAddress - a String which is a valid email address or SMS
address, or a sustitution token, or a delimiter separated list
of such addresses and tokenscontext - a map containing substitutions to make into the
template, such that the tokens to be substituted for are the
keys and the values to be substituted in are the associated
values
AlertingException
public boolean sendAlert(InternetAddress toAddress,
java.util.Map context)
throws AlertingException
toAddress - an InternetAddresscontext - a map containing substitutions to make into the
template, such that the tokens to be substituted for are the
keys and the values to be substituted in are the associated
values
AlertingException
public boolean sendAlert(SMSAddress toAddress,
java.util.Map context)
throws AlertingException
toAddress - a SMSAddresscontext - a map containing substitutions to make into the
template, such that the tokens to be substituted for are the
keys and the values to be substituted in are the associated
values
AlertingException
protected void init(java.util.Map config)
throws AlertingException
AlertingException
|
jacquard 1.12.0 by The Web Engineering Factory and Toolworks | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||