X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2Forg%2Fmxchange%2Fjcoreee%2Fdatabase%2FBaseDatabaseBean.java;h=8e3f9f31e760cc6138d34352169c8d9ff0853f42;hb=479979d00f68f66eae2920cab2dc7051fafa01fd;hp=07e54ae2a5224b37b75d68c29bcfb639da4669ec;hpb=9822626f10b3b2d14cc994f7af09e13ec9522fde;p=jcore-utils.git diff --git a/src/org/mxchange/jcoreee/database/BaseDatabaseBean.java b/src/org/mxchange/jcoreee/database/BaseDatabaseBean.java index 07e54ae..8e3f9f3 100644 --- a/src/org/mxchange/jcoreee/database/BaseDatabaseBean.java +++ b/src/org/mxchange/jcoreee/database/BaseDatabaseBean.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 Roland Haeder + * 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 General Public License as published by @@ -16,25 +16,24 @@ */ package org.mxchange.jcoreee.database; -import java.io.Serializable; import java.text.MessageFormat; import javax.jms.JMSException; -import javax.jms.MessageProducer; import javax.jms.ObjectMessage; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; +import org.mxchange.jcoreee.bean.BaseBean; import org.mxchange.jcoreeelogger.beans.local.logger.Log; import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal; /** * A helper class for beans that access the database. *
- * @author Roland Haeder
+ * @param factoryJndi JNDI name for queue factory
+ * @param queueJndi JNDI name for email queue
+ */
+ protected BaseDatabaseBean (final String factoryJndi, final String queueJndi) {
+ // Call super constructor
+ super(factoryJndi, queueJndi);
+
+ // Init logger instance
+ this.initLoggerInstance();
+ }
+
+ /**
+ * Initializes logger instance
+ */
+ private void initLoggerInstance () {
try {
// Get initial context
Context context = new InitialContext();
@@ -91,25 +117,24 @@ public abstract class BaseDatabaseBean implements Serializable {
* Sends given message to configured queue
*
* @param message Message to send
- * @param messageProducer Message producer
*
* @throws JMSException if something went wrong
*/
- protected void sendMessage (final ObjectMessage message, final MessageProducer messageProducer) throws JMSException {
+ protected void sendMessage (final ObjectMessage message) throws JMSException {
// Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.sendMessage: message={1},messageProducer={2} - CALLED!", this.getClass().getSimpleName(), message, messageProducer)); //NOI18N
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.sendMessage: message={1} - CALLED!", this.getClass().getSimpleName(), message)); //NOI18N
// The parameter should be valid
if (null == message) {
// Throw NPE
throw new NullPointerException("message is null"); //NOI18N
- } else if (null == messageProducer) {
+ } else if (this.getMessageProducer() == null) {
// Throw NPE again
- throw new NullPointerException("messageProvider is null"); //NOI18N
+ throw new NullPointerException("this.messageProvider is null"); //NOI18N
}
// Send it
- messageProducer.send(message);
+ this.getMessageProducer().send(message);
// Trace message
this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.sendMessage: EXIT!", this.getClass().getSimpleName())); //NOI18N