1 /**
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 *
6 * If it is not possible or desirable to put the notice in a particular
7 * file, then You may include the notice in a location (such as a LICENSE
8 * file in a relevant directory) where a recipient would be likely to look
9 * for such a notice.
10
11 *
12 */
13
14 /* ---------------------------------------------------------------------------
15 * U.S. Government, Department of the Army
16 * Army Materiel Command
17 * Research Development Engineering Command
18 * Communications Electronics Research Development and Engineering Center
19 * ---------------------------------------------------------------------------
20 */
21
22 package org.miloss.fgsms.common;
23
24 import java.util.Locale;
25 import java.util.ResourceBundle;
26 import org.apache.log4j.Level;
27
28
29 /**
30 *
31 * @author AO
32 */
33 public class BundleLoader {
34
35 private static ResourceBundle bundle = null;
36
37 /**
38 * loads a resource from the properties file
39 *
40 * @param key
41 * @return
42 */
43 public static String getBundleString(String key) {
44 SetupBundle();
45 return bundle.getString(key);
46 }
47 private static Logger log = Logger.getLogger("org.miloss.fgsms.common/SLAResources");
48 private static synchronized void SetupBundle() {
49 if (bundle == null) {
50 try {
51 bundle = ResourceBundle.getBundle("org.miloss.fgsms.common/SLAResources", Locale.getDefault());
52 } catch (Exception ex) {
53 log.log(Level.FATAL, "unable to load the resource bundle for " + "org.miloss.fgsms.common/SLAResources" + Locale.getDefault().toString(), ex);
54 }
55 }
56 if (bundle == null) {
57 try {
58 bundle = ResourceBundle.getBundle("org.miloss.fgsms.common/SLAResources");
59 } catch (Exception ex) {
60 log.log(Level.FATAL, "unable to load the resource bundle for " + "org.miloss.fgsms.common/SLAResources", ex);
61 }
62 }
63 }
64 }