]> git.mxchange.org Git - pizzaservice-ejb.git/commitdiff
Continued a bit:
authorRoland Häder <roland@mxchange.org>
Wed, 18 May 2016 15:53:05 +0000 (17:53 +0200)
committerRoland Haeder <roland@mxchange.org>
Fri, 20 May 2016 21:24:08 +0000 (23:24 +0200)
- load properties in init() method (post-construction)
- added config.properties

Signed-off-by: Roland Häder <roland@mxchange.org>
src/java/org/mxchange/jmailer/config.properties [new file with mode: 0644]
src/java/org/mxchange/pizzaapplication/mailer/model/delivery/PizzaEmailDeliveryMessageBean.java

diff --git a/src/java/org/mxchange/jmailer/config.properties b/src/java/org/mxchange/jmailer/config.properties
new file mode 100644 (file)
index 0000000..4d2c1cf
--- /dev/null
@@ -0,0 +1,21 @@
+# Copyright (C) 2016 Roland Haeder
+#
+# 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 <http://www.gnu.org/licenses/>.
+
+# 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
index 3df748b4b566570bcdbdb9a38c6e617fc44b37be..d6f17d4497e9c1f1664e79117742ff296a9c4ea0 100644 (file)
@@ -21,6 +21,9 @@ import de.chotime.landingpage.mailer.model.delivery.DeliverableLandingEmail;
 import de.chotime.landingpage.mailer.model.delivery.LandingMailer;
 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;
@@ -49,6 +52,11 @@ public class PizzaEmailDeliveryMessageBean extends BaseLandingDatabaseBean imple
         */
        private final DeliverableLandingEmail mailer;
 
+       /**
+        * Configuration file
+        */
+       private final String configFile = "org.mxchange.jmailer.config"; //NOI18N
+
        /**
         * Default constructor
         */
@@ -92,4 +100,45 @@ public class PizzaEmailDeliveryMessageBean extends BaseLandingDatabaseBean imple
                this.getLoggerBeanLocal().logTrace("onMessage - EXIT!"); //NOI18N
        }
 
+       /**
+        * Post-construction
+        */
+       @PostConstruct
+       public void init () {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace("init: CALLED!"); //NOI18N
+
+               // Try to load bundle
+               ResourceBundle bundle = ResourceBundle.getBundle(this.configFile);
+
+               // Debug message
+               this.getLoggerBeanLocal().logDebug(MessageFormat.format("init: bundle={0}", 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("init: key={0}", 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("init: EXIT!"); //NOI18N
+       }
 }