]> git.mxchange.org Git - jjobs-ejb.git/commitdiff
moved generic code to jcoreee
authorRoland Häder <roland@mxchange.org>
Tue, 6 Jun 2017 20:58:10 +0000 (22:58 +0200)
committerRoland Häder <roland@mxchange.org>
Tue, 6 Jun 2017 20:58:10 +0000 (22:58 +0200)
Signed-off-by: Roland Häder <roland@mxchange.org>
src/java/org/mxchange/jusercore/model/user/activity/JobsUserActivityLogMessageBean.java
src/java/org/mxchange/jusercore/model/user/activity/JobsUserActivitySessionBean.java

index 7915fe36373f52ac451ebb466365e0ac92778cb2..a02777336e1e26b6576c5bad7dc36906441208f8 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 3c79b7b009bb14a49402de0f6e056a8266788b45..c73f81e6ec7c6c397d3ee42d3158f313d2f50021 100644 (file)
@@ -21,17 +21,8 @@ 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;
@@ -51,55 +42,12 @@ public class JobsUserActivitySessionBean extends BaseDatabaseBean implements Use
         */
        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 JobsUserActivitySessionBean () {
                // Call super constructor
-               super();
-
-               try {
-                       // Get initial context
-                       Context context = new InitialContext();
-
-                       // Get factory from JMS resource
-                       QueueConnectionFactory connectionFactory = (QueueConnectionFactory) context.lookup("jms/jjobs-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/jjobs-queue-factory", "jms/jjobs-user-activity-log"); //NOI18N
        }
 
        @Override
@@ -133,11 +81,11 @@ public class JobsUserActivitySessionBean extends BaseDatabaseBean implements Use
 
                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);