Bring things to a state where the basic DB schema gets auto-created if it doesn't...
[cfb.git] / prod / net / jaekl / qd / QDBundleFactory.java
1 // Copyright (C) 2004, 2014 Christian Jaekl
2
3 // Central spot from which to access ResourceBundles.
4 // This made more sense with earlier versions of Java, where the specification did not 
5 // guarantee that ResourceBundles would be cached.  Java 7 and later cache by default,
6 // but it still seems prudent to centralize accesses to resources here so that we have 
7 // control in case we want to implement our own cache, or override certain behaviours.
8 // 
9 // Note that we rely on the JVM's caching, to avoid unnecessary overhead.
10 // See http://java2go.blogspot.ca/2010/03/dont-be-smart-never-implement-resource.html
11
12 package net.jaekl.qd;
13
14 import java.util.Locale;
15 import java.util.ResourceBundle;
16
17 public class QDBundleFactory {
18         static volatile QDBundleFactory m_inst; // singleton instance
19         
20         private QDBundleFactory() {
21                 // no-op
22         }
23         
24         public static QDBundleFactory getInst() {
25                 QDBundleFactory result = m_inst;
26                 if (null == result) {
27                         synchronized(QDBundleFactory.class) {
28                                 if (null == m_inst) {
29                                         m_inst = new QDBundleFactory();
30                                 }
31                                 result = m_inst;
32                         }
33                 }
34                 return result;
35         }
36         
37         public ResourceBundle getBundle(String baseName, Locale locale) {
38                 return ResourceBundle.getBundle(baseName, locale);
39         }
40 }