Author: orudyy
Date: Wed Dec  5 14:25:43 2012
New Revision: 1417439

URL: http://svn.apache.org/viewvc?rev=1417439&view=rev
Log:
QPID-4390: Add JVM system property to set the broker locale

Added:
    
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/messages/Broker_logmessages_uk_UA.properties
    
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/BrokerPropertiesTest.java
Modified:
    
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/BrokerProperties.java
    
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/velocity/templates/org/apache/qpid/server/logging/messages/LogMessages.vm

Modified: 
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/BrokerProperties.java
URL: 
http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/BrokerProperties.java?rev=1417439&r1=1417438&r2=1417439&view=diff
==============================================================================
--- 
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/BrokerProperties.java
 (original)
+++ 
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/BrokerProperties.java
 Wed Dec  5 14:25:43 2012
@@ -1,5 +1,7 @@
 package org.apache.qpid.server.configuration;
 
+import java.util.Locale;
+
 /**
  * Declares broker system property names
  */
@@ -24,8 +26,28 @@ public class BrokerProperties
 
     public static final String PROPERTY_STATUS_UPDATES = "qpid.status_updates";
     public static final String PROPERTY_SYNCHED_CLOCKS = "qpid.synched_clocks";
+    public static final String PROPERTY_LOCALE = "qpid.locale";
 
     private BrokerProperties()
     {
     }
+
+    public static Locale getLocale()
+    {
+        Locale locale = Locale.US;
+        String localeSetting = 
System.getProperty(BrokerProperties.PROPERTY_LOCALE);
+        if (localeSetting != null)
+        {
+            String[] localeParts = localeSetting.split("_");
+            String language = (localeParts.length > 0 ? localeParts[0] : "");
+            String country = (localeParts.length > 1 ? localeParts[1] : "");
+            String variant = "";
+            if (localeParts.length > 2)
+            {
+                variant = localeSetting.substring(language.length() + 1 + 
country.length() + 1);
+            }
+            locale = new Locale(language, country, variant);
+        }
+        return locale;
+    }
 }

Added: 
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/messages/Broker_logmessages_uk_UA.properties
URL: 
http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/messages/Broker_logmessages_uk_UA.properties?rev=1417439&view=auto
==============================================================================
--- 
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/messages/Broker_logmessages_uk_UA.properties
 (added)
+++ 
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/messages/Broker_logmessages_uk_UA.properties
 Wed Dec  5 14:25:43 2012
@@ -0,0 +1,47 @@
+#
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing,
+#  software distributed under the License is distributed on an
+#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#  KIND, either express or implied.  See the License for the
+#  specific language governing permissions and limitations
+#  under the License.
+#
+
+# 0 - Version
+# 1 = Build
+STARTUP = BRK-1001 : \u0417\u0430\u043F\u0443\u0441\u043A : 
\u0412\u0435\u0440\u0441\u0456\u044F: {0} 
\u041F\u043E\u0431\u0443\u0434\u043E\u0432\u0430: {1}
+# 0 - Transport
+# 1 - Port
+LISTENING = BRK-1002 : \u0412 \u0437\u0430\u043F\u0443\u0441\u043A\u0443 : 
\u0421\u043B\u0443\u0445\u0430\u044E  {0}  \u043D\u0430 
\u043F\u043E\u0440\u0442\u0443 {1,number,#}
+# 0 - Transport
+# 1 - Port
+SHUTTING_DOWN = BRK-1003 : 
\u0412\u0438\u043C\u043A\u043D\u0435\u043D\u043D\u044F : {0} 
\u043F\u043E\u0440\u0442 {1,number,#}
+READY = BRK-1004 : Qpid \u0411\u0440\u043E\u043A\u0435\u0440 
\u0433\u043E\u0442\u043E\u0432\u0438\u0439
+STOPPED = BRK-1005 : \u0417\u0443\u043F\u0438\u043D\u0435\u043D\u0438\u0439
+# 0 - path
+CONFIG = BRK-1006 : 
\u0412\u0438\u043A\u043E\u0440\u0438\u0441\u0442\u043E\u0432\u0443\u044E 
\u043A\u043E\u043D\u0444\u0456\u0433\u0443\u0440\u0430\u0446\u0456\u044E : {0}
+# 0 - path
+LOG_CONFIG = BRK-1007 : 
\u0412\u0438\u043A\u043E\u0440\u0438\u0441\u0442\u043E\u0432\u0443\u044E 
\u043A\u043E\u043D\u0444\u0456\u0433\u0443\u0440\u0430\u0446\u0456\u044E 
\u0434\u043B\u044F \u043B\u043E\u0433\u0456\u0432 : {0}
+
+STATS_DATA = BRK-1008 : {0,choice,0# 
\u0434\u043E\u0441\u0442\u0430\u0432\u043B\u0435\u043D\u043E|1#\u043E\u0442\u0440\u0438\u043C\u0430\u043D\u043E}
 : {1,number,#.###} kB/s \u043F\u0456\u043A : {2,number,#} 
\u0431\u0430\u0439\u0442\u0456\u0432 \u0437\u0430\u0433\u0430\u043B\u043E\u043C
+STATS_MSGS = BRK-1009 : {0,choice,0# 
\u0434\u043E\u0441\u0442\u0430\u0432\u043B\u0435\u043D\u043E|1#\u043E\u0442\u0440\u0438\u043C\u0430\u043D\u043E}
 : {1,number,#.###} msg/s \u043F\u0456\u043A : {2,number,#} 
\u043F\u043E\u0432\u0456\u0434\u043E\u043C\u043B\u0435\u043D\u044C 
\u0437\u0430\u0433\u0430\u043B\u043E\u043C
+
+# 0 - java vendor
+# 1 - java runtime version
+# 2 - os name
+# 3 - os type
+# 4 - os architecture
+PLATFORM = BRK-1010 : \u041F\u043B\u0430\u0442\u0444\u043E\u0440\u043C\u0430 : 
JVM : {0} \u0432\u0435\u0440\u0441\u0456\u044F: {1} \u041E\u0421 : {2} 
\u0432\u0435\u0440\u0441\u0456\u044F: {3} 
\u0430\u0440\u0445\u0456\u0442\u0435\u043A\u0442\u0443\u0440\u0430: {4}
+
+# 0 Maximum Memory
+MAX_MEMORY = BRK-1011 : 
\u041C\u0430\u043A\u0441\u0438\u043C\u0430\u043B\u044C\u043D\u0438\u0439 
\u043E\u0431'\u0454\u043C \u043F\u0430\u043C'\u044F\u0442\u0456 : {0,number} 
\u0431\u0430\u0439\u0442
\ No newline at end of file

Added: 
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/BrokerPropertiesTest.java
URL: 
http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/BrokerPropertiesTest.java?rev=1417439&view=auto
==============================================================================
--- 
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/BrokerPropertiesTest.java
 (added)
+++ 
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/BrokerPropertiesTest.java
 Wed Dec  5 14:25:43 2012
@@ -0,0 +1,51 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.server.configuration;
+
+import java.util.Locale;
+
+import org.apache.qpid.test.utils.QpidTestCase;
+
+public class BrokerPropertiesTest extends QpidTestCase
+{
+    public void testGetLocaleDefault()
+    {
+        Locale locale = BrokerProperties.getLocale();
+        assertEquals("Unexpected locale", Locale.US, locale);
+    }
+
+    public void testGetLocaleSetWithJVMProperty()
+    {
+        setTestSystemProperty(BrokerProperties.PROPERTY_LOCALE, "en_GB");
+        Locale locale = BrokerProperties.getLocale();
+        assertEquals("Unexpected locale", Locale.UK, locale);
+    }
+
+    public void testGetLocaleSetWithJVMPropertyInUnexpectedFormat()
+    {
+        setTestSystemProperty(BrokerProperties.PROPERTY_LOCALE, 
"penguins_ANTARCTIC_Moubray_Bay");
+        Locale locale = BrokerProperties.getLocale();
+        assertEquals("Unexpected locale language", "penguins", 
locale.getLanguage());
+        assertEquals("Unexpected locale country", "ANTARCTIC", 
locale.getCountry());
+        assertEquals("Unexpected locale country", "Moubray_Bay", 
locale.getVariant());
+    }
+
+}

Modified: 
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/velocity/templates/org/apache/qpid/server/logging/messages/LogMessages.vm
URL: 
http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/velocity/templates/org/apache/qpid/server/logging/messages/LogMessages.vm?rev=1417439&r1=1417438&r2=1417439&view=diff
==============================================================================
--- 
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/velocity/templates/org/apache/qpid/server/logging/messages/LogMessages.vm
 (original)
+++ 
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/velocity/templates/org/apache/qpid/server/logging/messages/LogMessages.vm
 Wed Dec  5 14:25:43 2012
@@ -23,6 +23,7 @@ package ${package};
 import static 
org.apache.qpid.server.logging.AbstractRootMessageLogger.DEFAULT_LOG_HIERARCHY_PREFIX;
 
 import org.apache.log4j.Logger;
+import org.apache.qpid.server.configuration.BrokerProperties;
 import org.apache.qpid.server.logging.LogMessage;
 
 import java.text.MessageFormat;
@@ -43,7 +44,7 @@ import java.util.ResourceBundle;
 public class ${type.name}Messages
 {
     private static ResourceBundle _messages;
-    private static Locale _currentLocale = Locale.US;
+    private static Locale _currentLocale = BrokerProperties.getLocale();
     
     public static final String ${type.name.toUpperCase()}_LOG_HIERARCHY = 
DEFAULT_LOG_HIERARCHY_PREFIX + "${type.name.toLowerCase()}";
 #foreach( $message in ${type.list} )



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to