diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/resources/Resources.java @ 2290:6f4a1f513e89

Calculation error report: i18n the km of the error report. flys-artifacts/trunk@3954 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Wed, 08 Feb 2012 09:33:06 +0000
parents 2898b1ff6013
children 79e7bba0f593
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/resources/Resources.java	Tue Feb 07 18:12:08 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/resources/Resources.java	Wed Feb 08 09:33:06 2012 +0000
@@ -37,7 +37,7 @@
      *
      * @return the supported locales.
      */
-    public Locale[] getLocales() {
+    public synchronized Locale [] getLocales() {
         if (locales == null) {
             readLocales();
         }
@@ -58,10 +58,15 @@
     }
 
 
-    public static Locale getLocale(CallMeta meta) {
+    private static synchronized void ensureInstance() {
         if (INSTANCE == null) {
             INSTANCE = new Resources();
         }
+    }
+
+
+    public static Locale getLocale(CallMeta meta) {
+        ensureInstance();
 
         Locale[] locales = INSTANCE.getLocales();
         return meta.getPreferredLocale(locales);
@@ -80,9 +85,8 @@
      * @return the translated message.
      */
     public static String getMsg(CallMeta meta, String key, String def) {
-        if (INSTANCE == null) {
-            INSTANCE = new Resources();
-        }
+
+        ensureInstance();
 
         Locale[] locales = INSTANCE.getLocales();
         Locale   locale  = meta.getPreferredLocale(locales);

http://dive4elements.wald.intevation.org