]> git.mxchange.org Git - jmailer-ee.git/commitdiff
Rewrite:
authorRoland Häder <roland@mxchange.org>
Sat, 8 Jul 2017 16:56:32 +0000 (18:56 +0200)
committerRoland Häder <roland@mxchange.org>
Sat, 8 Jul 2017 16:56:32 +0000 (18:56 +0200)
- having a mailer class is nice but only as a singleton (EJB) bean

Signed-off-by: Roland Häder <roland@mxchange.org>
src/org/mxchange/jmailee/model/delivery/BaseMailer.java [deleted file]
src/org/mxchange/jmailee/model/delivery/BaseMailerBean.java [new file with mode: 0644]
src/org/mxchange/jmailee/model/delivery/DeliverableEmail.java [deleted file]
src/org/mxchange/jmailee/model/delivery/DeliverableEmailLocal.java [new file with mode: 0644]

diff --git a/src/org/mxchange/jmailee/model/delivery/BaseMailer.java b/src/org/mxchange/jmailee/model/delivery/BaseMailer.java
deleted file mode 100644 (file)
index 88571f3..0000000
+++ /dev/null
@@ -1,284 +0,0 @@
-/*
- * Copyright (C) 2016, 2017 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jmailee.model.delivery;
-
-import java.io.StringWriter;
-import java.text.MessageFormat;
-import java.util.Date;
-import java.util.Properties;
-import javax.mail.MessagingException;
-import javax.mail.Session;
-import javax.mail.Transport;
-import javax.mail.internet.InternetAddress;
-import javax.mail.internet.MimeMessage;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import org.apache.velocity.Template;
-import org.apache.velocity.VelocityContext;
-import org.apache.velocity.app.VelocityEngine;
-import org.apache.velocity.runtime.RuntimeConstants;
-import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
-import org.mxchange.jcoreeelogger.beans.local.logger.Log;
-import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal;
-import org.mxchange.jmailee.model.delivery.wrapper.WrapableEmailDelivery;
-
-/**
- * An email class for sending out mails from templates
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public abstract class BaseMailer implements DeliverableEmail {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 14_598_912_753_106L;
-
-       /**
-        * Logger bean
-        */
-       @Log
-       private LoggerBeanLocal loggerBeanLocal;
-
-       /**
-        * Properties for this mailer
-        * <p>
-        * Valid are: - mailer.errorsto = Email address for "Errors-To" header -
-        * mailer.bouncesto = Email address for "Bounces-To" header (optional, if
-        * not set, errorsto must be set) - mailer.xloop = Email address for
-        * "X-Loop" header (optional, if not set, errorsto must be set)
-        */
-       private Properties properties;
-
-       /**
-        * Template engine
-        */
-       private final VelocityEngine templateEngine;
-
-       /**
-        * Default constructor
-        */
-       protected BaseMailer () {
-               try {
-                       // Get initial context
-                       Context context = new InitialContext();
-
-                       // Lookup logger
-                       this.loggerBeanLocal = (LoggerBeanLocal) context.lookup("java:global/jcore-logger-ejb/logger!org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal"); //NOI18N
-               } catch (final NamingException ex) {
-                       // Continue to throw
-                       throw new RuntimeException(MessageFormat.format("context.lookup() failed: {0}", ex.getMessage()), ex); //NOI18N
-               }
-
-               // Init template engine
-               this.templateEngine = new VelocityEngine();
-               this.templateEngine.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath"); //NOI18N
-               this.templateEngine.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName()); //NOI18N
-               this.templateEngine.init();
-       }
-
-       @Override
-       public VelocityEngine getTemplateEngine () {
-               return this.templateEngine;
-       }
-
-       @Override
-       @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter")
-       public void init (final Properties properties) {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("init: properties={0} - CALLED!", properties)); //NOI18N
-
-               // Are all required properties set?
-               if (null == properties) {
-                       // Is null
-                       throw new NullPointerException("properties is null"); //NOI18N
-               } else if (!properties.containsKey("mailer.errorsto")) { //NOI18N
-                       // Errors-To not set
-                       throw new IllegalArgumentException("properties.mailer.errorsto is not set"); //NOI18N
-               } else if (!properties.containsKey("mailer.bouncesto")) { //NOI18N
-                       // Errors-To not set
-                       throw new IllegalArgumentException("properties.mailer.bouncesto is not set"); //NOI18N
-               }
-
-               // Set it here
-               this.properties = properties;
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace("init: EXIT!"); //NOI18N
-       }
-
-       /**
-        * Sends an email to given email address with subject line.
-        * <p>
-        * @param emailAddress Email address for recipient
-        * @param subjectLine Subject line
-        * @param writer Body part
-        * @param mailSession Corresponding mail session to use
-        * <p>
-        * @throws MessagingException If something happened on message delivery
-        */
-       private void sendMail (final WrapableEmailDelivery emailWrapper, final StringWriter writer, final Session mailSession) throws MessagingException {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("sendMail: emailWrapper={0},body={1},mailSession={2} - CALLED!", emailWrapper, writer, mailSession)); //NOI18N
-
-               // Are the additional properties and all parameter set?
-               if (null == this.properties) {
-                       // Nothing set
-                       throw new NullPointerException("this.properties is null"); //NOI18N
-               } else if (null == emailWrapper) {
-                       // Throw NPE
-                       throw new NullPointerException("emailWrapper is null"); //NOI18N
-               } else if (emailWrapper.getLocale() == null) {
-                       // Throw it again
-                       throw new NullPointerException("emailWrapper.locale is null"); //NOI18N
-               } else if (emailWrapper.getRecipientAddress() == null) {
-                       // Throw it again
-                       throw new NullPointerException("emailWrapper.recipient is null"); //NOI18N
-               } else if (emailWrapper.getTemplateName() == null) {
-                       // Throw it again
-                       throw new NullPointerException("emailWrapper.templateName is null"); //NOI18N
-               } else if (emailWrapper.getTemplateName().isEmpty()) {
-                       // Throw IAE
-                       throw new IllegalArgumentException("emailWrapper.templateName is empty"); //NOI18N
-               } else if (emailWrapper.getTemplateVariables() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("emailWrapper.templateVariables is null"); //NOI18N
-               } else if (emailWrapper.getTemplateVariables().isEmpty()) {
-                       // Throw IAE
-                       throw new IllegalArgumentException("emailWrapper.templateVariables is empty"); //NOI18N
-               } else if (!emailWrapper.getTemplateVariables().containsKey("baseUrl")) { //NOI18N
-                       // Not set
-                       throw new IllegalArgumentException("emailWrapper.templateVariables.baseUrl is not set"); //NOI18N
-               } else if (null == writer) {
-                       // Throw NPE
-                       throw new NullPointerException("writer is null"); //NOI18N
-               } else if (writer.toString().isEmpty()) {
-                       // Throw IAE
-                       throw new IllegalArgumentException("writer.string is empty"); //NOI18N
-               } else if (null == mailSession) {
-                       // Throw NPE
-                       throw new NullPointerException("mailSession is null"); //NOI18N
-               }
-
-               // Get MIME message instance
-               MimeMessage message = new MimeMessage(mailSession);
-
-               // Set subject, recipients and body
-               message.setSubject(emailWrapper.getSubjectLine());
-               message.setRecipients(javax.mail.Message.RecipientType.TO, InternetAddress.parse(emailWrapper.getRecipientAddress().toString(), true));
-               message.setSentDate(new Date());
-               message.setText(writer.toString());
-               message.setHeader("MIME-Version", "1.0"); //NOI18N
-               message.setHeader("Content-Type", "text/plain; charset=UTF-8"); //NOI18N
-               message.setHeader("Content-Transfer-Encoding", "8bit"); //NOI18N
-
-               // Is property "errorsto" set ?
-               if ((this.properties.containsKey("mailer.errorsto")) && (!this.properties.getProperty("mailer.errorsto").isEmpty())) { //NOI18N
-                       // Use this
-                       message.setHeader("Errors-To", this.properties.getProperty("mailer.errorsto")); //NOI18N#
-               }
-
-               // Is the property "bouncesto" set?
-               if ((this.properties.containsKey("mailer.bouncesto")) && (!this.properties.getProperty("mailer.bouncesto").isEmpty())) { //NOI18N
-                       // Use this
-                       message.setHeader("Bounces-To", this.properties.getProperty("mailer.bouncesto")); //NOI18N
-               }
-
-               // Is the property "xloop" set?
-               if ((this.properties.containsKey("mailer.xloop")) && (!this.properties.getProperty("mailer.xloop").isEmpty())) { //NOI18N
-                       // Use this
-                       message.setHeader("X-Loop", this.properties.getProperty("mailer.xloop")); //NOI18N
-               }
-
-               // Directly send email
-               Transport.send(message);
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace("init: EXIT!"); //NOI18N
-       }
-
-       /**
-        * Getter for logger bean
-        * <p>
-        * @return Local logger bean
-        */
-       protected LoggerBeanLocal getLoggerBeanLocal () {
-               return this.loggerBeanLocal;
-       }
-
-       /**
-        * Sends given mail template to all addresses found in email wrapper
-        * <p>
-        * @param template Template to send
-        * @param context Velocity context
-        * @param emailWrapper Email wrapper containing recipient and such
-        * @param mailSession Mail session
-        * <p>
-        * @throws MessagingException If something happened on message delivery
-        */
-       protected void sendMailTemplate (final Template template, final VelocityContext context, final WrapableEmailDelivery emailWrapper, final Session mailSession) throws MessagingException {
-               // Log trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("sendMailTemplate: template={0},emailWrapper={1},mailSession={2} - CALLED!", template, emailWrapper, mailSession)); //NOI18N
-
-               // The parameters must be valid
-               if (null == template) {
-                       // Throw NPE
-                       throw new NullPointerException("template is null"); //NOI18N
-               } else if (null == emailWrapper) {
-                       // Throw NPE
-                       throw new NullPointerException("emailWrapper is null"); //NOI18N
-               } else if (emailWrapper.getLocale() == null) {
-                       // Throw it again
-                       throw new NullPointerException("emailWrapper.locale is null"); //NOI18N
-               } else if (emailWrapper.getRecipientAddress() == null) {
-                       // Throw it again
-                       throw new NullPointerException("emailWrapper.recipient is null"); //NOI18N
-               } else if (emailWrapper.getTemplateName() == null) {
-                       // Throw it again
-                       throw new NullPointerException("emailWrapper.templateName is null"); //NOI18N
-               } else if (emailWrapper.getTemplateName().isEmpty()) {
-                       // Throw IAE
-                       throw new IllegalArgumentException("emailWrapper.templateName is empty"); //NOI18N
-               } else if (emailWrapper.getTemplateVariables() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("emailWrapper.templateVariables is null"); //NOI18N
-               } else if (emailWrapper.getTemplateVariables().isEmpty()) {
-                       // Throw IAE
-                       throw new IllegalArgumentException("emailWrapper.templateVariables is empty"); //NOI18N
-               } else if (!emailWrapper.getTemplateVariables().containsKey("baseUrl")) { //NOI18N
-                       // Not set
-                       throw new IllegalArgumentException("emailWrapper.templateVariables.baseUrl is not set"); //NOI18N
-               } else if (null == mailSession) {
-                       // Throw NPE
-                       throw new NullPointerException("mailSession is null"); //NOI18N
-               }
-
-               // Get writer instance
-               StringWriter writer = new StringWriter();
-
-               // Merge template
-               template.merge(context, writer);
-
-               // Get all out and send it
-               this.sendMail(emailWrapper, writer, mailSession);
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace("init: EXIT!"); //NOI18N
-       }
-
-}
diff --git a/src/org/mxchange/jmailee/model/delivery/BaseMailerBean.java b/src/org/mxchange/jmailee/model/delivery/BaseMailerBean.java
new file mode 100644 (file)
index 0000000..b77b97b
--- /dev/null
@@ -0,0 +1,292 @@
+/*
+ * Copyright (C) 2016, 2017 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jmailee.model.delivery;
+
+import java.io.StringWriter;
+import java.text.MessageFormat;
+import java.util.Date;
+import java.util.Properties;
+import javax.mail.MessagingException;
+import javax.mail.Session;
+import javax.mail.Transport;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeMessage;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.runtime.RuntimeConstants;
+import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
+import org.mxchange.jcoreeelogger.beans.local.logger.Log;
+import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal;
+import org.mxchange.jmailee.model.delivery.wrapper.WrapableEmailDelivery;
+
+/**
+ * A general email bean for sending out mails from templates
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public abstract class BaseMailerBean implements DeliverableEmailLocal {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 14_598_912_753_106L;
+
+       /**
+        * Logger bean
+        */
+       @Log
+       private LoggerBeanLocal loggerBeanLocal;
+
+       /**
+        * Properties for this mailer
+        * <p>
+        * Valid are: - mailer.errorsto = Email address for "Errors-To" header -
+        * mailer.bouncesto = Email address for "Bounces-To" header (optional, if
+        * not set, errorsto must be set) - mailer.xloop = Email address for
+        * "X-Loop" header (optional, if not set, errorsto must be set)
+        */
+       private Properties properties;
+
+       /**
+        * Template engine
+        */
+       private final VelocityEngine templateEngine;
+
+       /**
+        * Default constructor
+        */
+       protected BaseMailerBean () {
+               try {
+                       // Get initial context
+                       Context context = new InitialContext();
+
+                       // Lookup logger
+                       this.loggerBeanLocal = (LoggerBeanLocal) context.lookup("java:global/jcore-logger-ejb/logger!org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal"); //NOI18N
+               } catch (final NamingException ex) {
+                       // Continue to throw
+                       throw new RuntimeException(MessageFormat.format("context.lookup() failed: {0}", ex.getMessage()), ex); //NOI18N
+               }
+
+               // Init template engine
+               this.templateEngine = new VelocityEngine();
+               this.templateEngine.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath"); //NOI18N
+               this.templateEngine.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName()); //NOI18N
+               this.templateEngine.init();
+       }
+
+       /**
+        * Sends an email to given email address with subject line.
+        * <p>
+        * @param emailAddress Email address for recipient
+        * @param subjectLine  Subject line
+        * @param writer       Body part
+        * @param mailSession  Corresponding mail session to use
+        * <p>
+        * @throws MessagingException If something happened on message delivery
+        */
+       private void deliverMail (final WrapableEmailDelivery emailWrapper, final StringWriter writer, final Session mailSession) throws MessagingException {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("sendMail: emailWrapper={0},body={1},mailSession={2} - CALLED!", emailWrapper, writer, mailSession)); //NOI18N
+
+               // Are the additional properties and all parameter set?
+               if (null == this.properties) {
+                       // Nothing set
+                       throw new NullPointerException("this.properties is null"); //NOI18N
+               } else if (null == emailWrapper) {
+                       // Throw NPE
+                       throw new NullPointerException("emailWrapper is null"); //NOI18N
+               } else if (emailWrapper.getLocale() == null) {
+                       // Throw it again
+                       throw new NullPointerException("emailWrapper.locale is null"); //NOI18N
+               } else if (emailWrapper.getRecipientAddress() == null) {
+                       // Throw it again
+                       throw new NullPointerException("emailWrapper.recipient is null"); //NOI18N
+               } else if (emailWrapper.getTemplateName() == null) {
+                       // Throw it again
+                       throw new NullPointerException("emailWrapper.templateName is null"); //NOI18N
+               } else if (emailWrapper.getTemplateName().isEmpty()) {
+                       // Throw IAE
+                       throw new IllegalArgumentException("emailWrapper.templateName is empty"); //NOI18N
+               } else if (emailWrapper.getTemplateVariables() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("emailWrapper.templateVariables is null"); //NOI18N
+               } else if (emailWrapper.getTemplateVariables().isEmpty()) {
+                       // Throw IAE
+                       throw new IllegalArgumentException("emailWrapper.templateVariables is empty"); //NOI18N
+               } else if (!emailWrapper.getTemplateVariables().containsKey("baseUrl")) { //NOI18N
+                       // Not set
+                       throw new IllegalArgumentException("emailWrapper.templateVariables.baseUrl is not set"); //NOI18N
+               } else if (null == writer) {
+                       // Throw NPE
+                       throw new NullPointerException("writer is null"); //NOI18N
+               } else if (writer.toString().isEmpty()) {
+                       // Throw IAE
+                       throw new IllegalArgumentException("writer.string is empty"); //NOI18N
+               } else if (null == mailSession) {
+                       // Throw NPE
+                       throw new NullPointerException("mailSession is null"); //NOI18N
+               }
+
+               // Get MIME message instance
+               MimeMessage message = new MimeMessage(mailSession);
+
+               // Set subject, recipients and body
+               message.setSubject(emailWrapper.getSubjectLine());
+               message.setRecipients(javax.mail.Message.RecipientType.TO, InternetAddress.parse(emailWrapper.getRecipientAddress().toString(), true));
+               message.setSentDate(new Date());
+               message.setText(writer.toString());
+               message.setHeader("MIME-Version", "1.0"); //NOI18N
+               message.setHeader("Content-Type", "text/plain; charset=UTF-8"); //NOI18N
+               message.setHeader("Content-Transfer-Encoding", "8bit"); //NOI18N
+
+               // Is property "errorsto" set ?
+               if ((this.properties.containsKey("mailer.errorsto")) && (!this.properties.getProperty("mailer.errorsto").isEmpty())) { //NOI18N
+                       // Use this
+                       message.setHeader("Errors-To", this.properties.getProperty("mailer.errorsto")); //NOI18N#
+               }
+
+               // Is the property "bouncesto" set?
+               if ((this.properties.containsKey("mailer.bouncesto")) && (!this.properties.getProperty("mailer.bouncesto").isEmpty())) { //NOI18N
+                       // Use this
+                       message.setHeader("Bounces-To", this.properties.getProperty("mailer.bouncesto")); //NOI18N
+               }
+
+               // Is the property "xloop" set?
+               if ((this.properties.containsKey("mailer.xloop")) && (!this.properties.getProperty("mailer.xloop").isEmpty())) { //NOI18N
+                       // Use this
+                       message.setHeader("X-Loop", this.properties.getProperty("mailer.xloop")); //NOI18N
+               }
+
+               // Directly send email
+               Transport.send(message);
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace("init: EXIT!"); //NOI18N
+       }
+
+       /**
+        * Sends given mail template to all addresses found in email wrapper
+        * <p>
+        * @param template     Template to send
+        * @param context      Velocity context
+        * @param emailWrapper Email wrapper containing recipient and such
+        * @param mailSession  Mail session
+        * <p>
+        * @throws MessagingException If something happened on message delivery
+        */
+       protected void deliverMailWithTemplate (final Template template, final VelocityContext context, final WrapableEmailDelivery emailWrapper, final Session mailSession) throws MessagingException {
+               // Log trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("sendMailTemplate: template={0},emailWrapper={1},mailSession={2} - CALLED!", template, emailWrapper, mailSession)); //NOI18N
+
+               // The parameters must be valid
+               if (null == template) {
+                       // Throw NPE
+                       throw new NullPointerException("template is null"); //NOI18N
+               } else if (null == emailWrapper) {
+                       // Throw NPE
+                       throw new NullPointerException("emailWrapper is null"); //NOI18N
+               } else if (emailWrapper.getLocale() == null) {
+                       // Throw it again
+                       throw new NullPointerException("emailWrapper.locale is null"); //NOI18N
+               } else if (emailWrapper.getRecipientAddress() == null) {
+                       // Throw it again
+                       throw new NullPointerException("emailWrapper.recipient is null"); //NOI18N
+               } else if (emailWrapper.getTemplateName() == null) {
+                       // Throw it again
+                       throw new NullPointerException("emailWrapper.templateName is null"); //NOI18N
+               } else if (emailWrapper.getTemplateName().isEmpty()) {
+                       // Throw IAE
+                       throw new IllegalArgumentException("emailWrapper.templateName is empty"); //NOI18N
+               } else if (emailWrapper.getTemplateVariables() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("emailWrapper.templateVariables is null"); //NOI18N
+               } else if (emailWrapper.getTemplateVariables().isEmpty()) {
+                       // Throw IAE
+                       throw new IllegalArgumentException("emailWrapper.templateVariables is empty"); //NOI18N
+               } else if (!emailWrapper.getTemplateVariables().containsKey("baseUrl")) { //NOI18N
+                       // Not set
+                       throw new IllegalArgumentException("emailWrapper.templateVariables.baseUrl is not set"); //NOI18N
+               } else if (null == mailSession) {
+                       // Throw NPE
+                       throw new NullPointerException("mailSession is null"); //NOI18N
+               }
+
+               // Get writer instance
+               StringWriter writer = new StringWriter();
+
+               // Merge template
+               template.merge(context, writer);
+
+               // Get all out and send it
+               this.deliverMail(emailWrapper, writer, mailSession);
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace("init: EXIT!"); //NOI18N
+       }
+
+       /**
+        * Getter for logger bean
+        * <p>
+        * @return Local logger bean
+        */
+       protected LoggerBeanLocal getLoggerBeanLocal () {
+               return this.loggerBeanLocal;
+       }
+
+       /**
+        * Setter for initial properties
+        * <p>
+        * @param properties Initial properties
+        */
+       @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter")
+       protected void setProperties (final Properties properties) {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("setProperties: properties={0} - CALLED!", properties)); //NOI18N
+
+               // Are all required properties set?
+               if (null == properties) {
+                       // Is null
+                       throw new NullPointerException("properties is null"); //NOI18N
+               } else if (!properties.containsKey("mailer.errorsto")) { //NOI18N
+                       // Errors-To not set
+                       throw new IllegalArgumentException("properties.mailer.errorsto is not set"); //NOI18N
+               } else if (!properties.containsKey("mailer.bouncesto")) { //NOI18N
+                       // Errors-To not set
+                       throw new IllegalArgumentException("properties.mailer.bouncesto is not set"); //NOI18N
+               }
+
+               // Set it here
+               this.properties = properties;
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace("setProperties: EXIT!"); //NOI18N
+       }
+
+       /**
+        * Getter for template engine instance
+        * <p>
+        * @return Template engine instance
+        */
+       protected VelocityEngine getTemplateEngine () {
+               return this.templateEngine;
+       }
+
+}
diff --git a/src/org/mxchange/jmailee/model/delivery/DeliverableEmail.java b/src/org/mxchange/jmailee/model/delivery/DeliverableEmail.java
deleted file mode 100644 (file)
index d845c1a..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2016, 2017 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jmailee.model.delivery;
-
-import java.io.Serializable;
-import java.util.Properties;
-import javax.ejb.Local;
-import org.apache.velocity.app.VelocityEngine;
-
-/**
- * An interface for email delivery classes
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Local
-public interface DeliverableEmail extends Serializable {
-
-       /**
-        * Getter for template engine
-        * <p>
-        * @return Template engine
-        */
-       VelocityEngine getTemplateEngine ();
-
-       /**
-        * Initializes the mailer with given properties. Please see BaseMailer for
-        * all supported and required properties.
-        * <p>
-        * @param properties Properties instance
-        */
-       void init (final Properties properties);
-
-}
diff --git a/src/org/mxchange/jmailee/model/delivery/DeliverableEmailLocal.java b/src/org/mxchange/jmailee/model/delivery/DeliverableEmailLocal.java
new file mode 100644 (file)
index 0000000..42b5148
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2016, 2017 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jmailee.model.delivery;
+
+import java.io.Serializable;
+import javax.ejb.Local;
+import javax.mail.MessagingException;
+import org.mxchange.jmailee.model.delivery.wrapper.WrapableEmailDelivery;
+
+/**
+ * An interface for email delivery classes
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Local
+public interface DeliverableEmailLocal extends Serializable {
+
+       /**
+        * Sends given deliverable mail instance. This must have set a template
+        * name, a recipient address and a subject line set.
+        * <p>
+        * @param emailWrapper Deliverable mail wrapper
+        *
+        * @throws MessagingException If something bad happened
+        */
+       void sendDeliverableMail (final WrapableEmailDelivery emailWrapper) throws MessagingException;
+
+}