]> git.mxchange.org Git - pizzaservice-war.git/blob - src/java/org/mxchange/pizzaapplication/beans/AbstractWebBean.java
Need to clear these properties
[pizzaservice-war.git] / src / java / org / mxchange / pizzaapplication / beans / AbstractWebBean.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.pizzaapplication.beans;
18
19 import java.io.Serializable;
20 import java.util.ResourceBundle;
21
22 /**
23  * An abstract web web bean for web applications. This class currently only
24  * handles loading the resource bundle (i18n).
25  *
26  * @author Roland Haeder
27  */
28 public abstract class AbstractWebBean implements Serializable {
29
30         /**
31          * Serial number
32          */
33         private static final long serialVersionUID = 48_475_834_783_473_187L;
34
35         /**
36          * Bundle instance
37          */
38         private final ResourceBundle bundle;
39
40         /**
41          * Protectd constructor
42          */
43         protected AbstractWebBean () {
44                 // Load resource bundle
45                 this.bundle = ResourceBundle.getBundle("org/mxchange/localization/bundle");
46         }
47
48         /**
49          * Getter for bundle instance
50          *
51          * @return Bundle instance
52          */
53         protected ResourceBundle getBundle () {
54                 return this.bundle;
55         }
56
57         /**
58          * Getter for message from given key
59          *
60          * @param key Key to get message from
61          * @return Message
62          */
63         protected String getMessageStringFromKey (final String key) {
64                 // Is the bundle loaded?
65                 if (this.getBundle() == null) {
66                         // Abort here
67                         throw new NullPointerException("bundle is null"); //NOI18N
68                 }
69
70                 // Return message
71                 return this.getBundle().getString(key);
72         }
73 }