You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by hl...@apache.org on 2003/08/07 16:08:11 UTC
cvs commit: jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/impl MessagesImpl.java
hlship 2003/08/07 07:08:11
Modified: hivemind/xdocs index.xml localization.xml
hivemind/src/test/hivemind/test TestMessagesImpl.java
hivemind/src/java/org/apache/commons/hivemind/impl
MessagesImpl.java
Added: hivemind/src/test/hivemind/test/config Localized.properties
Localized_fr.properties
Removed: hivemind/src/test/hivemind/test/config
hivemodule_fr.properties hivemodule.properties
Log:
Adjust the way MessagesImpl finds a module's messages properties files, to allow for non-standard module deployment descriptor locations.
Revision Changes Path
1.5 +10 -6 jakarta-commons-sandbox/hivemind/xdocs/index.xml
Index: index.xml
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/xdocs/index.xml,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- index.xml 31 Jul 2003 21:06:24 -0000 1.4
+++ index.xml 7 Aug 2003 14:08:11 -0000 1.5
@@ -41,7 +41,7 @@
HiveMind does a limited amount (reading descriptors, instantiating services and managing singletons) but
does it well. HiveMind is exhaustively tested and focused entirely on developer productivity.
HiveMind uses <em>line precise error reporting</em>: this means that when errors occur,
- even runtime errors longs after module deployment descriptors have been parsed, HiveMind will report the
+ even runtime errors long after module deployment descriptors have been parsed, HiveMind will report the
exact location of the source of an error (simply put, each runtime object is "tagged" with
the location - file and line - of the XML element it was created from). This means that the
vast majority of common errors not only report themselves consistently but even tell you
@@ -56,10 +56,10 @@
</section>
- <section name="Services and Configurations">
+ <section name="Services and Extension Points">
<p>
- HiveMind is a centralized registry of services and configurations.
+ HiveMind is a centralized registry of services and extension pointes
</p>
<p>
@@ -69,8 +69,12 @@
</p>
<p>
- Configurations are unordered lists of elements, also accessible
- using a well known name.
+ Extension points are lists of elements, also accessible
+ using a well known name. The elements of an extension point
+ are provided by extensions
+ that appear in many modules, which is the basis for
+ allowing multiple modules to work together to form
+ the application.
</p>
</section>
1.5 +8 -1 jakarta-commons-sandbox/hivemind/xdocs/localization.xml
Index: localization.xml
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/xdocs/localization.xml,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- localization.xml 1 Aug 2003 14:41:29 -0000 1.4
+++ localization.xml 7 Aug 2003 14:08:11 -0000 1.5
@@ -19,6 +19,13 @@
<code>META-INF/hivemodule.properties</code> (within the module's JAR).
</p>
+<blockquote>
+ Note: In actuality, the name of the properties file is created
+ by stripping off the extension (".xml") from the descriptor name
+ and appending the localization code and ".properties". This is relevant
+ only if you load your module deployment descriptors from a non-standard location.
+</blockquote>
+
<p>
Services can gain access to localized messages, as an instance
of
1.3 +9 -9 jakarta-commons-sandbox/hivemind/src/test/hivemind/test/TestMessagesImpl.java
Index: TestMessagesImpl.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/test/hivemind/test/TestMessagesImpl.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TestMessagesImpl.java 29 Jul 2003 22:20:31 -0000 1.2
+++ TestMessagesImpl.java 7 Aug 2003 14:08:11 -0000 1.3
@@ -86,7 +86,7 @@
public void testSimple() throws Exception
{
- IMessages m = read("config/Symbols.xml", Locale.ENGLISH);
+ IMessages m = read("config/Localized.xml", Locale.ENGLISH);
assertEquals("Some Damn Thing", m.getMessage("inner-message"));
assertEquals("[MISSING-MESSAGE]", m.getMessage("missing-message"));
@@ -97,7 +97,7 @@
public void testMissing() throws Exception
{
- IMessages m = read("config/Symbols.xml", Locale.ENGLISH);
+ IMessages m = read("config/Localized.xml", Locale.ENGLISH);
assertEquals("[MISSING-MESSAGE]", m.getMessage("missing-message"));
@@ -105,7 +105,7 @@
public void testDefault() throws Exception
{
- IMessages m = read("config/Symbols.xml", Locale.ENGLISH);
+ IMessages m = read("config/Localized.xml", Locale.ENGLISH);
assertEquals(
"Default for missing.",
@@ -114,35 +114,35 @@
public void testLocalized() throws Exception
{
- IMessages m = read("config/Symbols.xml", Locale.FRANCE);
+ IMessages m = read("config/Localized.xml", Locale.FRANCE);
assertEquals("Une Certaine Fichue Chose", m.getMessage("inner-message"));
}
public void testOneArg() throws Exception
{
- IMessages m = read("config/Symbols.xml", Locale.ENGLISH);
+ IMessages m = read("config/Localized.xml", Locale.ENGLISH);
assertEquals("[fred]", m.format("one-arg", "fred"));
}
public void testTwoArg() throws Exception
{
- IMessages m = read("config/Symbols.xml", Locale.ENGLISH);
+ IMessages m = read("config/Localized.xml", Locale.ENGLISH);
assertEquals("[abbot, costello]", m.format("two-arg", "abbot", "costello"));
}
public void testThreeArg() throws Exception
{
- IMessages m = read("config/Symbols.xml", Locale.ENGLISH);
+ IMessages m = read("config/Localized.xml", Locale.ENGLISH);
assertEquals("[moe, larry, curly]", m.format("three-arg", "moe", "larry", "curly"));
}
public void testFourArg() throws Exception
{
- IMessages m = read("config/Symbols.xml", Locale.ENGLISH);
+ IMessages m = read("config/Localized.xml", Locale.ENGLISH);
assertEquals(
"[alpha, bravo, delta, gamma]",
1.1 jakarta-commons-sandbox/hivemind/src/test/hivemind/test/config/Localized.properties
Index: Localized.properties
===================================================================
# $Id: Localized.properties,v 1.1 2003/08/07 14:08:11 hlship Exp $
test-message=Test message #{1} from {0} about: {2}.
inner-message=Some Damn Thing
one-arg=[{0}]
two-arg=[{0}, {1}]
three-arg=[{0}, {1}, {2}]
four-arg=[{0}, {1}, {2}, {3}]
1.1 jakarta-commons-sandbox/hivemind/src/test/hivemind/test/config/Localized_fr.properties
Index: Localized_fr.properties
===================================================================
# $Id: Localized_fr.properties,v 1.1 2003/08/07 14:08:11 hlship Exp $
inner-message=Une Certaine Fichue Chose
1.2 +6 -2 jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/impl/MessagesImpl.java
Index: MessagesImpl.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/impl/MessagesImpl.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- MessagesImpl.java 2 Jul 2003 21:41:12 -0000 1.1
+++ MessagesImpl.java 7 Aug 2003 14:08:11 -0000 1.2
@@ -100,7 +100,11 @@
if (LOG.isDebugEnabled())
LOG.debug("Reading message properties for module at " + moduleLocation);
- LocalizedNameGenerator g = new LocalizedNameGenerator("hivemodule", _locale, ".properties");
+ String descriptorName = moduleLocation.getName();
+ int dotx = descriptorName.lastIndexOf('.');
+ String baseName = descriptorName.substring(0, dotx);
+
+ LocalizedNameGenerator g = new LocalizedNameGenerator(baseName, _locale, ".properties");
List urls = new ArrayList();
while (g.more())