From c0233a7d09e29955e45f75787e5f666d27ddb475 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sat, 8 Jul 2017 19:15:04 +0200 Subject: [PATCH] Please cherry-pick: - this message-driven bean has been moved to new project - also the mailer's initialization and config properties - removed genfiles.properties which is being regenerated anyway MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- nbproject/build-impl.xml | 14 +- nbproject/genfiles.properties | 8 - nbproject/project.properties | 11 +- nbproject/project.xml | 4 +- .../FinancialsEmailDeliveryMessageBean.java | 197 ------------------ .../org/mxchange/jmailer/config.properties | 21 -- 6 files changed, 14 insertions(+), 241 deletions(-) delete mode 100644 nbproject/genfiles.properties delete mode 100644 src/java/org/mxchange/jfinancials/mailer/model/delivery/FinancialsEmailDeliveryMessageBean.java delete mode 100644 src/java/org/mxchange/jmailer/config.properties diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml index 8b02b98..eeae150 100644 --- a/nbproject/build-impl.xml +++ b/nbproject/build-impl.xml @@ -812,7 +812,7 @@ exists or setup the property manually. For example like this: - + @@ -826,7 +826,7 @@ exists or setup the property manually. For example like this: - + @@ -861,7 +861,7 @@ exists or setup the property manually. For example like this: - + @@ -882,7 +882,7 @@ exists or setup the property manually. For example like this: - + @@ -903,7 +903,7 @@ exists or setup the property manually. For example like this: - + @@ -925,7 +925,7 @@ exists or setup the property manually. For example like this: - + @@ -1312,7 +1312,7 @@ exists or setup the property manually. For example like this: - + diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties deleted file mode 100644 index bba072b..0000000 --- a/nbproject/genfiles.properties +++ /dev/null @@ -1,8 +0,0 @@ -build.xml.data.CRC32=18f264f5 -build.xml.script.CRC32=7d41e0fd -build.xml.stylesheet.CRC32=5910fda3@1.51.1 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=e4e5030d -nbproject/build-impl.xml.script.CRC32=82e82586 -nbproject/build-impl.xml.stylesheet.CRC32=6096d939@1.55.1 diff --git a/nbproject/project.properties b/nbproject/project.properties index 030b3db..2f27fb8 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -70,7 +70,7 @@ javac.classpath=\ ${file.reference.jmailer-ee.jar}:\ ${reference.jfinancials-core.jar}:\ ${reference.jfinancials-lib.jar}:\ - ${reference.jfinancials-mailer.jar}:\ + ${reference.jfinancials-mailer-lib.jar}:\ ${file.reference.cdi-api.jar} javac.compilerargs=-Xlint:unchecked -Xlint:deprecation javac.debug=true @@ -98,15 +98,14 @@ javadoc.windowtitle=JFinancials EJBs meta.inf=${source.root}/conf meta.inf.excludes=sun-cmp-mappings.xml platform.active=default_platform -project.jfinancials-core=../../NetBeansProjects/jfinancials-core +project.jfinancials-core=../jfinancials-core +project.jfinancials-lib=../jfinancials-lib +project.jfinancials-mailer-lib=../jfinancials-mailer-lib project.juser-core=../juser-core project.license=agpl30 -project.jfinancials-lib=../jfinancials-lib -project.jfinancials-mailer=../../NetBeansProjects/jfinancials-mailer -project.serviceLocator.class=org.mxchange.jfinancials.mailer.model.delivery.FinancialsMailer reference.jfinancials-core.jar=${project.jfinancials-core}/dist/jfinancials-core.jar reference.jfinancials-lib.jar=${project.jfinancials-lib}/dist/jfinancials-lib.jar -reference.jfinancials-mailer.jar=${project.jfinancials-mailer}/dist/jfinancials-mailer.jar +reference.jfinancials-mailer-lib.jar=${project.jfinancials-mailer-lib}/dist/jfinancials-mailer-lib.jar resource.dir=setup run.test.classpath=\ ${javac.test.classpath}:\ diff --git a/nbproject/project.xml b/nbproject/project.xml index 0459fca..41c2b66 100644 --- a/nbproject/project.xml +++ b/nbproject/project.xml @@ -22,7 +22,7 @@ file.reference.jmailer-ee.jar reference.jfinancials-core.jar reference.jfinancials-lib.jar - reference.jfinancials-mailer.jar + reference.jfinancials-mailer-lib.jar file.reference.cdi-api.jar @@ -52,7 +52,7 @@ jar - jfinancials-mailer + jfinancials-mailer-lib jar jar diff --git a/src/java/org/mxchange/jfinancials/mailer/model/delivery/FinancialsEmailDeliveryMessageBean.java b/src/java/org/mxchange/jfinancials/mailer/model/delivery/FinancialsEmailDeliveryMessageBean.java deleted file mode 100644 index ac98876..0000000 --- a/src/java/org/mxchange/jfinancials/mailer/model/delivery/FinancialsEmailDeliveryMessageBean.java +++ /dev/null @@ -1,197 +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 Affero 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package org.mxchange.jfinancials.mailer.model.delivery; - -import java.io.Serializable; -import java.text.MessageFormat; -import java.util.Properties; -import java.util.ResourceBundle; -import javax.annotation.PostConstruct; -import javax.ejb.ActivationConfigProperty; -import javax.ejb.MessageDriven; -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.MessageListener; -import javax.jms.ObjectMessage; -import javax.mail.MessagingException; -import javax.naming.NamingException; -import org.mxchange.jfinancials.database.BaseFinancialsDatabaseBean; -import org.mxchange.jmailee.model.delivery.wrapper.WrapableEmailDelivery; - -/** - * A message-driven bean for sending out emails - *

- * @author Roland Häder - */ -@MessageDriven ( - name = "jfinancialsEmailDelivery", - description = "A message bean for email delivery", - activationConfig = { - @ActivationConfigProperty (propertyName = "destinationLookup", propertyValue = "jms/jfinancials-email-queue"), - @ActivationConfigProperty (propertyName = "destinationType", propertyValue = "javax.jms.Queue") - }) -public class FinancialsEmailDeliveryMessageBean extends BaseFinancialsDatabaseBean implements MessageListener { - - /** - * Serial number - */ - private static final long serialVersionUID = 75_638_176_619_024L; - - /** - * Configuration file - */ - private final String configFile = "org.mxchange.jmailer.config"; //NOI18N//NOI18N - - /** - * Mailer instance - */ - private final DeliverableFinancialsEmail mailer; - - /** - * Default constructor - *

- * @throws javax.naming.NamingException If a JNDI name could not be found - */ - public FinancialsEmailDeliveryMessageBean () throws NamingException { - // Call super constructor - super(); - - // Init mailer instance - this.mailer = new FinancialsMailer(); - } - - /** - * Post-construction - */ - @PostConstruct - public void init () { - // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.init: CALLED!", this.getClass().getSimpleName())); //NOI18N - - // Try to load bundle - ResourceBundle bundle = ResourceBundle.getBundle(this.configFile); - - // Debug message - this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.init: bundle={1}", this.getClass().getSimpleName(), bundle)); //NOI18N - - // The bunble should be valid - if (null == bundle) { - // Throw NPE - throw new NullPointerException(MessageFormat.format("bundle is null, maybe file {0} does not exist?", this.configFile)); //NOI18N - } - - // Init Properties - Properties properties = new Properties(); - - // Is the bundle not empty? - if (!bundle.keySet().isEmpty()) { - // Loop through all - for (final String key : bundle.keySet()) { - // Log debug message - this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.init: key={1}", this.getClass().getSimpleName(), key)); //NOI18N - - // Get string from bundle and set it in properties - properties.put(key, bundle.getString(key)); - } - } - - // Handle it over to the mailer - this.mailer.init(properties); - - // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.init: EXIT!", this.getClass().getSimpleName())); //NOI18N - } - - @Override - public void onMessage (final Message message) { - // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.onMessage: message={1} - CALLED!", this.getClass().getSimpleName(), message)); //NOI18N - - // The parameter should be valid - if (null == message) { - // Throw NPE - throw new NullPointerException("message is null"); //NOI18N - } else if (!(message instanceof ObjectMessage)) { - // Not implementing right interface - throw new IllegalArgumentException(MessageFormat.format("message={0} does not implemented ObjectMessage", message)); //NOI18N - } - - // Securely cast it - ObjectMessage objectMessage = (ObjectMessage) message; - - // Init variable - Serializable serializable; - - try { - // Get object from message - serializable = objectMessage.getObject(); - } catch (final JMSException ex) { - // Log it and don't continue any further - this.getLoggerBeanLocal().logException(ex); - return; - } - - // Debug message - this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.onMessage: serializable={1}", this.getClass().getSimpleName(), serializable)); //NOI18N - - // Okay, is it the right interface? - if (null == serializable) { - // Throw NPE - throw new NullPointerException("serializable is null"); //NOI18N - } else if (!(serializable instanceof WrapableEmailDelivery)) { - // Not correct object send - throw new IllegalArgumentException(MessageFormat.format("serializable={0} does not implement WrapableEmailDelivery", serializable)); //NOI18N - } - - // Securely cast it - WrapableEmailDelivery wrapper = (WrapableEmailDelivery) serializable; - - // Is all required set? - if (wrapper.getLocale() == null) { - // Throw NPE - throw new NullPointerException("wrapper.locale is null"); //NOI18N - } else if (wrapper.getRecipientAddress()== null) { - // Throw again ... - throw new NullPointerException("wrapper.recipientAddress is null"); //NOI18N - } else if (wrapper.getSubjectLine() == null) { - // ... and again - throw new NullPointerException("wrapper.subjectLine is null"); //NOI18N - } else if (wrapper.getSubjectLine().isEmpty()) { - // Is empty - throw new IllegalArgumentException("wrapper.subjectLine is empty"); //NOI18N - } else if (wrapper.getTemplateName() == null) { - // Throw NPE again - throw new NullPointerException("wrapper.templateName is null"); //NOI18N - } else if (wrapper.getTemplateName().isEmpty()) { - // Is empty - throw new IllegalArgumentException("wrapper.templateName is empty"); //NOI18N - } - - try { - // Send email out - this.mailer.sendDeliverableMail(wrapper); - } catch (final MessagingException ex) { - // Opps, something went wrong - this.getLoggerBeanLocal().logException(ex); - return; - } - - // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.onMessage - EXIT!", this.getClass().getSimpleName())); //NOI18N - } - -} diff --git a/src/java/org/mxchange/jmailer/config.properties b/src/java/org/mxchange/jmailer/config.properties deleted file mode 100644 index 5a02e31..0000000 --- a/src/java/org/mxchange/jmailer/config.properties +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright (C) 2016, 2017 Roland H\u00e4der -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero 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 Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -# Email address for "Errors-To" header -mailer.errorsto=you@foo.example -# Email address for "Bounces-To" header -mailer.bouncesto=you@foo.example -# Email address for "X-Loop" header -mailer.xloop=you@foo.example -- 2.39.5