]> git.mxchange.org Git - jcore-utils.git/blobdiff - src/org/mxchange/jcoreee/beans/BaseFrameworkBean.java
Added EJB logger
[jcore-utils.git] / src / org / mxchange / jcoreee / beans / BaseFrameworkBean.java
index 49677645a6298c9cea761b0575c8115c24e35e34..73d8345a658c645377bb519f875e46710e87004e 100644 (file)
  */
 package org.mxchange.jcoreee.beans;
 
-import javax.enterprise.context.Dependent;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
+import java.io.Serializable;
+import java.util.ResourceBundle;
+import javax.ejb.EJB;
+import org.mxchange.jcoreeelogger.beans.local.logger.Log;
+import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal;
 
 /**
  * A general bean class. Do not put things in here that are not serializable.
  * The logger is currently not serializable, so you will get error messages.
  *
- * @author Roland Haeder
+ * @author Roland Haeder<roland@mxchange.org>
  */
-@Dependent
-public abstract class BaseFrameworkBean implements FrameworkBean {
+public abstract class BaseFrameworkBean implements Serializable {
 
        /**
         * Serial number
         */
-       private static final long serialVersionUID = 83258139481372814L;
+       private static final long serialVersionUID = 83_258_139_481_372_814L;
 
        /**
-        * Class' logger
+        * Resource bundle
         */
-       private final Logger LOG;
+       private ResourceBundle bundle;
 
        /**
-        * Initializer
+        * Logger instance
         */
-       {
-               // Get logger
-               this.LOG = LogManager.getLogger(this);
-       }
+       @EJB
+       @Log
+       private LoggerBeanLocal logger;
 
        /**
         * Protected constructor, please don't add init() call here.
@@ -54,20 +54,32 @@ public abstract class BaseFrameworkBean implements FrameworkBean {
        }
 
        /**
-        * Getter for logger
+        * Super initialization method. If you wrie your initialization method,
+        * please call this method before (!) your own initialization.
         *
-        * @return Logger
+        * @throws RuntimeException If something unexpected happens
         */
-       protected Logger getLogger () {
-               return this.LOG;
+       protected void genericInit () throws RuntimeException {
+               // Init resource bundle
+               this.bundle = ResourceBundle.getBundle("org/mxchange/localization/bundle");
        }
 
        /**
-        * Super initialization method. If you overwrite this method, please call it before (!) your own initialization.
+        * Returns an EJB logger instance
         *
-        * @throws RuntimeException If something unexpected happens
+        * @return EBJ logger instance
+        */
+       protected LoggerBeanLocal getLogger () {
+               return this.logger;
+       }
+
+       /**
+        * Getter for localized message from key
+        *
+        * @param key Key for message
+        * @return Localized message
         */
-       protected void localInit () throws RuntimeException {
-               // Empty for now
+       protected String getMessage (final String key) {
+               return this.bundle.getString(key);
        }
 }