summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--java/broker/etc/config-systests.xml1
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java42
-rw-r--r--java/broker/src/test/java/org/apache/qpid/server/configuration/ServerConfigurationTest.java33
-rw-r--r--java/systests/src/main/java/org/apache/qpid/server/configuration/ServerConfigurationFileTest.java5
4 files changed, 81 insertions, 0 deletions
diff --git a/java/broker/etc/config-systests.xml b/java/broker/etc/config-systests.xml
index 7e3ef438ff..42e8c9dbba 100644
--- a/java/broker/etc/config-systests.xml
+++ b/java/broker/etc/config-systests.xml
@@ -61,6 +61,7 @@
<framesize>65535</framesize>
<compressBufferOnQueue>false</compressBufferOnQueue>
<enableJMSXUserID>false</enableJMSXUserID>
+ <locale>en_US</locale>
</advanced>
<security>
diff --git a/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java b/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java
index e4ce042891..e56f1cda12 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java
@@ -55,6 +55,7 @@ public class ServerConfiguration implements SignalHandler
public static final int DEFAULT_BUFFER_WRITE_LIMIT_SIZE = 262144;
public static final boolean DEFAULT_BROKER_CONNECTOR_PROTECTIO_ENABLED = false;
public static final String DEFAULT_STATUS_UPDATES = "on";
+ public static final String DEFAULT_ADVANCED_LOCALE = Locale.US.toString();
private static final int DEFAULT_FRAME_SIZE = 65536;
private static final int DEFAULT_PORT = 5672;
@@ -83,6 +84,7 @@ public class ServerConfiguration implements SignalHandler
public static final String CONNECTOR_PROTECTIO_READ_BUFFER_LIMIT_SIZE = "connector.protectio.readBufferLimitSize";
public static final String CONNECTOR_PROTECTIO_WRITE_BUFFER_LIMIT_SIZE = "connector.protectio.writeBufferLimitSize";
public static final String STATUS_UPDATES = "status-updates";
+ public static final String ADVANCED_LOCALE = "advanced.locale";
{
envVarMap.put("QPID_PORT", "connector.port");
@@ -212,6 +214,46 @@ public class ServerConfiguration implements SignalHandler
return value.equalsIgnoreCase("on");
}
+ /**
+ * The currently defined {@see Locale} for this broker
+ * @return the configuration defined locale
+ */
+ public Locale getLocale()
+ {
+
+ String localeString = getConfig().getString(ADVANCED_LOCALE, DEFAULT_ADVANCED_LOCALE);
+ // Expecting locale of format langauge_country_variant
+
+ String[] parts = localeString.split("_");
+
+ Locale locale = null;
+ switch (parts.length)
+ {
+ case 1:
+ locale = new Locale(localeString);
+ break;
+ case 2:
+ locale = new Locale(parts[0], parts[1]);
+ break;
+ default:
+ String variant = parts[2];
+ // If we have a variant such as the Java doc suggests for Spanish
+ // Traditional_WIN we may end up with more than 3 parts on a
+ // split with '_'. So we should recombine the variant.
+ if (parts.length > 3)
+ {
+ for (int index = 3; index < parts.length; index++)
+ {
+ variant = variant + "_" + parts[index];
+ }
+ }
+
+ locale = new Locale(parts[0], parts[1], variant);
+ }
+
+ return locale;
+ }
+
// Our configuration class needs to make the interpolate method
// public so it can be called below from the config method.
private static class MyConfiguration extends CompositeConfiguration
diff --git a/java/broker/src/test/java/org/apache/qpid/server/configuration/ServerConfigurationTest.java b/java/broker/src/test/java/org/apache/qpid/server/configuration/ServerConfigurationTest.java
index 92f4926c83..2879277784 100644
--- a/java/broker/src/test/java/org/apache/qpid/server/configuration/ServerConfigurationTest.java
+++ b/java/broker/src/test/java/org/apache/qpid/server/configuration/ServerConfigurationTest.java
@@ -39,6 +39,7 @@ import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.Iterator;
import java.util.List;
+import java.util.Locale;
public class ServerConfigurationTest extends TestCase
{
@@ -253,6 +254,38 @@ public class ServerConfigurationTest extends TestCase
assertEquals(true, serverConfig.getSynchedClocks());
}
+ public void testGetLocale() throws ConfigurationException
+ {
+ // Check default
+ ServerConfiguration serverConfig = new ServerConfiguration(_config);
+
+ String defaultParts[] = ServerConfiguration.DEFAULT_ADVANCED_LOCALE.split("_");
+ // The Default is en_US so will split well
+ Locale defaultLocale = new Locale(defaultParts[0],defaultParts[1]);
+
+ assertEquals(defaultLocale, serverConfig.getLocale());
+
+
+ //Test Language only
+ Locale update = new Locale("es");
+ _config.setProperty(ServerConfiguration.ADVANCED_LOCALE, "es");
+ serverConfig = new ServerConfiguration(_config);
+ assertEquals(update, serverConfig.getLocale());
+
+ //Test Language and Country
+ update = new Locale("es","ES");
+ _config.setProperty(ServerConfiguration.ADVANCED_LOCALE, "es_ES");
+ serverConfig = new ServerConfiguration(_config);
+ assertEquals(update, serverConfig.getLocale());
+
+ //Test Language and Country and Variant
+ update = new Locale("es","ES", "Traditional_WIN");
+ _config.setProperty(ServerConfiguration.ADVANCED_LOCALE, "es_ES_Traditional_WIN");
+ serverConfig = new ServerConfiguration(_config);
+ assertEquals(update, serverConfig.getLocale());
+ }
+
+
public void testGetMsgAuth() throws ConfigurationException
{
// Check default
diff --git a/java/systests/src/main/java/org/apache/qpid/server/configuration/ServerConfigurationFileTest.java b/java/systests/src/main/java/org/apache/qpid/server/configuration/ServerConfigurationFileTest.java
index d49206a650..c4803e121e 100644
--- a/java/systests/src/main/java/org/apache/qpid/server/configuration/ServerConfigurationFileTest.java
+++ b/java/systests/src/main/java/org/apache/qpid/server/configuration/ServerConfigurationFileTest.java
@@ -77,4 +77,9 @@ public class ServerConfigurationFileTest extends QpidTestCase
validatePropertyDefinedInFile(ServerConfiguration.STATUS_UPDATES);
}
+ public void testLocale() throws ConfigurationException
+ {
+ validatePropertyDefinedInFile(ServerConfiguration.ADVANCED_LOCALE);
+ }
+
}