]> git.mxchange.org Git - pizzaservice-ejb.git/commitdiff
Continued a bit:
authorRoland Häder <roland@mxchange.org>
Wed, 18 May 2016 09:01:48 +0000 (11:01 +0200)
committerRoland Haeder <roland@mxchange.org>
Fri, 20 May 2016 21:19:26 +0000 (23:19 +0200)
- renamed to have project name in it
- sending out mails over a message-driven bean is an asynchronous approach and will keep the other EJBs running fast
- use class, not interface everywhere

Signed-off-by: Roland Häder <roland@mxchange.org>
src/java/org/mxchange/jusercore/model/user/PizzaUserSessionBean.java
src/java/org/mxchange/pizzaapplication/mailer/model/delivery/EmailDeliveryMessageBean.java [deleted file]
src/java/org/mxchange/pizzaapplication/mailer/model/delivery/PizzaEmailDeliveryMessageBean.java [new file with mode: 0644]

index ddd1d20d87246cfb16a6b4645282b0b50e7b81fb..2174f56dfb639ae10553488cf1c8760980f11286 100644 (file)
@@ -186,7 +186,7 @@ public class PizzaUserSessionBean extends BasePizzaDatabaseBean implements UserS
                }
 
                // Try to locate it
-               Query query = this.getEntityManager().createNamedQuery("SearchUserByName", User.class); //NOI18N
+               Query query = this.getEntityManager().createNamedQuery("SearchUserByName", LoginUser.class); //NOI18N
 
                // Set parameter
                query.setParameter("param", user.getUserName()); //NOI18N
@@ -228,7 +228,7 @@ public class PizzaUserSessionBean extends BasePizzaDatabaseBean implements UserS
                }
 
                // Create query instance
-               Query query = this.getEntityManager().createNamedQuery("SearchUserById", User.class); //NOI18N
+               Query query = this.getEntityManager().createNamedQuery("SearchUserById", LoginUser.class); //NOI18N
 
                // Set user id
                query.setParameter("id", userId); //NOI18N
@@ -311,7 +311,7 @@ public class PizzaUserSessionBean extends BasePizzaDatabaseBean implements UserS
                }
 
                // Generate query
-               Query query = this.getEntityManager().createNamedQuery("SearchUserById", User.class); //NOI18N
+               Query query = this.getEntityManager().createNamedQuery("SearchUserById", LoginUser.class); //NOI18N
 
                // Set parameter
                query.setParameter("id", user.getUserId()); //NOI18N
@@ -358,7 +358,7 @@ public class PizzaUserSessionBean extends BasePizzaDatabaseBean implements UserS
                }
 
                // Generate query
-               Query query = this.getEntityManager().createNamedQuery("SearchUserById", User.class); //NOI18N
+               Query query = this.getEntityManager().createNamedQuery("SearchUserById", LoginUser.class); //NOI18N
 
                // Set parameter
                query.setParameter("id", userId); //NOI18N
@@ -405,7 +405,7 @@ public class PizzaUserSessionBean extends BasePizzaDatabaseBean implements UserS
                }
 
                // Generate query
-               Query query = this.getEntityManager().createNamedQuery("SearchUserByName", User.class); //NOI18N
+               Query query = this.getEntityManager().createNamedQuery("SearchUserByName", LoginUser.class); //NOI18N
 
                // Set parameter
                query.setParameter("param", userName); //NOI18N
@@ -443,7 +443,7 @@ public class PizzaUserSessionBean extends BasePizzaDatabaseBean implements UserS
                }
 
                // Generate query
-               Query query = this.getEntityManager().createNamedQuery("SearchUserByEmailAddress", User.class); //NOI18N
+               Query query = this.getEntityManager().createNamedQuery("SearchUserByEmailAddress", LoginUser.class); //NOI18N
 
                // Set parameter
                query.setParameter("param", user.getUserContact().getContactEmailAddress()); //NOI18N
@@ -484,7 +484,7 @@ public class PizzaUserSessionBean extends BasePizzaDatabaseBean implements UserS
                }
 
                // Generate query
-               Query query = this.getEntityManager().createNamedQuery("SearchUserByName", User.class); //NOI18N
+               Query query = this.getEntityManager().createNamedQuery("SearchUserByName", LoginUser.class); //NOI18N
 
                // Set parameter
                query.setParameter("param", user.getUserName()); //NOI18N
diff --git a/src/java/org/mxchange/pizzaapplication/mailer/model/delivery/EmailDeliveryMessageBean.java b/src/java/org/mxchange/pizzaapplication/mailer/model/delivery/EmailDeliveryMessageBean.java
deleted file mode 100644 (file)
index c92c026..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (C) 2016 Cho-Time GmbH
- *
- * 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/>.
- */
-package org.mxchange.pizzaapplication.mailer.model.delivery;
-
-import de.chotime.landingpage.database.BaseLandingDatabaseBean;
-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 javax.ejb.ActivationConfigProperty;
-import javax.ejb.MessageDriven;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageListener;
-import javax.jms.ObjectMessage;
-
-/**
- * A message-driven bean for sending out emails
- * <p>
- * @author Roland Haeder<rhaeder@cho-time.de>
- */
-@MessageDriven (activationConfig = {
-       @ActivationConfigProperty (propertyName = "destinationLookup", propertyValue = "jms/jlandingpage-email-queue"),
-       @ActivationConfigProperty (propertyName = "destinationType", propertyValue = "javax.jms.Queue")
-})
-public class EmailDeliveryMessageBean extends BaseLandingDatabaseBean implements MessageListener {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 75_638_176_619_024L;
-
-       /**
-        * Mailer instance
-        */
-       private final DeliverableLandingEmail mailer;
-
-       /**
-        * Default constructor
-        */
-       public EmailDeliveryMessageBean () {
-               // Init mailer instance
-               this.mailer = new LandingMailer();
-       }
-
-       @Override
-       public void onMessage (final Message message) {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("onMessage: message={0} - CALLED!", 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("onMessage: serializable={0}", serializable)); //NOI18N
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace("onMessage - EXIT!"); //NOI18N
-       }
-
-}
diff --git a/src/java/org/mxchange/pizzaapplication/mailer/model/delivery/PizzaEmailDeliveryMessageBean.java b/src/java/org/mxchange/pizzaapplication/mailer/model/delivery/PizzaEmailDeliveryMessageBean.java
new file mode 100644 (file)
index 0000000..3df748b
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2016 Cho-Time GmbH
+ *
+ * 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/>.
+ */
+package org.mxchange.pizzaapplication.mailer.model.delivery;
+
+import de.chotime.landingpage.database.BaseLandingDatabaseBean;
+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 javax.ejb.ActivationConfigProperty;
+import javax.ejb.MessageDriven;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.ObjectMessage;
+
+/**
+ * A message-driven bean for sending out emails
+ * <p>
+ * @author Roland Haeder<rhaeder@cho-time.de>
+ */
+@MessageDriven (activationConfig = {
+       @ActivationConfigProperty (propertyName = "destinationLookup", propertyValue = "jms/jlandingpage-email-queue"),
+       @ActivationConfigProperty (propertyName = "destinationType", propertyValue = "javax.jms.Queue")
+})
+public class PizzaEmailDeliveryMessageBean extends BaseLandingDatabaseBean implements MessageListener {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 75_638_176_619_024L;
+
+       /**
+        * Mailer instance
+        */
+       private final DeliverableLandingEmail mailer;
+
+       /**
+        * Default constructor
+        */
+       public PizzaEmailDeliveryMessageBean () {
+               // Init mailer instance
+               this.mailer = new LandingMailer();
+       }
+
+       @Override
+       public void onMessage (final Message message) {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("onMessage: message={0} - CALLED!", 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("onMessage: serializable={0}", serializable)); //NOI18N
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace("onMessage - EXIT!"); //NOI18N
+       }
+
+}