Home

Extracting the E-Mail Service

moving the pebble E-Mail Utility to a separate bundle

Building a generic E-Mail service for an OSGi environment from the pebble implementation

Create a generic E-Mail interface like MailGateway:
public interface MailGateway {

void send(String emailAddress, String emailName, String to, String subject, String message);

void send(String emailAddress, String emailName, Collection<String> to, String subject, String message);

void send(String emailAddress, String emailName, Collection<String> to, Collection<String> cc, Collection<String> bcc, String subject,
String message);

}
A reference to the MailGateway service is configured as usual:
<osgi:reference id="mailGateway" interface="de.datenkollektiv.util.email.MailGateway" />
During development a console writer E-Mail stub can be used to satisfy the MailGateway dependency. The Spring configuration for exporting the LoggerMailGateway is straight forward:
<bean id="mailGateway" class="de.datenkollektiv.util.email.impl.LoggerMailGateway" />

<osgi:service ref="mailGateway" interface="de.datenkollektiv.util.email.MailGateway" />

The OSGi configuration in MANIFEST.MF

All mail related dependencies are moved away from pebble into the implementing bundle (snippet taken from MANIFEST.MF):
Require-Bundle: com.springsource.javax.mail;bundle-version="[1.4.1,1.5.0)",
com.springsource.javax.activation;bundle-version="[1.1.1,1.2.0)",
Import-Package:
javax.naming



Add a comment