3 import java.util.Locale;
4 import java.util.MissingResourceException;
5 import java.util.ResourceBundle;
6 import java.util.concurrent.ConcurrentHashMap;
8 import net.jaekl.qd.QDBundleFactory;
10 public class CfbBundle {
11 public static final String CANNOT_CONNECT = "cannot.connect.to.db";
13 final static String BUNDLE_NAME = "cfb";
15 static ConcurrentHashMap<Locale, CfbBundle> m_bundleMap = new ConcurrentHashMap<Locale, CfbBundle>();
17 ResourceBundle m_bundle;
19 public static CfbBundle getInst(Locale locale) {
20 CfbBundle result = m_bundleMap.get(locale);
22 synchronized(CfbBundle.class) {
23 result = m_bundleMap.get(locale);
25 result = new CfbBundle(locale);
27 m_bundleMap.put(locale, result);
33 private CfbBundle(Locale locale) {
34 m_bundle = QDBundleFactory.getInst().getBundle(BUNDLE_NAME, locale);
37 public String get(String key) {
39 if (null != m_bundle) {
40 return m_bundle.getString(key);
43 catch (MissingResourceException exc) {
44 // Make it clear that something has gone wrong.
45 exc.printStackTrace();
46 // Fall through to the fallback behaviour below
48 return "[" + key + "]";