]> 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 9d70e5059f65d716d5266e15b03c7de0e6488400..73d8345a658c645377bb519f875e46710e87004e 100644 (file)
 package org.mxchange.jcoreee.beans;
 
 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>
  */
 public abstract class BaseFrameworkBean implements Serializable {
 
@@ -31,6 +35,18 @@ public abstract class BaseFrameworkBean implements Serializable {
         */
        private static final long serialVersionUID = 83_258_139_481_372_814L;
 
+       /**
+        * Resource bundle
+        */
+       private ResourceBundle bundle;
+
+       /**
+        * Logger instance
+        */
+       @EJB
+       @Log
+       private LoggerBeanLocal logger;
+
        /**
         * Protected constructor, please don't add init() call here.
         */
@@ -38,11 +54,32 @@ public abstract class BaseFrameworkBean implements Serializable {
        }
 
        /**
-        * Super initialization method. If you overwrite this method, please call it before (!) your own initialization.
+        * Super initialization method. If you wrie your initialization method,
+        * please call this method before (!) your own initialization.
         *
         * @throws RuntimeException If something unexpected happens
         */
        protected void genericInit () throws RuntimeException {
-               // Empty for now
+               // Init resource bundle
+               this.bundle = ResourceBundle.getBundle("org/mxchange/localization/bundle");
+       }
+
+       /**
+        * Returns an EJB logger instance
+        *
+        * @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 String getMessage (final String key) {
+               return this.bundle.getString(key);
        }
 }