diff options
| author | Martin Ritchie <ritchiem@apache.org> | 2009-07-22 17:10:21 +0000 |
|---|---|---|
| committer | Martin Ritchie <ritchiem@apache.org> | 2009-07-22 17:10:21 +0000 |
| commit | f9f7fdc64cce0afd37d2c420fc37619b6eb35731 (patch) | |
| tree | 18b18b3e0fd1269f47689f93283ad7cdb6ff2dc6 /qpid/java/broker/src/main | |
| parent | 24cc42d10857f671423d347aeaa5002d11c5de82 (diff) | |
| download | qpid-python-f9f7fdc64cce0afd37d2c420fc37619b6eb35731.tar.gz | |
QPID-2001 : Provide a locale configuration option to allow the localisation of logging as part of providing fixed log messages
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@796799 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/broker/src/main')
| -rw-r--r-- | qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java index e4ce042891..e56f1cda12 100644 --- a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java +++ b/qpid/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 |
