Author: julien(a)jboss.com
Date: 2007-03-26 09:28:39 -0400 (Mon, 26 Mar 2007)
New Revision: 6825
Added:
trunk/common/src/main/org/jboss/portal/common/i18n/BundleName.java
trunk/common/src/main/org/jboss/portal/common/i18n/ComplexResourceBundleFactory.java
trunk/common/src/main/org/jboss/portal/common/i18n/SimpleResourceBundleFactory.java
trunk/common/src/main/org/jboss/portal/test/common/BundleNameIteratorTestCase.java
trunk/common/src/main/org/jboss/portal/test/common/BundleNameParserTestCase.java
trunk/common/src/main/org/jboss/portal/test/common/ComplexResourceBundleFactoryTestCase.java
trunk/common/src/resources/test/bundle/
trunk/common/src/resources/test/bundle/a_de_DE.properties
trunk/common/src/resources/test/bundle/a_fr.properties
trunk/common/src/resources/test/bundle/a_fr_FR.properties
trunk/common/src/resources/test/bundle/a_it.properties
trunk/common/src/resources/test/bundle/b.properties
trunk/common/src/resources/test/bundle/c_fr.properties
trunk/common/src/resources/test/bundle/d_fr_FR.properties
trunk/common/src/resources/test/bundle/e.properties
trunk/common/src/resources/test/bundle/e_fr.properties
trunk/common/src/resources/test/bundle/f.properties
trunk/common/src/resources/test/bundle/f_fr_FR.properties
trunk/common/src/resources/test/bundle/g_fr.properties
trunk/common/src/resources/test/bundle/g_fr_FR.properties
trunk/common/src/resources/test/bundle/h.properties
trunk/common/src/resources/test/bundle/h_fr.properties
trunk/common/src/resources/test/bundle/h_fr_FR.properties
Modified:
trunk/common/build.xml
trunk/common/src/main/org/jboss/portal/common/i18n/ResourceBundleManager.java
trunk/common/src/main/org/jboss/portal/common/net/URLFilter.java
trunk/core/src/main/org/jboss/portal/core/impl/model/content/portlet/InternalPortletContentProvider.java
Log:
started to write resource bundle utilities and an implementation of ResourceBundleFactory
having the behavior of ResourceBundle.getBundle(...) except it does not take (yet?) in
account bundles which are classes, only properties.
Modified: trunk/common/build.xml
===================================================================
--- trunk/common/build.xml 2007-03-26 10:02:56 UTC (rev 6824)
+++ trunk/common/build.xml 2007-03-26 13:28:39 UTC (rev 6825)
@@ -202,14 +202,17 @@
<execute-tests>
+ <x-sysproperty>
<!--
- <x-sysproperty>
<jvmarg value="-Xdebug"/>
<jvmarg
value="-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y"/>
+-->
</x-sysproperty>
--->
<x-test>
+ <test todir="${test.reports}"
name="org.jboss.portal.test.common.BundleNameIteratorTestCase"/>
+ <test todir="${test.reports}"
name="org.jboss.portal.test.common.BundleNameParserTestCase"/>
+ <test todir="${test.reports}"
name="org.jboss.portal.test.common.ComplexResourceBundleFactoryTestCase"/>
<test todir="${test.reports}"
name="org.jboss.portal.test.common.ObjectLoaderTestCase"/>
<test todir="${test.reports}"
name="org.jboss.portal.test.common.MarkupTestCase"/>
<test todir="${test.reports}"
name="org.jboss.portal.test.common.TypedMapTestCase"/>
Added: trunk/common/src/main/org/jboss/portal/common/i18n/BundleName.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/i18n/BundleName.java
(rev 0)
+++ trunk/common/src/main/org/jboss/portal/common/i18n/BundleName.java 2007-03-26 13:28:39
UTC (rev 6825)
@@ -0,0 +1,311 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.common.i18n;
+
+import java.util.Locale;
+import java.util.NoSuchElementException;
+
+/**
+ * The immutable name of a bundle.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class BundleName
+{
+
+ public BundleName(String baseName)
+ {
+ this(baseName, "", "", "");
+ }
+
+ public BundleName(String baseName, String language)
+ {
+ this(baseName, language, "", "");
+ }
+
+ public BundleName(String baseName, String language, String country)
+ {
+ this(baseName, language, country, "");
+ }
+
+ public BundleName(String baseName, String language, String country, String variant)
+ {
+ if (baseName == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (language == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (country == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (variant == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.baseName = baseName;
+ this.language = language;
+ this.country = country;
+ this.variant = variant;
+ }
+
+ /** . */
+ private final String baseName;
+
+ /** Lower-case two-letter codes as defined by ISO-639. */
+ private final String language;
+
+ /** Upper-case two-letter codes as defined by ISO-3166. */
+ private final String country;
+
+ /** . */
+ private final String variant;
+
+ public String getBaseName()
+ {
+ return baseName;
+ }
+
+ public String getLanguage()
+ {
+ return language;
+ }
+
+ public String getCountry()
+ {
+ return country;
+ }
+
+ public String getVariant()
+ {
+ return variant;
+ }
+
+ public static class Iterator implements java.util.Iterator
+ {
+
+ /** . */
+ private final String language;
+
+ /** . */
+ private final String country;
+
+ /** . */
+ private final String variant;
+
+ /** . */
+ private String name;
+
+ /** . */
+ private int status;
+
+ public Iterator(String baseName, Locale locale)
+ {
+ language = locale.getLanguage();
+ country = locale.getCountry();
+ variant = locale.getVariant();
+ status = 8 + (language.length() > 0 ? 4 : 0) + (country.length() > 0 ? 2 :
0) + (variant.length() > 0 ? 1 : 0);
+ switch(status & 0x7)
+ {
+ case 0:
+ name = baseName;
+ break;
+ case 1:
+ name = baseName + "___" + variant;
+ break;
+ case 2:
+ name = baseName + "__" + country;
+ break;
+ case 3:
+ name = baseName + "__" + country + "_" + variant;
+ break;
+ case 4:
+ name = baseName + "_" + language;
+ break;
+ case 5:
+ name = baseName + "_" + language + "__" + variant;
+ break;
+ case 6:
+ name = baseName + "_" + language + "_" + country;
+ break;
+ case 7:
+ name = baseName + "_" + language + "_" + country +
"_" + variant;
+ break;
+ default:
+ throw new AssertionError("Should not be here");
+ }
+ }
+
+ public boolean hasNext()
+ {
+ return status != 0;
+ }
+
+ public Object next()
+ {
+ if (status >= 8)
+ {
+ status -= 8;
+ }
+ else
+ {
+ switch(status)
+ {
+ case 0:
+ throw new NoSuchElementException();
+ case 1:
+ name = name.substring(0, name.length() - 3 - variant.length());
+ status = 0;
+ break;
+ case 2:
+ name = name.substring(0, name.length() - 2 - country.length());
+ status = 0;
+ break;
+ case 3:
+ name = name.substring(0, name.length() - 1 - variant.length());
+ status = 2;
+ break;
+ case 4:
+ name = name.substring(0, name.length() - 1 - language.length());
+ status = 0;
+ break;
+ case 5:
+ name = name.substring(0, name.length() - 2 - variant.length());
+ status = 4;
+ break;
+ case 6:
+ name = name.substring(0, name.length() - 1 - country.length());
+ status = 4;
+ break;
+ case 7:
+ name = name.substring(0, name.length() - 1 - variant.length());
+ status = 6;
+ break;
+ default:
+ throw new AssertionError("Should not be here");
+ }
+ }
+ return name;
+ }
+
+ public void remove()
+ {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ /**
+ *
+ */
+ public static class Parser
+ {
+ /**
+ *
+ * @param s
+ * @param from inclusive
+ * @param to exclusive
+ * @return
+ */
+ public BundleName parse(String s, int from, int to)
+ {
+ if (s == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (from < 0)
+ {
+
+ }
+ if (to < s.length())
+ {
+
+ }
+ if (to < from)
+ {
+
+ }
+
+ //
+ int p1 = s.lastIndexOf('_', to - 1);
+ if (p1 < from)
+ {
+ p1 = -1;
+ }
+
+ //
+ if (p1 == -1)
+ {
+ // We have base name
+ return new BundleName(s.substring(from, to));
+ }
+ else if (p1 == to - 1)
+ {
+ // It ends up with _ or __ or ___
+ return null;
+ }
+ String a = s.substring(p1 + 1, to);
+
+ //
+ int p2 = s.lastIndexOf('_', p1 - 1);
+ if (p2 < from)
+ {
+ p2 = -1;
+ }
+
+ //
+ if (p2 == -1)
+ {
+ // We have base name + language
+ return new BundleName(s.substring(from, p1), a);
+ }
+ String b = p2 == p1 - 1 ? "" : s.substring(p2 + 1, p1);
+
+ //
+ int p3 = s.lastIndexOf('_', p2 - 1);
+ if (p3 < from)
+ {
+ p3 = -1;
+ }
+
+ //
+ if (p3 == -1)
+ {
+ // We have (base name + language + country) or (base name + country)
+ return new BundleName(s.substring(from, p2), b, a);
+ }
+
+ //
+ String c = (p3 == p2 - 1) ? "" : s.substring(p3 + 1, p2);
+
+ // We have (base name + variant)
+ // or (base name + country + variant)
+ // or (base name + language + country + variant)
+ // or (base name + language + variant)
+ return new BundleName(s.substring(from, p3), c, b, a);
+ }
+ }
+}
Added:
trunk/common/src/main/org/jboss/portal/common/i18n/ComplexResourceBundleFactory.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/i18n/ComplexResourceBundleFactory.java
(rev 0)
+++
trunk/common/src/main/org/jboss/portal/common/i18n/ComplexResourceBundleFactory.java 2007-03-26
13:28:39 UTC (rev 6825)
@@ -0,0 +1,123 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.common.i18n;
+
+import org.jboss.portal.common.util.Tools;
+
+import java.util.ResourceBundle;
+import java.util.Locale;
+import java.util.PropertyResourceBundle;
+import java.io.InputStream;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ComplexResourceBundleFactory implements ResourceBundleFactory
+{
+
+ /** . */
+ private final ClassLoader resourceLoader;
+
+ /** . */
+ private final String baseName;
+
+ public ComplexResourceBundleFactory(ClassLoader resourceLoader, String baseName)
+ {
+ this.resourceLoader = resourceLoader;
+ this.baseName = baseName;
+ }
+
+ public ResourceBundle getBundle(Locale locale) throws IllegalArgumentException
+ {
+ if (locale == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ for (BundleName.Iterator iterator = new BundleName.Iterator(baseName, locale);
iterator.hasNext();)
+ {
+ String name = (String)iterator.next();
+
+ // We don't want to process the base name only with the specified locale
+ // in order to respect the sequence of candidate bundle names
+ if (!iterator.hasNext())
+ {
+ break;
+ }
+
+ //
+ ResourceBundle bundle = lookup(name);
+ if (bundle != null)
+ {
+ return bundle;
+ }
+ }
+
+ // Try default locale
+ for (BundleName.Iterator iterator = new BundleName.Iterator(baseName,
Locale.getDefault()); iterator.hasNext();)
+ {
+ String name = (String)iterator.next();
+
+ //
+ ResourceBundle bundle = lookup(name);
+ if (bundle != null)
+ {
+ return bundle;
+ }
+ }
+
+ // Nothing was found
+ return null;
+ }
+
+ protected ResourceBundle lookup(String s)
+ {
+ // Try to load class first
+ // we don't do that for now !!!
+
+ // Try to load bundle then
+ String propertyName = s.replace('.', '/') +
".properties";
+ InputStream in = resourceLoader.getResourceAsStream(propertyName);
+ if (in != null)
+ {
+ try
+ {
+ in = Tools.safeBufferedWrapper(in);
+ return new PropertyResourceBundle(in);
+ }
+ catch (IOException e)
+ {
+ }
+ finally
+ {
+ Tools.safeClose(in);
+ }
+ }
+
+ //
+ return null;
+ }
+}
Modified: trunk/common/src/main/org/jboss/portal/common/i18n/ResourceBundleManager.java
===================================================================
---
trunk/common/src/main/org/jboss/portal/common/i18n/ResourceBundleManager.java 2007-03-26
10:02:56 UTC (rev 6824)
+++
trunk/common/src/main/org/jboss/portal/common/i18n/ResourceBundleManager.java 2007-03-26
13:28:39 UTC (rev 6825)
@@ -23,7 +23,6 @@
package org.jboss.portal.common.i18n;
import org.apache.log4j.Logger;
-import org.jboss.portal.common.i18n.LocalizedString;
import java.util.Map;
import java.util.ResourceBundle;
Added:
trunk/common/src/main/org/jboss/portal/common/i18n/SimpleResourceBundleFactory.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/i18n/SimpleResourceBundleFactory.java
(rev 0)
+++
trunk/common/src/main/org/jboss/portal/common/i18n/SimpleResourceBundleFactory.java 2007-03-26
13:28:39 UTC (rev 6825)
@@ -0,0 +1,61 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.common.i18n;
+
+import java.util.ResourceBundle;
+import java.util.Locale;
+
+/**
+ * An implementation that delegates bundle loading to
<code>ResourceBundle.getBundle(String,Locale,ClassLoader)</code>.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class SimpleResourceBundleFactory implements ResourceBundleFactory
+{
+
+ /** The base name of the resource bundles. */
+ private String baseName;
+
+ /** The classloader to load resource from. */
+ private ClassLoader classLoader;
+
+ public SimpleResourceBundleFactory(String baseName, ClassLoader classLoader) throws
IllegalArgumentException
+ {
+ if (baseName == null)
+ {
+ throw new IllegalArgumentException("No base name provided");
+ }
+ if (classLoader == null)
+ {
+ throw new IllegalArgumentException("No classloader provided");
+ }
+ this.baseName = baseName;
+ this.classLoader = classLoader;
+ }
+
+ public ResourceBundle getBundle(Locale locale) throws IllegalArgumentException
+ {
+ return ResourceBundle.getBundle(baseName, locale, classLoader);
+ }
+}
Modified: trunk/common/src/main/org/jboss/portal/common/net/URLFilter.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/net/URLFilter.java 2007-03-26 10:02:56
UTC (rev 6824)
+++ trunk/common/src/main/org/jboss/portal/common/net/URLFilter.java 2007-03-26 13:28:39
UTC (rev 6825)
@@ -31,7 +31,7 @@
public interface URLFilter
{
/**
- * Return true if the factory accept to create a deployment for this url.
+ * Return true if the filter accepts the url.
*/
boolean acceptFile(URL url);
Added: trunk/common/src/main/org/jboss/portal/test/common/BundleNameIteratorTestCase.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/test/common/BundleNameIteratorTestCase.java
(rev 0)
+++
trunk/common/src/main/org/jboss/portal/test/common/BundleNameIteratorTestCase.java 2007-03-26
13:28:39 UTC (rev 6825)
@@ -0,0 +1,206 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.common;
+
+import junit.framework.TestCase;
+
+import java.util.Locale;
+import java.util.NoSuchElementException;
+
+import org.jboss.portal.common.i18n.BundleName;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class BundleNameIteratorTestCase extends TestCase
+{
+
+ private final String A = new Locale("a", "b",
"c").getLanguage();
+ private final String B = new Locale("a", "b",
"c").getCountry();
+ private final String C = new Locale("a", "b",
"c").getVariant();
+
+ public void testNameLookup1()
+ {
+ Locale l = new Locale("a", "b", "c");
+ BundleName.Iterator iterator = new BundleName.Iterator("base", l);
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A + "_" + B + "_" + C,
iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A + "_" + B, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base", iterator.next());
+ assertFalse(iterator.hasNext());
+ try
+ {
+ iterator.next();
+ fail("Was expecting NoSuchElementException");
+ }
+ catch (NoSuchElementException expected)
+ {
+ }
+ }
+
+ public void testNameLookup2()
+ {
+ Locale l = new Locale("a", "b");
+ BundleName.Iterator iterator = new BundleName.Iterator("base", l);
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A + "_" + B, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base", iterator.next());
+ assertFalse(iterator.hasNext());
+ try
+ {
+ iterator.next();
+ fail("Was expecting NoSuchElementException");
+ }
+ catch (NoSuchElementException expected)
+ {
+ }
+ }
+
+ public void testNameLookup4()
+ {
+ Locale l = new Locale("a", "b", "");
+ BundleName.Iterator iterator = new BundleName.Iterator("base", l);
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A + "_" + B, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base", iterator.next());
+ assertFalse(iterator.hasNext());
+ try
+ {
+ iterator.next();
+ fail("Was expecting NoSuchElementException");
+ }
+ catch (NoSuchElementException expected)
+ {
+ }
+ }
+
+ public void testNameLookup3()
+ {
+ Locale l = new Locale("a");
+ BundleName.Iterator iterator = new BundleName.Iterator("base", l);
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base", iterator.next());
+ assertFalse(iterator.hasNext());
+ try
+ {
+ iterator.next();
+ fail("Was expecting NoSuchElementException");
+ }
+ catch (NoSuchElementException expected)
+ {
+ }
+ }
+
+ public void testNameLookup5()
+ {
+ Locale l = new Locale("a", "", "");
+ BundleName.Iterator iterator = new BundleName.Iterator("base", l);
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base", iterator.next());
+ assertFalse(iterator.hasNext());
+ try
+ {
+ iterator.next();
+ fail("Was expecting NoSuchElementException");
+ }
+ catch (NoSuchElementException expected)
+ {
+ }
+ }
+
+ public void testNameLookup6()
+ {
+ Locale l = new Locale("a", "", "c");
+ BundleName.Iterator iterator = new BundleName.Iterator("base", l);
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A + "__" + C, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base", iterator.next());
+ assertFalse(iterator.hasNext());
+ try
+ {
+ iterator.next();
+ fail("Was expecting NoSuchElementException");
+ }
+ catch (NoSuchElementException expected)
+ {
+ }
+ }
+
+ public void testNameLookup7()
+ {
+ Locale l = new Locale("", "b", "c");
+ BundleName.Iterator iterator = new BundleName.Iterator("base", l);
+ assertTrue(iterator.hasNext());
+ assertEquals("base__" + B + "_" + C, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base__" + B, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base", iterator.next());
+ assertFalse(iterator.hasNext());
+ try
+ {
+ iterator.next();
+ fail("Was expecting NoSuchElementException");
+ }
+ catch (NoSuchElementException expected)
+ {
+ }
+ }
+
+ public void testNameLookup8()
+ {
+ Locale l = new Locale("", "", "c");
+ BundleName.Iterator iterator = new BundleName.Iterator("base", l);
+ assertTrue(iterator.hasNext());
+ assertEquals("base___" + C, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base", iterator.next());
+ assertFalse(iterator.hasNext());
+ try
+ {
+ iterator.next();
+ fail("Was expecting NoSuchElementException");
+ }
+ catch (NoSuchElementException expected)
+ {
+ }
+ }
+}
Added: trunk/common/src/main/org/jboss/portal/test/common/BundleNameParserTestCase.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/test/common/BundleNameParserTestCase.java
(rev 0)
+++
trunk/common/src/main/org/jboss/portal/test/common/BundleNameParserTestCase.java 2007-03-26
13:28:39 UTC (rev 6825)
@@ -0,0 +1,102 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.common;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.i18n.BundleName;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class BundleNameParserTestCase extends TestCase
+{
+
+ /** . */
+ private final BundleName.Parser parser = new BundleName.Parser();
+
+
+ private static final Test[] tests = {
+ new Test("_", null),
+ new Test("__", null),
+ new Test("___", null),
+
+ //
+ new Test("a", new BundleName("a")),
+ new Test("a_b", new BundleName("a", "b")),
+ new Test("a_b_c", new BundleName("a", "b",
"c")),
+ new Test("a__b", new BundleName("a", "",
"b")),
+ new Test("a___b", new BundleName("a", "",
"", "b")),
+ new Test("a__b_c", new BundleName("a", "",
"b", "c")),
+ new Test("a_b__c", new BundleName("a", "b",
"", "c")),
+ new Test("a_b_c_d", new BundleName("a", "b",
"c", "d")),
+
+ //
+ new Test("", new BundleName("")),
+ new Test("_b", new BundleName("", "b")),
+ new Test("_b_c", new BundleName("", "b",
"c")),
+ new Test("__b", new BundleName("", "",
"b")),
+ new Test("___b", new BundleName("", "", "",
"b")),
+ new Test("__b_c", new BundleName("", "",
"b", "c")),
+ new Test("_b__c", new BundleName("", "b",
"", "c")),
+ new Test("_b_c_d", new BundleName("", "b",
"c", "d")),
+ };
+
+ public void testA()
+ {
+ for (int i = 0; i < tests.length; i++)
+ {
+ Test test = tests[i];
+ BundleName name = parser.parse(test.input, 0, test.input.length());
+ if (name == null)
+ {
+ assertNull(test.input, test.expectedName);
+ }
+ else
+ {
+ assertNotNull(test.input, test.expectedName);
+ assertEquals(test.input, test.expectedName.getBaseName(),
name.getBaseName());
+ assertEquals(test.input, test.expectedName.getLanguage(),
name.getLanguage());
+ assertEquals(test.input, test.expectedName.getCountry(), name.getCountry());
+ assertEquals(test.input, test.expectedName.getVariant(), name.getVariant());
+ }
+ }
+ }
+
+
+ private static class Test
+ {
+
+ /** . */
+ private String input;
+
+ /** . */
+ private BundleName expectedName;
+
+ public Test(String input, BundleName expectedName)
+ {
+ this.input = input;
+ this.expectedName = expectedName;
+ }
+ }
+}
Added:
trunk/common/src/main/org/jboss/portal/test/common/ComplexResourceBundleFactoryTestCase.java
===================================================================
---
trunk/common/src/main/org/jboss/portal/test/common/ComplexResourceBundleFactoryTestCase.java
(rev 0)
+++
trunk/common/src/main/org/jboss/portal/test/common/ComplexResourceBundleFactoryTestCase.java 2007-03-26
13:28:39 UTC (rev 6825)
@@ -0,0 +1,309 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.common;
+
+import junit.framework.TestCase;
+
+import java.io.File;
+import java.net.URLClassLoader;
+import java.net.URL;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+import org.jboss.portal.common.i18n.ComplexResourceBundleFactory;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ComplexResourceBundleFactoryTestCase extends TestCase
+{
+
+ /** . */
+ private File resourcesDir;
+
+ /** . */
+ private ClassLoader cl;
+
+ protected void setUp() throws Exception
+ {
+ String resourcePath = System.getProperty("build.resources");
+ resourcesDir = new File(resourcePath);
+ assertTrue(resourcesDir.exists());
+ assertTrue(resourcesDir.isDirectory());
+
+ File f = new File(resourcesDir, "test/bundle");
+ assertTrue(f.exists());
+ assertTrue(f.isDirectory());
+ cl = new URLClassLoader(new URL[]{f.toURL()}, ClassLoader.getSystemClassLoader());
+ }
+
+ public void testExactMatch() throws Exception
+ {
+ Locale.setDefault(new Locale("ja"));
+
+ //
+ ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(cl,
"a");
+
+ //
+ ResourceBundle a_de_DE = factory.getBundle(new Locale("de",
"DE"));
+ assertNotNull(a_de_DE);
+ assertEquals("a_de_DE", a_de_DE.getString("value"));
+
+ //
+ ResourceBundle a_fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(a_fr);
+ assertEquals("a_fr", a_fr.getString("value"));
+
+ //
+ ResourceBundle a_fr_FR = factory.getBundle(new Locale("fr",
"FR"));
+ assertNotNull(a_fr_FR);
+ assertEquals("a_fr_FR", a_fr_FR.getString("value"));
+
+ //
+ ResourceBundle a_it = factory.getBundle(new Locale("it"));
+ assertNotNull(a_it);
+ assertEquals("a_it", a_it.getString("value"));
+ }
+
+ public void testNoMatch() throws Exception
+ {
+ Locale.setDefault(new Locale("ja"));
+
+ //
+ ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(cl,
"a");
+
+ //
+ ResourceBundle a_de = factory.getBundle(new Locale("de"));
+ assertNull(a_de);
+
+ //
+ ResourceBundle a_en = factory.getBundle(new Locale("en"));
+ assertNull(a_en);
+
+ //
+ ResourceBundle a_en_EN = factory.getBundle(new Locale("en",
"EN"));
+ assertNull(a_en_EN);
+ }
+
+ public void testFallbackOnDefaultLocale1() throws Exception
+ {
+ ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(cl,
"b");
+
+ //
+ Locale.setDefault(new Locale("fr"));
+ ResourceBundle de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("b", de.getString("value"));
+ ResourceBundle fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("b", fr.getString("value"));
+ ResourceBundle fr_FR = factory.getBundle(new Locale("fr",
"FR"));
+ assertNotNull(fr_FR);
+ assertEquals("b", fr_FR.getString("value"));
+
+ //
+ Locale.setDefault(new Locale("fr", "FR"));
+ de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("b", de.getString("value"));
+ fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("b", fr.getString("value"));
+ fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("b", fr_FR.getString("value"));
+ }
+
+ public void testFallbackOnDefaultLocale2() throws Exception
+ {
+ ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(cl,
"c");
+
+ //
+ Locale.setDefault(new Locale("fr"));
+ ResourceBundle de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("c_fr", de.getString("value"));
+ ResourceBundle fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("c_fr", fr.getString("value"));
+ ResourceBundle fr_FR = factory.getBundle(new Locale("fr",
"FR"));
+ assertNotNull(fr_FR);
+ assertEquals("c_fr", fr_FR.getString("value"));
+
+ //
+ Locale.setDefault(new Locale("fr", "FR"));
+ de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("c_fr", de.getString("value"));
+ fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("c_fr", fr.getString("value"));
+ fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("c_fr", fr_FR.getString("value"));
+ }
+
+ public void testFallbackOnDefaultLocale3() throws Exception
+ {
+ ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(cl,
"d");
+
+ //
+ Locale.setDefault(new Locale("fr"));
+ ResourceBundle de = factory.getBundle(new Locale("de"));
+ assertNull(de);
+ ResourceBundle fr = factory.getBundle(new Locale("fr"));
+ assertNull(fr);
+ ResourceBundle fr_FR = factory.getBundle(new Locale("fr",
"FR"));
+ assertNotNull(fr_FR);
+ assertEquals("d_fr_FR", fr_FR.getString("value"));
+
+ //
+ Locale.setDefault(new Locale("fr", "FR"));
+ de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("d_fr_FR", de.getString("value"));
+ fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("d_fr_FR", fr.getString("value"));
+ fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("d_fr_FR", fr_FR.getString("value"));
+ }
+
+ public void testFallbackOnDefaultLocale4() throws Exception
+ {
+ ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(cl,
"e");
+
+ //
+ Locale.setDefault(new Locale("fr"));
+ ResourceBundle de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("e_fr", de.getString("value"));
+ ResourceBundle fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("e_fr", fr.getString("value"));
+ ResourceBundle fr_FR = factory.getBundle(new Locale("fr",
"FR"));
+ assertNotNull(fr_FR);
+ assertEquals("e_fr", fr_FR.getString("value"));
+
+ //
+ Locale.setDefault(new Locale("fr", "FR"));
+ de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("e_fr", de.getString("value"));
+ fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("e_fr", fr.getString("value"));
+ fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("e_fr", fr_FR.getString("value"));
+ }
+
+ public void testFallbackOnDefaultLocale5() throws Exception
+ {
+ ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(cl,
"f");
+
+ //
+ Locale.setDefault(new Locale("fr"));
+ ResourceBundle de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("f", de.getString("value"));
+ ResourceBundle fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("f", fr.getString("value"));
+ ResourceBundle fr_FR = factory.getBundle(new Locale("fr",
"FR"));
+ assertNotNull(fr_FR);
+ assertEquals("f_fr_FR", fr_FR.getString("value"));
+
+ //
+ Locale.setDefault(new Locale("fr", "FR"));
+ de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("f_fr_FR", de.getString("value"));
+ fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("f_fr_FR", fr.getString("value"));
+ fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("f_fr_FR", fr_FR.getString("value"));
+ }
+
+ public void testFallbackOnDefaultLocale6() throws Exception
+ {
+ ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(cl,
"g");
+
+ //
+ Locale.setDefault(new Locale("fr"));
+ ResourceBundle de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("g_fr", de.getString("value"));
+ ResourceBundle fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("g_fr", fr.getString("value"));
+ ResourceBundle fr_FR = factory.getBundle(new Locale("fr",
"FR"));
+ assertNotNull(fr_FR);
+ assertEquals("g_fr_FR", fr_FR.getString("value"));
+
+ //
+ Locale.setDefault(new Locale("fr", "FR"));
+ de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("g_fr_FR", de.getString("value"));
+ fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("g_fr", fr.getString("value"));
+ fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("g_fr_FR", fr_FR.getString("value"));
+ }
+
+ public void testFallbackOnDefaultLocale7() throws Exception
+ {
+ ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(cl,
"h");
+
+ //
+ Locale.setDefault(new Locale("fr"));
+ ResourceBundle de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("h_fr", de.getString("value"));
+ ResourceBundle fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("h_fr", fr.getString("value"));
+ ResourceBundle fr_FR = factory.getBundle(new Locale("fr",
"FR"));
+ assertNotNull(fr_FR);
+ assertEquals("h_fr_FR", fr_FR.getString("value"));
+
+ //
+ Locale.setDefault(new Locale("fr", "FR"));
+ de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("h_fr_FR", de.getString("value"));
+ fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("h_fr", fr.getString("value"));
+ fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("h_fr_FR", fr_FR.getString("value"));
+ }
+}
Added: trunk/common/src/resources/test/bundle/a_de_DE.properties
===================================================================
--- trunk/common/src/resources/test/bundle/a_de_DE.properties (rev
0)
+++ trunk/common/src/resources/test/bundle/a_de_DE.properties 2007-03-26 13:28:39 UTC (rev
6825)
@@ -0,0 +1 @@
+value=a_de_DE
\ No newline at end of file
Added: trunk/common/src/resources/test/bundle/a_fr.properties
===================================================================
--- trunk/common/src/resources/test/bundle/a_fr.properties (rev
0)
+++ trunk/common/src/resources/test/bundle/a_fr.properties 2007-03-26 13:28:39 UTC (rev
6825)
@@ -0,0 +1 @@
+value=a_fr
\ No newline at end of file
Added: trunk/common/src/resources/test/bundle/a_fr_FR.properties
===================================================================
--- trunk/common/src/resources/test/bundle/a_fr_FR.properties (rev
0)
+++ trunk/common/src/resources/test/bundle/a_fr_FR.properties 2007-03-26 13:28:39 UTC (rev
6825)
@@ -0,0 +1 @@
+value=a_fr_FR
\ No newline at end of file
Added: trunk/common/src/resources/test/bundle/a_it.properties
===================================================================
--- trunk/common/src/resources/test/bundle/a_it.properties (rev
0)
+++ trunk/common/src/resources/test/bundle/a_it.properties 2007-03-26 13:28:39 UTC (rev
6825)
@@ -0,0 +1 @@
+value=a_it
\ No newline at end of file
Added: trunk/common/src/resources/test/bundle/b.properties
===================================================================
--- trunk/common/src/resources/test/bundle/b.properties (rev 0)
+++ trunk/common/src/resources/test/bundle/b.properties 2007-03-26 13:28:39 UTC (rev
6825)
@@ -0,0 +1 @@
+value=b
\ No newline at end of file
Added: trunk/common/src/resources/test/bundle/c_fr.properties
===================================================================
--- trunk/common/src/resources/test/bundle/c_fr.properties (rev
0)
+++ trunk/common/src/resources/test/bundle/c_fr.properties 2007-03-26 13:28:39 UTC (rev
6825)
@@ -0,0 +1 @@
+value=c_fr
\ No newline at end of file
Added: trunk/common/src/resources/test/bundle/d_fr_FR.properties
===================================================================
--- trunk/common/src/resources/test/bundle/d_fr_FR.properties (rev
0)
+++ trunk/common/src/resources/test/bundle/d_fr_FR.properties 2007-03-26 13:28:39 UTC (rev
6825)
@@ -0,0 +1 @@
+value=d_fr_FR
\ No newline at end of file
Added: trunk/common/src/resources/test/bundle/e.properties
===================================================================
--- trunk/common/src/resources/test/bundle/e.properties (rev 0)
+++ trunk/common/src/resources/test/bundle/e.properties 2007-03-26 13:28:39 UTC (rev
6825)
@@ -0,0 +1 @@
+value=e
\ No newline at end of file
Added: trunk/common/src/resources/test/bundle/e_fr.properties
===================================================================
--- trunk/common/src/resources/test/bundle/e_fr.properties (rev
0)
+++ trunk/common/src/resources/test/bundle/e_fr.properties 2007-03-26 13:28:39 UTC (rev
6825)
@@ -0,0 +1 @@
+value=e_fr
\ No newline at end of file
Added: trunk/common/src/resources/test/bundle/f.properties
===================================================================
--- trunk/common/src/resources/test/bundle/f.properties (rev 0)
+++ trunk/common/src/resources/test/bundle/f.properties 2007-03-26 13:28:39 UTC (rev
6825)
@@ -0,0 +1 @@
+value=f
Added: trunk/common/src/resources/test/bundle/f_fr_FR.properties
===================================================================
--- trunk/common/src/resources/test/bundle/f_fr_FR.properties (rev
0)
+++ trunk/common/src/resources/test/bundle/f_fr_FR.properties 2007-03-26 13:28:39 UTC (rev
6825)
@@ -0,0 +1 @@
+value=f_fr_FR
\ No newline at end of file
Added: trunk/common/src/resources/test/bundle/g_fr.properties
===================================================================
--- trunk/common/src/resources/test/bundle/g_fr.properties (rev
0)
+++ trunk/common/src/resources/test/bundle/g_fr.properties 2007-03-26 13:28:39 UTC (rev
6825)
@@ -0,0 +1 @@
+value=g_fr
Added: trunk/common/src/resources/test/bundle/g_fr_FR.properties
===================================================================
--- trunk/common/src/resources/test/bundle/g_fr_FR.properties (rev
0)
+++ trunk/common/src/resources/test/bundle/g_fr_FR.properties 2007-03-26 13:28:39 UTC (rev
6825)
@@ -0,0 +1 @@
+value=g_fr_FR
Added: trunk/common/src/resources/test/bundle/h.properties
===================================================================
--- trunk/common/src/resources/test/bundle/h.properties (rev 0)
+++ trunk/common/src/resources/test/bundle/h.properties 2007-03-26 13:28:39 UTC (rev
6825)
@@ -0,0 +1 @@
+value=h
Added: trunk/common/src/resources/test/bundle/h_fr.properties
===================================================================
--- trunk/common/src/resources/test/bundle/h_fr.properties (rev
0)
+++ trunk/common/src/resources/test/bundle/h_fr.properties 2007-03-26 13:28:39 UTC (rev
6825)
@@ -0,0 +1 @@
+value=h_fr
Added: trunk/common/src/resources/test/bundle/h_fr_FR.properties
===================================================================
--- trunk/common/src/resources/test/bundle/h_fr_FR.properties (rev
0)
+++ trunk/common/src/resources/test/bundle/h_fr_FR.properties 2007-03-26 13:28:39 UTC (rev
6825)
@@ -0,0 +1 @@
+value=h_fr_FR
Modified:
trunk/core/src/main/org/jboss/portal/core/impl/model/content/portlet/InternalPortletContentProvider.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/impl/model/content/portlet/InternalPortletContentProvider.java 2007-03-26
10:02:56 UTC (rev 6824)
+++
trunk/core/src/main/org/jboss/portal/core/impl/model/content/portlet/InternalPortletContentProvider.java 2007-03-26
13:28:39 UTC (rev 6825)
@@ -38,6 +38,10 @@
import org.jboss.portal.identity.User;
import org.jboss.portal.Mode;
import org.jboss.portal.common.i18n.LocalizedString;
+import org.jboss.portal.common.i18n.ResourceBundleManager;
+import org.jboss.portal.common.i18n.ResourceBundleFactory;
+import org.jboss.portal.common.i18n.SimpleResourceBundleFactory;
+import org.jboss.portal.common.util.EmptyResourceBundle;
import java.util.ResourceBundle;
@@ -55,7 +59,7 @@
private CustomizationManager customizationManager;
/** . */
- private ResourceBundle bundle;
+ private ResourceBundleManager bundleManager;
/** . */
private LocalizedString displayName;
@@ -85,7 +89,8 @@
public void start() throws Exception
{
- // bundle = ResourceBundle.getBundle("conf/bundles/PortletContent",
Locale.ENGLISH, Thread.currentThread().getContextClassLoader());
+ ResourceBundleFactory factory = new
SimpleResourceBundleFactory("conf/bundles/PortletContent",
Thread.currentThread().getContextClassLoader());
+ bundleManager = new ResourceBundleManager(EmptyResourceBundle.INSTANCE, factory);
// displayName = new LocalizedString();