]> git.mxchange.org Git - pizzaservice-ejb.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Tue, 6 Jun 2017 20:59:20 +0000 (22:59 +0200)
committerRoland Häder <roland@mxchange.org>
Tue, 6 Jun 2017 20:59:20 +0000 (22:59 +0200)
- moved generic code to jcoree

Signed-off-by: Roland Häder <roland@mxchange.org>
src/java/org/mxchange/jusercore/model/user/activity/PizzaUserActivityLogMessageBean.java
src/java/org/mxchange/jusercore/model/user/activity/PizzaUserActivitySessionBean.java

index 340852cdd5bec2c9a9e12dfe50846e325b0f8001..8ab55156138f6477a12770e8491ea4fa9af4b1c1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 Cho-Time GmbH
+ * 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
index 2ae18cca70ed9bb33afea7019d6d2da0b2192675..f802f91df4b899917e176831b95ea16646c3aa2f 100644 (file)
@@ -21,21 +21,11 @@ import java.util.Arrays;
 import java.util.List;
 import javax.ejb.EJBException;
 import javax.ejb.Stateless;
-import javax.faces.FacesException;
-import javax.jms.Connection;
 import javax.jms.JMSException;
-import javax.jms.MessageProducer;
 import javax.jms.ObjectMessage;
-import javax.jms.Queue;
-import javax.jms.QueueConnectionFactory;
-import javax.jms.Session;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
 import javax.persistence.Query;
 import org.mxchange.jcoreee.database.BaseDatabaseBean;
 import org.mxchange.jusercore.model.user.User;
-import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
 
 /**
  * An EJB for user activity log. This class extends BaseDatabaseBean and not
@@ -52,55 +42,12 @@ public class PizzaUserActivitySessionBean extends BaseDatabaseBean implements Us
         */
        private static final long serialVersionUID = 219_568_677_671_054L;
 
-       /**
-        * Connection
-        */
-       private Connection activityConnection;
-
-       /**
-        * Message producer
-        */
-       private MessageProducer activityMessageProducer;
-
-       /**
-        * Mailer message queue
-        */
-       private Queue activityQueue;
-
-       /**
-        * Session instance
-        */
-       private Session activitySession;
-
        /**
         * Default constructor
         */
        public PizzaUserActivitySessionBean () {
                // Call super constructor
-               super();
-
-               try {
-                       // Get initial context
-                       Context context = new InitialContext();
-
-                       // Get factory from JMS resource
-                       QueueConnectionFactory connectionFactory = (QueueConnectionFactory) context.lookup("jms/pizzaservice-queue-factory"); //NOI18N
-
-                       // Lookup queue
-                       this.activityQueue = (Queue) context.lookup("jms/jlanding-user-activity-log"); //NOI18N
-
-                       // Create connection
-                       this.activityConnection = connectionFactory.createConnection();
-
-                       // Init session instance
-                       this.activitySession = this.activityConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-                       // And message producer
-                       this.activityMessageProducer = this.activitySession.createProducer(this.activityQueue);
-               } catch (final NamingException | JMSException e) {
-                       // Continued to throw
-                       throw new FacesException(e);
-               }
+               super("jms/pizzaservice-queue-factory", "jms/pizzaservice-user-activity-log"); //NOI18N
        }
 
        @Override
@@ -134,11 +81,11 @@ public class PizzaUserActivitySessionBean extends BaseDatabaseBean implements Us
 
                try {
                        // Send out email change
-                       ObjectMessage message = this.activitySession.createObjectMessage();
+                       ObjectMessage message = this.getSession().createObjectMessage();
                        message.setObject(userActivity);
 
                        // Send message
-                       this.sendMessage(message, this.activityMessageProducer);
+                       this.sendMessage(message);
                } catch (final JMSException ex) {
                        // Throw again
                        throw new EJBException(ex);
@@ -202,7 +149,7 @@ public class PizzaUserActivitySessionBean extends BaseDatabaseBean implements Us
        @SuppressWarnings ("unchecked")
        public List<LogableUserActivity> fetchAllUsersActivityLogByMultipleType (final User user, final String[] activityTypes) {
                // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.fetchAllUsersActivityLogByType: user={1},activityTypes={2} - CALLED!", this.getClass().getSimpleName(), user, activityTypes)); //NOI18N
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.fetchAllUsersActivityLogByType: user={1},activityTypes={2} - CALLED!", this.getClass().getSimpleName(), user, Arrays.toString(activityTypes))); //NOI18N
 
                // Is user valid?
                if (null == user) {