]> git.mxchange.org Git - jcore-utils.git/blobdiff - src/org/mxchange/jcoreee/bean/BaseBean.java
Updated copyright, changes in 2018 did take happen ...
[jcore-utils.git] / src / org / mxchange / jcoreee / bean / BaseBean.java
index ef7f11ddeac432bf1ddde1b63cd0e7d47a471157..8f0c2354808c4365fa8a9c4e13b100a393097843 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017 Roland Häder
+ * Copyright (C) 2017, 2018 Free Software Foundation
  *
  * 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
 package org.mxchange.jcoreee.bean;
 
 import java.io.Serializable;
-import java.security.Principal;
-import java.text.MessageFormat;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
 import javax.faces.FacesException;
-import javax.faces.application.FacesMessage;
-import javax.faces.context.FacesContext;
 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 org.mxchange.jcoreeelogger.beans.local.logger.Log;
-import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal;
 
 /**
  * A generic bean class
@@ -55,12 +45,6 @@ public abstract class BaseBean implements Serializable {
         */
        private Connection connection;
 
-       /**
-        * Logger instance
-        */
-       @Log
-       private LoggerBeanLocal loggerBeanLocal;
-
        /**
         * Message producer
         */
@@ -82,16 +66,6 @@ public abstract class BaseBean implements Serializable {
         * need to send emails.
         */
        protected BaseBean () {
-               try {
-                       // Get initial context
-                       Context context = new InitialContext();
-
-                       // Lookup logger
-                       this.loggerBeanLocal = (LoggerBeanLocal) context.lookup("java:global/jcore-logger-ejb/logger!org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal"); //NOI18N
-               } catch (final NamingException ex) {
-                       // Continue to throw
-                       throw new RuntimeException(MessageFormat.format("context.lookup() failed: {0}", ex.getMessage()), ex); //NOI18N
-               }
        }
 
        /**
@@ -110,10 +84,10 @@ public abstract class BaseBean implements Serializable {
                        Context context = new InitialContext();
 
                        // Get factory from JMS resource
-                       QueueConnectionFactory connectionFactory = (QueueConnectionFactory) context.lookup(factoryJndi); //NOI18N
+                       QueueConnectionFactory connectionFactory = (QueueConnectionFactory) context.lookup(factoryJndi);
 
                        // Lookup queue
-                       this.queue = (Queue) context.lookup(queueJndi); //NOI18N
+                       this.queue = (Queue) context.lookup(queueJndi);
 
                        // Create connection
                        this.connection = connectionFactory.createConnection();
@@ -129,39 +103,6 @@ public abstract class BaseBean implements Serializable {
                }
        }
 
-       /**
-        * Determines principal's name or returns null if no principal (security) is
-        * set.
-        * <p>
-        * @return Principal's name or null
-        */
-       protected String determinePrincipalName () {
-               // Get principal
-               Principal userPrincipal = FacesContext.getCurrentInstance().getExternalContext().getUserPrincipal();
-
-               // Init with null
-               String principalName = null;
-
-               // Is the principal set?
-               if (userPrincipal instanceof Principal) {
-                       // Get principal's name
-                       principalName = userPrincipal.getName();
-               }
-
-               // Return it
-               return principalName;
-       }
-
-
-       /**
-        * Getter for loggerBeanLocal
-        * <p>
-        * @return Logger instance
-        */
-       protected LoggerBeanLocal getLoggerBeanLocal () {
-               return this.loggerBeanLocal;
-       }
-
        /**
         * Getter for configured message producer instance
         * <p>
@@ -180,33 +121,4 @@ public abstract class BaseBean implements Serializable {
                return this.session;
        }
 
-
-       /**
-        * Sends given message to configured queue
-        * <p>
-        * @param message Message to send
-        * <p>
-        * @throws JMSException if something went wrong
-        */
-       protected void sendMessage (final ObjectMessage message) throws JMSException {
-               // Trace message
-               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 == this.getMessageProducer()) {
-                       // Throw NPE again
-                       throw new NullPointerException("this.messageProvider is null"); //NOI18N
-               }
-
-               // Send it
-               this.getMessageProducer().send(message);
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.sendMessage: EXIT!", this.getClass().getSimpleName())); //NOI18N
-       }
-
-
 }