<Email ListLocation


Home
Download
Installation Docs
API Docs
Taglibs
Acknowledgements
Mailinglist

DeliveranceMail

Implementing a list location


To load a list of addresses for the deliverance server you may not wish to use or database or a text file in th eformat of the supplied examples. This document explains how to implement your own list location.

In this example you are going to load the list every time the JSP is loaded and run so that if the underlying data changes(list of addresses) it is reflected when the emails are sent.

first create a Java source file called MyEmailList.java
create an no arguments constructor
public MyEmailList(){
	super();
}
ensure the main public MyEmailList class implements the following interface
com.tp23.deliverance.EmailLocation
If you want to you can extend com.tp23.deliverance.AbstractEmailLocation so you get the required getAddresses() method and a setAddresses(InternetAddress[] newSet) method which you should use to populate the addresses.

if you want to be able to pass configuration options in the data.xml file ensure the main class implements.
com.tp23.deliverance.Configurable
you will need to implement the following two methods
  • public void configure(Properties config)
  • public Properties getConfig()
When the class is first loaded any configuration items in the XML file will be passed in the Properties object to the configure method.
Any - characters will be replaced with . characters. For example
<email-property-number value="23a"/>
will be accessible by calling config.getProperty("email.property.number") in the configure method, which will return the String "23a".
To create the list of email addresses you should now override the public InternetAddress[] getAddresses() method.
public InternetAddress[] getAddresses(){
	// get addresses from the LDAP server
	InternetAddress[] addresses = getAllFromLdap();
	return addresses
}
If you want to cache the addresses and you have subclassed AbstractEmailLocation you could override the email getAddresses() method as follows
public InternetAddress[] getAddresses(){
	InternetAddress[] addresses = getAddresses();
	if(addresses==null){
		// get addresses from the LDAP server
		addresses = getAllFromLdap();
		setAddresses(addresses);
	}
	return addresses
}
You would now need to ensure you call the setAddresses() method when the ldap changes to send mail to the full list.~



{logo}