]> git.mxchange.org Git - jcore-utils.git/blob - src/org/mxchange/jcoreee/beans/BaseFrameworkBean.java
a71f78869c3e4ac1850ab78020c4175820c28ffd
[jcore-utils.git] / src / org / mxchange / jcoreee / beans / BaseFrameworkBean.java
1 /*
2  * Copyright (C) 2015 Roland Haeder
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17 package org.mxchange.jcoreee.beans;
18
19 import java.io.Serializable;
20 import java.util.ResourceBundle;
21 import javax.ejb.EJB;
22 import org.mxchange.jcoreeelogger.beans.local.logger.Log;
23 import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal;
24
25 /**
26  * A general bean class. Do not put things in here that are not serializable.
27  * The logger is currently not serializable, so you will get error messages.
28  *
29  * @author Roland Haeder<roland@mxchange.org>
30  */
31 public abstract class BaseFrameworkBean implements Serializable {
32
33         /**
34          * Serial number
35          */
36         private static final long serialVersionUID = 83_258_139_481_372_814L;
37
38         /**
39          * Resource bundle
40          */
41         private ResourceBundle bundle;
42
43         /**
44          * Logger instance
45          */
46         @EJB(lookup = "java:global/jcore-ee-logger/logger")
47         @Log
48         private LoggerBeanLocal logger;
49
50         /**
51          * Protected constructor, please don't add init() call here.
52          */
53         protected BaseFrameworkBean () {
54         }
55
56         /**
57          * Super initialization method. If you wrie your initialization method,
58          * please call this method before (!) your own initialization.
59          *
60          * @throws RuntimeException If something unexpected happens
61          */
62         protected void genericInit () throws RuntimeException {
63                 // Init resource bundle
64                 this.bundle = ResourceBundle.getBundle("org/mxchange/localization/bundle");
65         }
66
67         /**
68          * Returns an EJB logger instance
69          *
70          * @return EBJ logger instance
71          */
72         protected LoggerBeanLocal getLogger () {
73                 return this.logger;
74         }
75
76         /**
77          * Getter for localized message from key
78          *
79          * @param key Key for message
80          * @return Localized message
81          */
82         protected String getMessage (final String key) {
83                 return this.bundle.getString(key);
84         }
85 }