From bd40d454894b54b4e2c1008f442219e671eeb1d0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Tue, 6 Jun 2017 22:47:50 +0200 Subject: [PATCH] Continued: - moved generic code to jcoree MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../jjobs/database/BaseJobsDatabaseBean.java | 58 +------------------ 1 file changed, 3 insertions(+), 55 deletions(-) diff --git a/src/org/mxchange/jjobs/database/BaseJobsDatabaseBean.java b/src/org/mxchange/jjobs/database/BaseJobsDatabaseBean.java index c80efda..5044254 100644 --- a/src/org/mxchange/jjobs/database/BaseJobsDatabaseBean.java +++ b/src/org/mxchange/jjobs/database/BaseJobsDatabaseBean.java @@ -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 BaseJobsDatabaseBean 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 BaseJobsDatabaseBean () { // 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.queue = (Queue) context.lookup("jms/jjobs-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/jjobs-queue-factory", "jms/jjobs-email-queue"); //NOI18N } /** @@ -561,11 +509,11 @@ public abstract class BaseJobsDatabaseBean 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); -- 2.39.5