*/
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.
}
/**
- * 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 void genericInit () throws RuntimeException {
- // Empty for now
+ 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);
}
}