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

Signed-off-by: Roland Häder <roland@mxchange.org>
src/org/mxchange/addressbook/database/BaseAddressbookDatabaseBean.java

index c2a38e54806dd6af551ff763bc275f334b5b9895..7ef7547e1d0f9840fc2ff9fbe0f0000027a2a4ba 100644 (file)
@@ -21,18 +21,9 @@ import java.util.GregorianCalendar;
 import java.util.Objects;
 import java.util.Properties;
 import javax.ejb.EJBException;
-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.mail.Address;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
 import org.mxchange.jcontacts.contact.Contact;
 import org.mxchange.jcoreee.database.BaseDatabaseBean;
 import org.mxchange.jmailee.model.delivery.wrapper.EmailDeliveryWrapper;
@@ -57,55 +48,12 @@ public abstract class BaseAddressbookDatabaseBean extends BaseDatabaseBean {
         */
        private static final long serialVersionUID = 12_895_410_275_811_963L;
 
-       /**
-        * Connection
-        */
-       private Connection connection;
-
-       /**
-        * Message producer
-        */
-       private MessageProducer messageProducer;
-
-       /**
-        * Mailer message queue
-        */
-       private Queue queue;
-
-       /**
-        * Session instance
-        */
-       private Session session;
-
        /**
         * Protected constructor
         */
        protected BaseAddressbookDatabaseBean () {
                // Call super constructor
-               super();
-
-               try {
-                       // Get initial context
-                       Context context = new InitialContext();
-
-                       // Get factory from JMS resource
-                       QueueConnectionFactory connectionFactory = (QueueConnectionFactory) context.lookup("jms/addressbook-queue-factory"); //NOI18N
-
-                       // Lookup queue
-                       this.queue = (Queue) context.lookup("jms/addressbook-email-queue"); //NOI18N
-
-                       // Create connection
-                       this.connection = connectionFactory.createConnection();
-
-                       // Init session instance
-                       this.session = this.connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-                       // And message producer
-                       this.messageProducer = this.session.createProducer(this.queue);
-               } catch (final NamingException | JMSException e) {
-                       // Continued to throw
-                       throw new FacesException(e);
-               }
+               super("jms/addressbook-queue-factory", "jms/addressbook-email-queue"); //NOI18N
        }
 
        /**
@@ -548,11 +496,11 @@ public abstract class BaseAddressbookDatabaseBean extends BaseDatabaseBean {
 
                try {
                        // Send out email change
-                       ObjectMessage message = this.session.createObjectMessage();
+                       ObjectMessage message = this.getSession().createObjectMessage();
                        message.setObject(emailWrapper);
 
                        // Send message
-                       this.sendMessage(message, this.messageProducer);
+                       this.sendMessage(message);
                } catch (final JMSException ex) {
                        // Throw again
                        throw new EJBException(ex);