JBoss Portal SVN: r6825 - in trunk: common/src/main/org/jboss/portal/common/i18n and 5 other directories.
by portal-commits@lists.jboss.org
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();
17 years, 3 months
JBoss Portal SVN: r6824 - trunk/core.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2007-03-26 06:02:56 -0400 (Mon, 26 Mar 2007)
New Revision: 6824
Modified:
trunk/core/build.xml
Log:
Oups...
Modified: trunk/core/build.xml
===================================================================
--- trunk/core/build.xml 2007-03-25 21:21:04 UTC (rev 6823)
+++ trunk/core/build.xml 2007-03-26 10:02:56 UTC (rev 6824)
@@ -338,7 +338,7 @@
<fileset dir="${javassist.javassist.lib}" includes="javassist.jar"/>
<fileset dir="${apache.fileupload.lib}" includes="commons-fileupload.jar"/>
<fileset dir="${jakarta.io.lib}" includes="commons-io.jar"/>
- <!--<fileset dir="${freemarker.freemarker.lib}" includes="freemarker.jar"/>-->
+ <fileset dir="${freemarker.freemarker.lib}" includes="freemarker.jar"/>
<fileset dir="${portals.bridges.lib}" includes="portals-bridges-common.jar"/>
</copy>
17 years, 3 months
JBoss Portal SVN: r6823 - in trunk/wsrp/src: resources/portal-wsrp-war/WEB-INF and 1 other directories.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2007-03-25 17:21:04 -0400 (Sun, 25 Mar 2007)
New Revision: 6823
Added:
trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerManagerBean.java
trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/faces-config.xml
trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/jsf/consumers/consumers.xhtml
trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/jsf/consumers/editConsumer.xhtml
Log:
- JBPORTAL-715:
- Started support for updating consumer state.
- Started support for creating new consumers.
- Introduced ConsumerBean in hope it would help with updating the consumer state and for easier referencing in JSF.
- This solution is currently not working properly but I want to commit a version of it for reference purpose... it might get reverted to just using ConsumerManagerBean.
Added: trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java (rev 0)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java 2007-03-25 21:21:04 UTC (rev 6823)
@@ -0,0 +1,178 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2007, 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.wsrp.admin.ui;
+
+import org.jboss.portal.wsrp.WSRPConsumer;
+import org.jboss.portal.wsrp.consumer.ConsumerRegistry;
+import org.jboss.portal.wsrp.consumer.ProducerInfo;
+
+import javax.faces.event.ValueChangeEvent;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public class ConsumerBean
+{
+ private WSRPConsumer consumer;
+ private ConsumerRegistry registry;
+ private Boolean useWSDL = null;
+
+
+ public void setRegistry(ConsumerRegistry registry)
+ {
+ this.registry = registry;
+ }
+
+ // Properties
+
+ public boolean isUseWSDL()
+ {
+ if (useWSDL != null)
+ {
+ return useWSDL.booleanValue();
+ }
+
+ return getProducerInfo().getEndpointConfigurationInfo().usesWSDL();
+ }
+
+ public String getId()
+ {
+ return consumer.getProducerId();
+ }
+
+ public void setId(String id)
+ {
+ if (consumer != null)
+ {
+ getProducerInfo().setId(id);
+ }
+ else
+ {
+ consumer = registry.getConsumer(id);
+ }
+ }
+
+ public Integer getCache()
+ {
+ return getProducerInfo().getExpirationCacheSeconds();
+ }
+
+ public void setCache(Integer cache)
+ {
+ getProducerInfo().setExpirationCacheSeconds(cache);
+ }
+
+ public String getServiceDescription()
+ {
+ return getProducerInfo().getEndpointConfigurationInfo().getServiceDescriptionURL();
+ }
+
+ public void setServiceDescription(String sdURL)
+ {
+ getProducerInfo().getEndpointConfigurationInfo().setServiceDescriptionURL(sdURL);
+ }
+
+ public String getMarkup()
+ {
+ return getProducerInfo().getEndpointConfigurationInfo().getMarkupURL();
+ }
+
+ public void setMarkup(String markupURL)
+ {
+ getProducerInfo().getEndpointConfigurationInfo().setMarkupURL(markupURL);
+ }
+
+ public String getPortletManagement()
+ {
+ return getProducerInfo().getEndpointConfigurationInfo().getPortletManagementURL();
+ }
+
+ public void setPortletManagement(String pmURL)
+ {
+ getProducerInfo().getEndpointConfigurationInfo().setPortletManagementURL(pmURL);
+ }
+
+ public String getRegistration()
+ {
+ return getProducerInfo().getEndpointConfigurationInfo().getRegistrationURL();
+ }
+
+ public void setRegistration(String rURL)
+ {
+ getProducerInfo().getEndpointConfigurationInfo().setRegistrationURL(rURL);
+ }
+
+ public String getWsdl()
+ {
+ return getProducerInfo().getEndpointConfigurationInfo().getWsdlDefinitionURL();
+ }
+
+ public void setWsdl(String wsdlURL)
+ {
+ getProducerInfo().getEndpointConfigurationInfo().setWsdlDefinitionURL(wsdlURL);
+ }
+
+ public boolean isActive()
+ {
+ return getProducerInfo().isActive();
+ }
+
+ public boolean isRegistered()
+ {
+ return getProducerInfo().isRegistered();
+ }
+
+ public boolean isRequiresRegistration()
+ {
+ return getProducerInfo().getRegistrationInfo().isRequiresRegistration();
+ }
+
+ public ProducerInfo getProducerInfo()
+ {
+ return consumer.getProducerInfo();
+ }
+
+ // Actions
+
+ public String update()
+ {
+ if (consumer != null)
+ {
+ registry.updateProducerInfo(getProducerInfo());
+ return ConsumerManagerBean.INDEX;
+ }
+
+ // todo: error message
+ return null;
+ }
+
+ // Listeners
+
+ public void useWSDLListener(ValueChangeEvent event)
+ {
+ useWSDL = (Boolean)event.getNewValue();
+ }
+}
\ No newline at end of file
Property changes on: trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerManagerBean.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerManagerBean.java 2007-03-25 20:43:24 UTC (rev 6822)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerManagerBean.java 2007-03-25 21:21:04 UTC (rev 6823)
@@ -42,7 +42,11 @@
private ConsumerRegistry registry;
private String selectedId;
private Boolean useWSDL = null;
+ private static final String CONSUMER_ID = "consumerId";
+ static final String CONFIGURE_CONSUMER = "configureConsumer";
+ static final String INDEX = "index";
+
public ConsumerRegistry getRegistry()
{
return registry;
@@ -53,6 +57,16 @@
this.registry = registry;
}
+ public void setSelectedId(String consumerId)
+ {
+ this.selectedId = consumerId;
+ }
+
+ public String getSelectedId()
+ {
+ return selectedId;
+ }
+
public WSRPConsumer getSelectedConsumer()
{
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(selectedId, "consumer id", null);
@@ -97,7 +111,8 @@
registry.registerOrDeregisterConsumerWith(selectedId, register);
// show consumer configuration
- return "configureConsumer";
+ setConsumerIdInSession(false);
+ return CONFIGURE_CONSUMER;
}
else
{
@@ -107,6 +122,31 @@
return null;
}
+ public String createConsumer()
+ {
+ if (selectedId != null)
+ {
+ registry.createConsumer(selectedId, null);
+ setConsumerIdInSession(false);
+ return CONFIGURE_CONSUMER;
+ }
+
+ return null;
+ }
+
+ public String updateConsumer()
+ {
+ WSRPConsumer consumer = getSelectedConsumer();
+ if (consumer != null)
+ {
+ registry.updateProducerInfo(consumer.getProducerInfo());
+ return listConsumers();
+ }
+
+ // todo: error message
+ return null;
+ }
+
public String destroyConsumer()
{
return null;
@@ -116,17 +156,32 @@
{
if (refreshConsumerId() != null)
{
- return "configureConsumer";
+ setConsumerIdInSession(false);
+ return CONFIGURE_CONSUMER;
}
// todo: error message
return null;
}
+ private void setConsumerIdInSession(boolean remove)
+ {
+ Map sessionMap = FacesContext.getCurrentInstance().getExternalContext().getSessionMap();
+ if (!remove)
+ {
+ sessionMap.put(CONSUMER_ID, selectedId);
+ }
+ else
+ {
+ sessionMap.remove(CONSUMER_ID);
+ }
+ }
+
public String listConsumers()
{
+ setConsumerIdInSession(true);
useWSDL = null;
selectedId = null;
- return "index";
+ return INDEX;
}
public void useWSDLListener(ValueChangeEvent event)
@@ -156,4 +211,10 @@
Map pmap = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
return (String)pmap.get(key);
}
+
+ /*private void createErrorMessage(String message, FacesMessage.Severity severity)
+ {
+ FacesMessage msg = new FacesMessage(severity, message, message);
+ FacesContext.getCurrentInstance().addMessage(messageTarget, message);
+ }*/
}
\ No newline at end of file
Modified: trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/faces-config.xml
===================================================================
--- trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/faces-config.xml 2007-03-25 20:43:24 UTC (rev 6822)
+++ trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/faces-config.xml 2007-03-25 21:21:04 UTC (rev 6823)
@@ -42,6 +42,20 @@
<value>#{applicationScope.ConsumerRegistry}</value>
</managed-property>
</managed-bean>
+ <managed-bean>
+ <managed-bean-name>consumer</managed-bean-name>
+ <managed-bean-class>org.jboss.portal.wsrp.admin.ui.ConsumerBean</managed-bean-class>
+ <managed-bean-scope>request</managed-bean-scope>
+ <managed-property>
+ <property-name>registry</property-name>
+ <property-class>org.jboss.portal.wsrp.consumer.ConsumerRegistry</property-class>
+ <value>#{applicationScope.ConsumerRegistry}</value>
+ </managed-property>
+ <managed-property>
+ <property-name>id</property-name>
+ <value>#{sessionScope.consumerId}</value>
+ </managed-property>
+ </managed-bean>
<navigation-rule>
<navigation-case>
Modified: trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/jsf/consumers/consumers.xhtml
===================================================================
--- trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/jsf/consumers/consumers.xhtml 2007-03-25 20:43:24 UTC (rev 6822)
+++ trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/jsf/consumers/consumers.xhtml 2007-03-25 21:21:04 UTC (rev 6823)
@@ -9,21 +9,29 @@
<hr/>
+ <h:messages/>
+
<h:form>
- <table width="100%" class="portlet-table-body">
- <thead>
- <tr class="portlet-table-header">
- <th>Consumer</th>
- <th>Actions</th>
- </tr>
- <tr>
- <td colspan="2">Legend:
- <span class="active">active</span>
- <span class="inactive">inactive</span>
- </td>
- </tr>
- </thead>
- <tbody>
+ Create a consumer:
+ <h:inputText value="#{consumersMgr.selectedId}"/>
+ <h:commandButton action="#{consumersMgr.createConsumer}" value="Create Consumer"/>
+ </h:form>
+
+ <table width="100%" class="portlet-table-body">
+ <thead>
+ <tr class="portlet-table-header">
+ <th>Consumer</th>
+ <th>Actions</th>
+ </tr>
+ <tr>
+ <td colspan="2">Legend:
+ <span class="active">active</span>
+ <span class="inactive">inactive</span>
+ </td>
+ </tr>
+ </thead>
+ <tbody>
+ <h:form>
<c:forEach items="#{consumersMgr.consumers}" var="consumer">
<tr class="#{consumer.producerInfo.active ? 'active' : 'inactive'}">
<td>
@@ -37,25 +45,30 @@
<h:commandLink action="#{consumersMgr.configureConsumer}">
<f:param name="id" value="#{consumer.producerId}"/>
<h:outputText value="Configure"/>
- </h:commandLink> | <h:commandLink action="#{consumersMgr.activateConsumer}">
- <f:param name="id" value="#{consumer.producerId}"/>
- <f:param name="activate" value="#{!consumer.producerInfo.active}"/>
- <h:outputText value="#{consumer.producerInfo.active ? 'Deactivate' : 'Activate'}"/>
- </h:commandLink>
- <c:if test="#{consumer.producerInfo.active}"> | <h:commandLink
- action="#{consumersMgr.registerConsumer}">
+ </h:commandLink>
+ |
+ <h:commandLink action="#{consumersMgr.activateConsumer}">
<f:param name="id" value="#{consumer.producerId}"/>
- <f:param name="register" value="#{!consumer.producerInfo.registered}"/>
- <h:outputText value="#{consumer.producerInfo.registered ? 'Deregister' : 'Register'}"/>
+ <f:param name="activate" value="#{!consumer.producerInfo.active}"/>
+ <h:outputText value="#{consumer.producerInfo.active ? 'Deactivate' : 'Activate'}"/>
</h:commandLink>
- </c:if> | <h:commandLink action="#{consumersMgr.destroyConsumer}">
- <f:param name="id" value="#{consumer.producerId}"/>
- <h:outputText value="Destroy"/>
- </h:commandLink>
+ <c:if test="#{consumer.producerInfo.active}"> |
+ <h:commandLink
+ action="#{consumersMgr.registerConsumer}">
+ <f:param name="id" value="#{consumer.producerId}"/>
+ <f:param name="register" value="#{!consumer.producerInfo.registered}"/>
+ <h:outputText value="#{consumer.producerInfo.registered ? 'Deregister' : 'Register'}"/>
+ </h:commandLink>
+ </c:if>
+ |
+ <h:commandLink action="#{consumersMgr.destroyConsumer}">
+ <f:param name="id" value="#{consumer.producerId}"/>
+ <h:outputText value="Destroy"/>
+ </h:commandLink>
</td>
</tr>
</c:forEach>
- </tbody>
- </table>
- </h:form>
+ </h:form>
+ </tbody>
+ </table>
</div>
\ No newline at end of file
Modified: trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/jsf/consumers/editConsumer.xhtml
===================================================================
--- trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/jsf/consumers/editConsumer.xhtml 2007-03-25 20:43:24 UTC (rev 6822)
+++ trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/jsf/consumers/editConsumer.xhtml 2007-03-25 21:21:04 UTC (rev 6823)
@@ -5,131 +5,141 @@
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jstl/core">
-<h1 class="portlet">Consumer '#{consumersMgr.selectedConsumer.producerId}' configuration</h1>
+<f:view>
+<h:form>
+ <h1 class="portlet">Consumer '#{consumer.id}' configuration
+ <h:commandLink action="#{consumersMgr.activateConsumer}" styleClass="portlet-form-button"
+ value="#{consumer.active ? 'Deactivate' : 'Activate'}">
+ <f:param name="id" value="#{consumer.id}"/>
+ <f:param name="activate" value="#{!consumer.active}"/>
+ </h:commandLink>
+ <h:commandLink action="#{consumersMgr.registerConsumer}" styleClass="portlet-form-button"
+ rendered="#{consumer.active}"
+ value="#{consumer.registered ? 'Deregister' : 'Register'}">
+ <f:param name="id" value="#{consumer.id}"/>
+ <f:param name="register" value="#{!consumer.registered}"/>
+ </h:commandLink>
+
+ <h:commandLink action="#{consumersMgr.destroyConsumer}" value="Destroy" styleClass="portlet-form-button">
+ <f:param name="id" value="#{consumer.id}"/>
+ </h:commandLink>
+
+ <h:commandLink action="#{consumersMgr.listConsumers}" value="Return to list" styleClass="portlet-form-button"/>
+ </h1>
+</h:form>
+
<hr/>
<h:form>
-<table width="100%" class="portlet-table-body">
- <tr>
- <th>Producer id:</th>
- <td><h:inputText value="#{consumersMgr.selectedConsumer.producerId}"/></td>
- </tr>
- <tr>
- <th>Cache expiration:</th>
- <td><h:inputText value="#{consumersMgr.selectedConsumer.producerInfo.expirationCacheSeconds}"/> (seconds
- before expiration)
- </td>
- </tr>
- <tr>
- <th>Endpoint configuration:</th>
- <td>
- <h:selectBooleanCheckbox value="#{consumersMgr.useWSDL}"
- valueChangeListener="#{consumersMgr.useWSDLListener}"
- onchange="submit()" immediate="true"/>Use WSDL?
+ <table width="100%" class="portlet-table-body">
+ <tr>
+ <th>Producer id:</th>
+ <td>
+ <h:inputText value="#{consumer.id}"/>
+ </td>
+ </tr>
+ <tr>
+ <th>Cache expiration:</th>
+ <td>
+ <h:inputText value="#{consumer.cache}"/>
+ (seconds before expiration)
+ </td>
+ </tr>
+ <tr>
+ <th>Endpoint configuration:</th>
+ <td>
+ <h:selectBooleanCheckbox value="#{consumer.useWSDL}"/>
+ Use WSDL?
- <c:choose>
- <c:when test="#{consumersMgr.useWSDL}">
- <h:inputText size="70"
- value="#{consumersMgr.selectedConsumer.producerInfo.endpointConfigurationInfo.wsdlDefinitionURL}"/>
- </c:when>
+ <c:choose>
+ <c:when test="#{consumer.useWSDL}">
+ <h:inputText size="70" value="#{consumer.wsdl}"/>
+ </c:when>
- <c:otherwise>
- <table border="0" class='portlet-table-body'>
- <tr>
- <th>Service Description URL:</th>
- <td><h:inputText size="70"
- value="#{consumersMgr.selectedConsumer.producerInfo.endpointConfigurationInfo.serviceDescriptionURL}"/>
- </td>
- </tr>
- <tr>
- <th>Markup URL:</th>
- <td><h:inputText size="70"
- value="#{consumersMgr.selectedConsumer.producerInfo.endpointConfigurationInfo.markupURL}"/>
- </td>
- </tr>
- <tr>
- <th>Registration URL:</th>
- <td><h:inputText size="70"
- value="#{consumersMgr.selectedConsumer.producerInfo.endpointConfigurationInfo.registrationURL}"/>
- </td>
- </tr>
- <tr>
- <th>Portlet Management URL:</th>
- <td><h:inputText size="70"
- value="#{consumersMgr.selectedConsumer.producerInfo.endpointConfigurationInfo.portletManagementURL}"/>
- </td>
- </tr>
- </table>
- </c:otherwise>
- </c:choose>
- </td>
- </tr>
- <tr>
- <th>Registration information</th>
- <td>
- <c:choose>
- <c:when test="#{consumersMgr.selectedConsumer.producerInfo.registrationInfo.requiresRegistration}">
- <c:choose>
- <c:when
- test="#{!empty consumersMgr.selectedConsumer.producerInfo.registrationInfo.registrationPropertyNames}">
- <table border='1' cellspacing='0' class='registration-prop-table'>
- <tr>
- <th>Name</th>
- <th>Value</th>
- </tr>
- <c:forEach
- items="#{consumersMgr.selectedConsumer.producerInfo.registrationInfo.registrationProperties}"
- var="prop">
- <tr title="#{prop.description.label.value}">
- <td><h:inputText value="#{prop.name}" size="40"/></td>
- <td><h:inputText value="#{prop.value}" size="40"/></td>
+ <c:otherwise>
+ <table border="0" class='portlet-table-body'>
+ <tr>
+ <th>Service Description URL:</th>
+ <td>
+ <h:inputText size="70" value="#{consumer.serviceDescription}"/>
+ </td>
+ </tr>
+ <tr>
+ <th>Markup URL:</th>
+ <td>
+ <h:inputText size="70" value="#{consumer.markup}"/>
+ </td>
+ </tr>
+ <tr>
+ <th>Registration URL:</th>
+ <td>
+ <h:inputText size="70" value="#{consumer.registration}"/>
+ </td>
+ </tr>
+ <tr>
+ <th>Portlet Management URL:</th>
+ <td>
+ <h:inputText size="70" value="#{consumer.portletManagement}"/>
+ </td>
+ </tr>
+ </table>
+ </c:otherwise>
+ </c:choose>
+ </td>
+ </tr>
+ <tr>
+ <th>Registration information</th>
+ <td>
+ <c:choose>
+ <c:when test="#{consumer.requiresRegistration}">
+ <c:choose>
+ <c:when test="#{!empty consumer.producerInfo.registrationInfo.registrationPropertyNames}">
+ <table border='1' cellspacing='0' class='registration-prop-table'>
+ <tr>
+ <th>Name</th>
+ <th>Value</th>
</tr>
- </c:forEach>
- </table>
- </c:when>
- <c:otherwise>
- No required registration properties.
- </c:otherwise>
- </c:choose>
- </c:when>
- <c:otherwise>
- Producer doesn't require registration.
- </c:otherwise>
- </c:choose>
- </td>
- </tr>
- <c:if test="#{consumersMgr.selectedConsumer.producerInfo.registrationInfo.registrationValid}">
+ <c:forEach items="#{consumer.producerInfo.registrationInfo.registrationProperties}"
+ var="prop">
+ <tr title="#{prop.description.label.value}">
+ <td>
+ <h:inputText value="#{prop.name}" size="40"/>
+ </td>
+ <td>
+ <h:inputText value="#{prop.value}" size="40"/>
+ </td>
+ </tr>
+ </c:forEach>
+ </table>
+ </c:when>
+ <c:otherwise>
+ No required registration properties.
+ </c:otherwise>
+ </c:choose>
+ </c:when>
+ <c:otherwise>
+ Producer doesn't require registration.
+ </c:otherwise>
+ </c:choose>
+ </td>
+ </tr>
+ <c:if test="#{consumer.producerInfo.registrationInfo.registrationValid}">
+ <tr>
+ <th>Registration context:</th>
+ <td>Handle:
+ <h:outputText value="#{consumer.producerInfo.registrationInfo.registrationContext.registrationHandle}"/>
+ </td>
+ </tr>
+ </c:if>
<tr>
- <th>Registration context:</th>
- <td>Handle: <h:outputText
- value="#{consumersMgr.selectedConsumer.producerInfo.registrationInfo.registrationContext.registrationHandle}"/>
+ <td colspan="2">
+ <h:commandButton action="#{consumer.update}" value="Save" styleClass="portlet-form-button"/>
</td>
</tr>
- </c:if>
-</table>
+ </table>
-<hr/>
+ <hr/>
</h:form>
-
-<h:form>
- <h:commandLink action="#{consumersMgr.listConsumers}" value="Cancel" styleClass="portlet-form-button"/>
-
- <h:commandLink action="#{consumersMgr.activateConsumer}" styleClass="portlet-form-button"
- value="#{consumersMgr.selectedConsumer.producerInfo.active ? 'Deactivate' : 'Activate'}">
- <f:param name="id" value="#{consumersMgr.selectedConsumer.producerId}"/>
- <f:param name="activate" value="#{!consumersMgr.selectedConsumer.producerInfo.active}"/>
- </h:commandLink>
-
- <h:commandLink action="#{consumersMgr.registerConsumer}" styleClass="portlet-form-button"
- rendered="#{consumersMgr.selectedConsumer.producerInfo.active}"
- value="#{consumersMgr.selectedConsumer.producerInfo.registered ? 'Deregister' : 'Register'}">
- <f:param name="id" value="#{consumersMgr.selectedConsumer.producerId}"/>
- <f:param name="register" value="#{!consumersMgr.selectedConsumer.producerInfo.registered}"/>
- </h:commandLink>
-
- <h:commandLink action="#{consumersMgr.destroyConsumer}" value="Destroy" styleClass="portlet-form-button">
- <f:param name="id" value="#{consumersMgr.selectedConsumer.producerId}"/>
- </h:commandLink>
-</h:form>
+</f:view>
</div>
\ No newline at end of file
17 years, 3 months
JBoss Portal SVN: r6822 - in trunk/core/src/main/org/jboss/portal: core/impl/model/content and 9 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-03-25 16:43:24 -0400 (Sun, 25 Mar 2007)
New Revision: 6822
Added:
trunk/core/src/main/org/jboss/portal/core/model/content/spi/ContentProvider.java
trunk/core/src/main/org/jboss/portal/core/model/content/spi/ContentProviderRegistry.java
trunk/core/src/main/org/jboss/portal/core/model/content/spi/handler/ContentState.java
Removed:
trunk/core/src/main/org/jboss/portal/core/model/content/ContentProvider.java
trunk/core/src/main/org/jboss/portal/core/model/content/ContentProviderRegistry.java
trunk/core/src/main/org/jboss/portal/core/model/content/spi/ContentState.java
Modified:
trunk/core/src/main/org/jboss/portal/core/deployment/jboss/ObjectDeployment.java
trunk/core/src/main/org/jboss/portal/core/deployment/jboss/ObjectDeploymentFactory.java
trunk/core/src/main/org/jboss/portal/core/impl/model/content/AbstractContent.java
trunk/core/src/main/org/jboss/portal/core/impl/model/content/ContentProviderRegistryService.java
trunk/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProvider.java
trunk/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProviderRegistry.java
trunk/core/src/main/org/jboss/portal/core/impl/model/content/generic/GenericContent.java
trunk/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java
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/PortletContent.java
trunk/core/src/main/org/jboss/portal/core/impl/model/portal/AbstractPortalObjectContainer.java
trunk/core/src/main/org/jboss/portal/core/impl/model/portal/WindowImpl.java
trunk/core/src/main/org/jboss/portal/core/model/content/spi/handler/ContentHandler.java
trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/ContextMetaData.java
trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/PageMetaData.java
trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/PortalMetaData.java
trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/PortalObjectMetaData.java
trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/WindowMetaData.java
trunk/core/src/main/org/jboss/portal/test/core/model/content/NullContent.java
trunk/core/src/main/org/jboss/portal/test/core/model/content/NullContentHandler.java
trunk/core/src/main/org/jboss/portal/test/core/model/content/NullContentProvider.java
trunk/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectContainerTestCase.java
Log:
moved interfaces at better places :
- ContentState -> handler package
- ContentProvider & ContentProviderRegistry to spi
Modified: trunk/core/src/main/org/jboss/portal/core/deployment/jboss/ObjectDeployment.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/deployment/jboss/ObjectDeployment.java 2007-03-25 13:20:26 UTC (rev 6821)
+++ trunk/core/src/main/org/jboss/portal/core/deployment/jboss/ObjectDeployment.java 2007-03-25 20:43:24 UTC (rev 6822)
@@ -33,7 +33,7 @@
import org.jboss.portal.core.model.portal.PortalObjectContainer;
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.content.ContentType;
-import org.jboss.portal.core.model.content.ContentProvider;
+import org.jboss.portal.core.model.content.spi.ContentProvider;
import org.jboss.portal.core.model.content.spi.handler.ContentHandler;
import org.jboss.portal.server.deployment.PortalWebApp;
import org.jboss.portal.server.deployment.jboss.Deployment;
Modified: trunk/core/src/main/org/jboss/portal/core/deployment/jboss/ObjectDeploymentFactory.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/deployment/jboss/ObjectDeploymentFactory.java 2007-03-25 13:20:26 UTC (rev 6821)
+++ trunk/core/src/main/org/jboss/portal/core/deployment/jboss/ObjectDeploymentFactory.java 2007-03-25 20:43:24 UTC (rev 6822)
@@ -25,7 +25,7 @@
import org.jboss.deployment.DeploymentException;
import org.jboss.portal.common.transaction.TransactionManagerProvider;
import org.jboss.portal.core.model.portal.PortalObjectContainer;
-import org.jboss.portal.core.model.content.ContentProviderRegistry;
+import org.jboss.portal.core.model.content.spi.ContentProviderRegistry;
import org.jboss.portal.server.deployment.PortalWebApp;
import org.jboss.portal.server.deployment.jboss.AbstractDeploymentFactory;
import org.jboss.portal.server.deployment.jboss.Deployment;
Modified: trunk/core/src/main/org/jboss/portal/core/impl/model/content/AbstractContent.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/content/AbstractContent.java 2007-03-25 13:20:26 UTC (rev 6821)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/content/AbstractContent.java 2007-03-25 20:43:24 UTC (rev 6822)
@@ -23,7 +23,7 @@
package org.jboss.portal.core.impl.model.content;
import org.jboss.portal.core.model.content.Content;
-import org.jboss.portal.core.model.content.spi.ContentState;
+import org.jboss.portal.core.model.content.spi.handler.ContentState;
import java.util.Iterator;
Modified: trunk/core/src/main/org/jboss/portal/core/impl/model/content/ContentProviderRegistryService.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/content/ContentProviderRegistryService.java 2007-03-25 13:20:26 UTC (rev 6821)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/content/ContentProviderRegistryService.java 2007-03-25 20:43:24 UTC (rev 6822)
@@ -23,7 +23,7 @@
package org.jboss.portal.core.impl.model.content;
import org.jboss.portal.core.model.content.ContentType;
-import org.jboss.portal.core.model.content.ContentProvider;
+import org.jboss.portal.core.model.content.spi.ContentProvider;
import org.jboss.portal.core.model.portal.content.ContentRenderer;
import org.jboss.portal.common.util.CopyOnWriteRegistry;
Modified: trunk/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProvider.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProvider.java 2007-03-25 13:20:26 UTC (rev 6821)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProvider.java 2007-03-25 20:43:24 UTC (rev 6822)
@@ -24,7 +24,7 @@
import org.jboss.portal.core.model.content.ContentType;
import org.jboss.portal.core.model.content.Content;
-import org.jboss.portal.core.model.content.ContentProvider;
+import org.jboss.portal.core.model.content.spi.ContentProvider;
import org.jboss.portal.core.model.instance.Instance;
import org.jboss.portal.core.model.portal.command.RenderWindowCommand;
import org.jboss.portal.core.model.portal.command.InvokePortletWindowRenderCommand;
Modified: trunk/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProviderRegistry.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProviderRegistry.java 2007-03-25 13:20:26 UTC (rev 6821)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProviderRegistry.java 2007-03-25 20:43:24 UTC (rev 6822)
@@ -23,7 +23,7 @@
package org.jboss.portal.core.impl.model.content;
import org.jboss.portal.core.model.content.ContentType;
-import org.jboss.portal.core.model.content.ContentProviderRegistry;
+import org.jboss.portal.core.model.content.spi.ContentProviderRegistry;
import org.jboss.portal.core.model.portal.content.ContentRendererRegistry;
/**
Modified: trunk/core/src/main/org/jboss/portal/core/impl/model/content/generic/GenericContent.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/content/generic/GenericContent.java 2007-03-25 13:20:26 UTC (rev 6821)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/content/generic/GenericContent.java 2007-03-25 20:43:24 UTC (rev 6822)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.portal.core.impl.model.content.generic;
-import org.jboss.portal.core.model.content.spi.ContentState;
+import org.jboss.portal.core.model.content.spi.handler.ContentState;
import org.jboss.portal.core.impl.model.content.AbstractContent;
import org.jboss.portal.common.i18n.LocalizedString;
Modified: trunk/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java 2007-03-25 13:20:26 UTC (rev 6821)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java 2007-03-25 20:43:24 UTC (rev 6822)
@@ -23,9 +23,9 @@
package org.jboss.portal.core.impl.model.content.generic;
import org.jboss.portal.core.model.content.Content;
-import org.jboss.portal.core.model.content.ContentProvider;
+import org.jboss.portal.core.model.content.spi.ContentProvider;
import org.jboss.portal.core.model.content.ContentType;
-import org.jboss.portal.core.model.content.spi.ContentState;
+import org.jboss.portal.core.model.content.spi.handler.ContentState;
import org.jboss.portal.core.model.content.spi.handler.ContentHandler;
import org.jboss.portal.core.model.content.spi.portlet.ContentPortlet;
import org.jboss.portal.core.model.instance.Instance;
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-25 13:20:26 UTC (rev 6821)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/content/portlet/InternalPortletContentProvider.java 2007-03-25 20:43:24 UTC (rev 6822)
@@ -25,9 +25,9 @@
import org.jboss.portal.core.model.instance.InstanceContainer;
import org.jboss.portal.core.model.instance.Instance;
import org.jboss.portal.core.model.content.Content;
-import org.jboss.portal.core.model.content.ContentProvider;
+import org.jboss.portal.core.model.content.spi.ContentProvider;
import org.jboss.portal.core.model.content.ContentType;
-import org.jboss.portal.core.model.content.spi.ContentState;
+import org.jboss.portal.core.model.content.spi.handler.ContentState;
import org.jboss.portal.core.model.content.spi.handler.ContentHandler;
import org.jboss.portal.core.model.content.spi.portlet.ContentPortlet;
import org.jboss.portal.core.model.portal.command.RenderWindowCommand;
@@ -40,7 +40,6 @@
import org.jboss.portal.common.i18n.LocalizedString;
import java.util.ResourceBundle;
-import java.util.Locale;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
Modified: trunk/core/src/main/org/jboss/portal/core/impl/model/content/portlet/PortletContent.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/content/portlet/PortletContent.java 2007-03-25 13:20:26 UTC (rev 6821)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/content/portlet/PortletContent.java 2007-03-25 20:43:24 UTC (rev 6822)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.portal.core.impl.model.content.portlet;
-import org.jboss.portal.core.model.content.spi.ContentState;
+import org.jboss.portal.core.model.content.spi.handler.ContentState;
import org.jboss.portal.core.impl.model.content.AbstractContent;
import org.jboss.portal.common.i18n.LocalizedString;
Modified: trunk/core/src/main/org/jboss/portal/core/impl/model/portal/AbstractPortalObjectContainer.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/portal/AbstractPortalObjectContainer.java 2007-03-25 13:20:26 UTC (rev 6821)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/portal/AbstractPortalObjectContainer.java 2007-03-25 20:43:24 UTC (rev 6822)
@@ -27,8 +27,8 @@
import org.jboss.portal.core.model.portal.PortalObjectPermission;
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.content.ContentType;
-import org.jboss.portal.core.model.content.ContentProviderRegistry;
-import org.jboss.portal.core.model.content.ContentProvider;
+import org.jboss.portal.core.model.content.spi.ContentProviderRegistry;
+import org.jboss.portal.core.model.content.spi.ContentProvider;
import org.jboss.portal.core.model.instance.InstanceContainer;
import org.jboss.portal.core.model.content.spi.handler.ContentHandler;
import org.jboss.portal.jems.as.system.AbstractJBossService;
Modified: trunk/core/src/main/org/jboss/portal/core/impl/model/portal/WindowImpl.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/portal/WindowImpl.java 2007-03-25 13:20:26 UTC (rev 6821)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/portal/WindowImpl.java 2007-03-25 20:43:24 UTC (rev 6822)
@@ -26,7 +26,7 @@
import org.jboss.portal.core.model.portal.Window;
import org.jboss.portal.core.model.content.Content;
import org.jboss.portal.core.model.content.ContentType;
-import org.jboss.portal.core.model.content.spi.ContentState;
+import org.jboss.portal.core.model.content.spi.handler.ContentState;
import org.jboss.portal.core.model.content.spi.handler.ContentHandler;
import org.jboss.portal.jems.hibernate.ContextObject;
Deleted: trunk/core/src/main/org/jboss/portal/core/model/content/ContentProvider.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/content/ContentProvider.java 2007-03-25 13:20:26 UTC (rev 6821)
+++ trunk/core/src/main/org/jboss/portal/core/model/content/ContentProvider.java 2007-03-25 20:43:24 UTC (rev 6822)
@@ -1,70 +0,0 @@
-/******************************************************************************
- * 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.core.model.content;
-
-import org.jboss.portal.core.model.content.spi.handler.ContentHandler;
-import org.jboss.portal.core.model.content.spi.portlet.ContentPortlet;
-import org.jboss.portal.common.i18n.LocalizedString;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public interface ContentProvider
-{
-
- /**
- * Return the content type value.
- *
- * @return the content type
- */
- ContentType getContentType();
-
- /**
- * Returns the display name.
- *
- * @return the display name
- */
- LocalizedString getDisplayName();
-
- /**
- * Returns the description.
- *
- * @return the description
- */
- LocalizedString getDescription();
-
- /**
- * Returns the handler.
- *
- * @return the handler
- */
- ContentHandler getHandler();
-
- /**
- * Returns the portlet info
- *
- * @return the portlet info
- */
- ContentPortlet getPortletInfo();
-}
Deleted: trunk/core/src/main/org/jboss/portal/core/model/content/ContentProviderRegistry.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/content/ContentProviderRegistry.java 2007-03-25 13:20:26 UTC (rev 6821)
+++ trunk/core/src/main/org/jboss/portal/core/model/content/ContentProviderRegistry.java 2007-03-25 20:43:24 UTC (rev 6822)
@@ -1,42 +0,0 @@
-/******************************************************************************
- * 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.core.model.content;
-
-import java.util.Collection;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public interface ContentProviderRegistry
-{
- /**
- *
- */
- Collection getContentTypes();
-
- /**
- *
- */
- ContentProvider getContentProvider(ContentType contentType);
-}
Copied: trunk/core/src/main/org/jboss/portal/core/model/content/spi/ContentProvider.java (from rev 6818, trunk/core/src/main/org/jboss/portal/core/model/content/ContentProvider.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/content/spi/ContentProvider.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/model/content/spi/ContentProvider.java 2007-03-25 20:43:24 UTC (rev 6822)
@@ -0,0 +1,71 @@
+/******************************************************************************
+ * 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.core.model.content.spi;
+
+import org.jboss.portal.core.model.content.spi.handler.ContentHandler;
+import org.jboss.portal.core.model.content.spi.portlet.ContentPortlet;
+import org.jboss.portal.core.model.content.ContentType;
+import org.jboss.portal.common.i18n.LocalizedString;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface ContentProvider
+{
+
+ /**
+ * Return the content type value.
+ *
+ * @return the content type
+ */
+ ContentType getContentType();
+
+ /**
+ * Returns the display name.
+ *
+ * @return the display name
+ */
+ LocalizedString getDisplayName();
+
+ /**
+ * Returns the description.
+ *
+ * @return the description
+ */
+ LocalizedString getDescription();
+
+ /**
+ * Returns the handler.
+ *
+ * @return the handler
+ */
+ ContentHandler getHandler();
+
+ /**
+ * Returns the portlet info
+ *
+ * @return the portlet info
+ */
+ ContentPortlet getPortletInfo();
+}
Copied: trunk/core/src/main/org/jboss/portal/core/model/content/spi/ContentProviderRegistry.java (from rev 6816, trunk/core/src/main/org/jboss/portal/core/model/content/ContentProviderRegistry.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/content/spi/ContentProviderRegistry.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/model/content/spi/ContentProviderRegistry.java 2007-03-25 20:43:24 UTC (rev 6822)
@@ -0,0 +1,44 @@
+/******************************************************************************
+ * 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.core.model.content.spi;
+
+import org.jboss.portal.core.model.content.ContentType;
+
+import java.util.Collection;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface ContentProviderRegistry
+{
+ /**
+ *
+ */
+ Collection getContentTypes();
+
+ /**
+ *
+ */
+ ContentProvider getContentProvider(ContentType contentType);
+}
Deleted: trunk/core/src/main/org/jboss/portal/core/model/content/spi/ContentState.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/content/spi/ContentState.java 2007-03-25 13:20:26 UTC (rev 6821)
+++ trunk/core/src/main/org/jboss/portal/core/model/content/spi/ContentState.java 2007-03-25 20:43:24 UTC (rev 6822)
@@ -1,56 +0,0 @@
-/******************************************************************************
- * 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.core.model.content.spi;
-
-import java.util.Iterator;
-
-/**
- * Represents the state of the content which consist in an URI and a set of properties.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public interface ContentState
-{
- /**
- * Returns the URI value.
- *
- * @return the URI
- */
- String getURI();
-
- /**
- * Set the URI value.
- *
- * @param uri the URI
- */
- void setURI(String uri);
-
- Iterator getParameterNames();
-
- void setParameter(String name, String value) throws IllegalArgumentException;
-
- String getParameter(String name) throws IllegalArgumentException;
-
- void clearParameters();
-}
Modified: trunk/core/src/main/org/jboss/portal/core/model/content/spi/handler/ContentHandler.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/content/spi/handler/ContentHandler.java 2007-03-25 13:20:26 UTC (rev 6821)
+++ trunk/core/src/main/org/jboss/portal/core/model/content/spi/handler/ContentHandler.java 2007-03-25 20:43:24 UTC (rev 6822)
@@ -23,7 +23,7 @@
package org.jboss.portal.core.model.content.spi.handler;
import org.jboss.portal.core.model.content.Content;
-import org.jboss.portal.core.model.content.spi.ContentState;
+import org.jboss.portal.core.model.content.spi.handler.ContentState;
/**
* The content handler act as a factory for <code>Content</code> objects from their state. The interface
Copied: trunk/core/src/main/org/jboss/portal/core/model/content/spi/handler/ContentState.java (from rev 6816, trunk/core/src/main/org/jboss/portal/core/model/content/spi/ContentState.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/content/spi/handler/ContentState.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/model/content/spi/handler/ContentState.java 2007-03-25 20:43:24 UTC (rev 6822)
@@ -0,0 +1,56 @@
+/******************************************************************************
+ * 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.core.model.content.spi.handler;
+
+import java.util.Iterator;
+
+/**
+ * Represents the state of the content which consist in an URI and a set of properties.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface ContentState
+{
+ /**
+ * Returns the URI value.
+ *
+ * @return the URI
+ */
+ String getURI();
+
+ /**
+ * Set the URI value.
+ *
+ * @param uri the URI
+ */
+ void setURI(String uri);
+
+ Iterator getParameterNames();
+
+ void setParameter(String name, String value) throws IllegalArgumentException;
+
+ String getParameter(String name) throws IllegalArgumentException;
+
+ void clearParameters();
+}
Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/ContextMetaData.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/ContextMetaData.java 2007-03-25 13:20:26 UTC (rev 6821)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/ContextMetaData.java 2007-03-25 20:43:24 UTC (rev 6822)
@@ -24,7 +24,7 @@
import org.jboss.portal.core.model.portal.PortalObject;
import org.jboss.portal.core.model.portal.PortalContainer;
-import org.jboss.portal.core.model.content.ContentProviderRegistry;
+import org.jboss.portal.core.model.content.spi.ContentProviderRegistry;
import org.jboss.portal.common.util.XML;
import org.w3c.dom.Element;
Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/PageMetaData.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/PageMetaData.java 2007-03-25 13:20:26 UTC (rev 6821)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/PageMetaData.java 2007-03-25 20:43:24 UTC (rev 6822)
@@ -25,7 +25,7 @@
import org.jboss.portal.common.util.XML;
import org.jboss.portal.core.model.portal.PageContainer;
import org.jboss.portal.core.model.portal.PortalObject;
-import org.jboss.portal.core.model.content.ContentProviderRegistry;
+import org.jboss.portal.core.model.content.spi.ContentProviderRegistry;
import org.w3c.dom.Element;
import java.util.List;
Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/PortalMetaData.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/PortalMetaData.java 2007-03-25 13:20:26 UTC (rev 6821)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/PortalMetaData.java 2007-03-25 20:43:24 UTC (rev 6822)
@@ -28,7 +28,7 @@
import org.jboss.portal.core.model.portal.PortalContainer;
import org.jboss.portal.core.model.portal.Portal;
import org.jboss.portal.core.model.portal.PortalObject;
-import org.jboss.portal.core.model.content.ContentProviderRegistry;
+import org.jboss.portal.core.model.content.spi.ContentProviderRegistry;
import org.jboss.portal.portlet.impl.jsr168.metadata.ModesMetaData;
import org.jboss.portal.portlet.impl.jsr168.metadata.WindowStatesMetaData;
import org.w3c.dom.Element;
Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/PortalObjectMetaData.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/PortalObjectMetaData.java 2007-03-25 13:20:26 UTC (rev 6821)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/PortalObjectMetaData.java 2007-03-25 20:43:24 UTC (rev 6822)
@@ -25,7 +25,7 @@
import org.jboss.logging.Logger;
import org.jboss.portal.common.util.Tools;
import org.jboss.portal.common.util.XML;
-import org.jboss.portal.core.model.content.ContentProviderRegistry;
+import org.jboss.portal.core.model.content.spi.ContentProviderRegistry;
import org.jboss.portal.core.model.portal.PortalObject;
import org.jboss.portal.core.model.portal.PortalObjectContainer;
import org.jboss.portal.core.model.portal.PortalObjectId;
Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/WindowMetaData.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/WindowMetaData.java 2007-03-25 13:20:26 UTC (rev 6821)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/WindowMetaData.java 2007-03-25 20:43:24 UTC (rev 6822)
@@ -26,7 +26,7 @@
import org.jboss.portal.core.model.portal.PortalObject;
import org.jboss.portal.core.model.portal.Window;
import org.jboss.portal.core.model.content.ContentType;
-import org.jboss.portal.core.model.content.ContentProviderRegistry;
+import org.jboss.portal.core.model.content.spi.ContentProviderRegistry;
import org.jboss.portal.theme.ThemeConstants;
import org.jboss.portal.common.util.XML;
import org.w3c.dom.Element;
Modified: trunk/core/src/main/org/jboss/portal/test/core/model/content/NullContent.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/test/core/model/content/NullContent.java 2007-03-25 13:20:26 UTC (rev 6821)
+++ trunk/core/src/main/org/jboss/portal/test/core/model/content/NullContent.java 2007-03-25 20:43:24 UTC (rev 6822)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.portal.test.core.model.content;
-import org.jboss.portal.core.model.content.spi.ContentState;
+import org.jboss.portal.core.model.content.spi.handler.ContentState;
import org.jboss.portal.core.impl.model.content.AbstractContent;
import org.jboss.portal.common.i18n.LocalizedString;
Modified: trunk/core/src/main/org/jboss/portal/test/core/model/content/NullContentHandler.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/test/core/model/content/NullContentHandler.java 2007-03-25 13:20:26 UTC (rev 6821)
+++ trunk/core/src/main/org/jboss/portal/test/core/model/content/NullContentHandler.java 2007-03-25 20:43:24 UTC (rev 6822)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.portal.test.core.model.content;
-import org.jboss.portal.core.model.content.spi.ContentState;
+import org.jboss.portal.core.model.content.spi.handler.ContentState;
import org.jboss.portal.core.model.content.spi.handler.ContentHandler;
import org.jboss.portal.core.model.content.Content;
Modified: trunk/core/src/main/org/jboss/portal/test/core/model/content/NullContentProvider.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/test/core/model/content/NullContentProvider.java 2007-03-25 13:20:26 UTC (rev 6821)
+++ trunk/core/src/main/org/jboss/portal/test/core/model/content/NullContentProvider.java 2007-03-25 20:43:24 UTC (rev 6822)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.portal.test.core.model.content;
-import org.jboss.portal.core.model.content.ContentProvider;
+import org.jboss.portal.core.model.content.spi.ContentProvider;
import org.jboss.portal.core.model.content.ContentType;
import org.jboss.portal.core.model.content.spi.handler.ContentHandler;
import org.jboss.portal.core.model.content.spi.portlet.ContentPortlet;
Modified: trunk/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectContainerTestCase.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectContainerTestCase.java 2007-03-25 13:20:26 UTC (rev 6821)
+++ trunk/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectContainerTestCase.java 2007-03-25 20:43:24 UTC (rev 6822)
@@ -31,9 +31,9 @@
import org.jboss.portal.core.model.portal.Window;
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.content.ContentType;
-import org.jboss.portal.core.model.content.ContentProviderRegistry;
-import org.jboss.portal.core.model.content.ContentProvider;
-import org.jboss.portal.core.model.content.spi.ContentState;
+import org.jboss.portal.core.model.content.spi.ContentProviderRegistry;
+import org.jboss.portal.core.model.content.spi.ContentProvider;
+import org.jboss.portal.core.model.content.spi.handler.ContentState;
import org.jboss.portal.security.impl.JBossAuthorizationDomainRegistryImpl;
import org.jboss.portal.security.impl.jacc.JACCPortalAuthorizationManagerFactory;
import org.jboss.portal.test.core.PortalBaseTestCase;
17 years, 3 months
JBoss Portal SVN: r6821 - in trunk: common/src/main/org/jboss/portal/common/util and 9 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-03-25 09:20:26 -0400 (Sun, 25 Mar 2007)
New Revision: 6821
Added:
trunk/common/src/main/org/jboss/portal/common/i18n/LocaleInfo.java
Removed:
trunk/common/src/main/org/jboss/portal/common/util/LocaleInfo.java
Modified:
trunk/common/src/main/org/jboss/portal/common/i18n/LocalizedString.java
trunk/common/src/main/org/jboss/portal/common/i18n/ResourceBundleManager.java
trunk/common/src/main/org/jboss/portal/test/common/LocaleInfoTestCase.java
trunk/core/src/main/org/jboss/portal/core/portlet/user/UserPortlet.java
trunk/identity/src/main/org/jboss/portal/identity/config/metadata/profile/ProfileMetaDataFactory.java
trunk/portlet/src/main/org/jboss/portal/portlet/deployment/PortletApplicationMetaDataFactory.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/UserContextConverter.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPUtils.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/portlet/info/WSRPPortletInfo.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupRequest.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/PortletManagementHandler.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/config/ProducerConfigurationFactory.java
Log:
- moved LocaleInfo to i18n package too
- javadoc improvements
- cache LocalizedString hashCode and toString
- made LocalizedString final
Copied: trunk/common/src/main/org/jboss/portal/common/i18n/LocaleInfo.java (from rev 6816, trunk/common/src/main/org/jboss/portal/common/util/LocaleInfo.java)
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/i18n/LocaleInfo.java (rev 0)
+++ trunk/common/src/main/org/jboss/portal/common/i18n/LocaleInfo.java 2007-03-25 13:20:26 UTC (rev 6821)
@@ -0,0 +1,460 @@
+/******************************************************************************
+ * 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.apache.log4j.Logger;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Additional infos about a locale.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision$
+ * @noinspection ALL
+ */
+public final class LocaleInfo
+{
+
+ // Static fields ****************************************************************************************************
+
+ /**
+ * The logger.
+ */
+ private static Logger log = Logger.getLogger(LocaleInfo.class);
+
+ /**
+ * The locale info map.
+ */
+ private static volatile Infos sharedInfos = createFromAvailableLocales();
+
+ /**
+ * Separator.
+ */
+ private static final String RFC3066_SEPARATOR = "-";
+
+ /**
+ * Valid language tag matcher (see <a href="http://www.ietf.org/rfc/rfc3066.txt">IETF RFC 3066</a>).
+ */
+ private static final Pattern RFC3066_COMPOUND_LANG_PATTERN = Pattern.compile("(\\p{Lower}{2})(-(\\p{Upper}{2}))?");
+
+ /**
+ * Sorted valid ISO country codes (needed for Arrays.binarySearch).
+ */
+ private static final String[] SORTED_ISO_COUNTRIES = Locale.getISOCountries();
+
+ /**
+ * Sorted valid ISO language codes (needed for Arrays.binarySearch).
+ */
+ private static final String[] SORTED_ISO_LANGUAGES = Locale.getISOLanguages();
+
+ private static final Comparator c = new Comparator()
+ {
+ public int compare(Object o1, Object o2)
+ {
+ String s1 = ((LocaleInfo)o1).getTrailingName();
+ String s2 = ((LocaleInfo)o2).getTrailingName();
+ return s1.compareTo(s2);
+ }
+ };
+
+
+ static
+ {
+ // should already be sorted but in case they're not...
+ Arrays.sort(SORTED_ISO_COUNTRIES);
+ Arrays.sort(SORTED_ISO_LANGUAGES);
+ }
+
+ // Fields ***********************************************************************************************************
+
+ /**
+ * The parent locale info or null if no parent.
+ */
+ private LocaleInfo parent;
+
+ /**
+ * The relaled locale.
+ */
+ private Locale locale;
+
+ /**
+ * The trailing name used to compute resource bundle name.
+ */
+ private String trailingName;
+
+ /**
+ * The RFC3066 language tag.
+ */
+ private String rfc3066LangageTag;
+
+ // Constructor ******************************************************************************************************
+
+ private LocaleInfo(LocaleInfo parent, Locale locale)
+ {
+ this.locale = locale;
+ this.trailingName = computeTrailingName(locale);
+ this.parent = parent;
+
+ //
+ this.rfc3066LangageTag = getRFC3066LanguageTagFor(locale);
+ }
+
+ // Public ***********************************************************************************************************
+
+ public LocaleInfo getParent()
+ {
+ return parent;
+ }
+
+ public Locale getLocale()
+ {
+ return locale;
+ }
+
+ public String getTrailingName()
+ {
+ return trailingName;
+ }
+
+ /**
+ * Retrieves the language identification tag associated to this LocaleInfo as defined by
+ * <a href="http://www.ietf.org/rfc/rfc3066.txt">IETF RFC 3066</a> limited to 2-letter
+ * language code per ISO standard 639, a "-" (dash) and a 2-letter country code per
+ * ISO 3166 alpha-2 country codes. E.g. "en-US" for American English, "en-GB" for
+ * British English, etc.
+ *
+ * @return a <a href="http://www.ietf.org/rfc/rfc3066.txt">IETF RFC 3066</a>-compatible language tag.
+ * @throws IllegalArgumentException if the given locale is not valid
+ * @since 2.4
+ */
+ public String getRFC3066LanguageTag()
+ {
+ return rfc3066LangageTag;
+ }
+
+ /**
+ * Retrieves the language identification tag associated to the specified Locale as defined by
+ * <a href="http://www.ietf.org/rfc/rfc3066.txt">IETF RFC 3066</a> limited to 2-letter
+ * language code per ISO standard 639, a "-" (dash) and a 2-letter country code per
+ * ISO 3166 alpha-2 country codes. E.g. "en-US" for American English, "en-GB" for
+ * British English, etc.
+ *
+ * @param locale the locale which language tag is wanted
+ * @return a <a href="http://www.ietf.org/rfc/rfc3066.txt">IETF RFC 3066</a>-compatible language tag.
+ * @throws IllegalArgumentException if the given locale is not valid
+ * @since 2.4
+ */
+ public static String getRFC3066LanguageTagFor(Locale locale)
+ {
+ String country = locale.getCountry(); // country will be empty if no country was specified in the locale
+ return locale.getLanguage() + ((country.length() == 2) ? RFC3066_SEPARATOR + country : country);
+ }
+
+ // Object override **************************************************************************************************
+
+ public String toString()
+ {
+ return locale.toString();
+ }
+
+ // Static ***********************************************************************************************************
+
+ /**
+ * Compute the trailing name for a given locale.
+ *
+ * @param locale the locale
+ * @return the trailing name
+ * @throws IllegalArgumentException if locale is null
+ */
+ public static String computeTrailingName(Locale locale) throws IllegalArgumentException
+ {
+ if (locale == null)
+ {
+ throw new IllegalArgumentException("locale parameter is null");
+ }
+ StringBuffer tmp = new StringBuffer();
+ if (locale.getLanguage() != null && locale.getLanguage().length() > 0)
+ {
+ tmp.append('_').append(locale.getLanguage());
+ if (locale.getCountry() != null && locale.getCountry().length() > 0)
+ {
+ tmp.append('_').append(locale.getCountry());
+ {
+ if (locale.getVariant() != null && locale.getVariant().length() > 0)
+ {
+ tmp.append('_').append(locale.getVariant());
+ }
+ }
+ }
+ }
+ return tmp.toString();
+ }
+
+ /**
+ * <p>Get an info object.</p>
+ * <p/>
+ * <p>Whenever the info object cannot be found then it creates a new one and possibly several
+ * since each info object may have a non null parent.</p>
+ * <p/>
+ * <p>If the infos argument is null, then the static shared infos is used to perform a lookup.
+ * If the lookup returns null then the shared infos is cloned and updated with the newly created
+ * info objects. The operation performed is a copy on write and is thread safe. Note that concurrent
+ * updates may cause the lost of info object in the shared infos.</p>
+ * <p/>
+ * <p>If the infos argument is not null, then it is used to perform a lookup first. If the lookup returns null
+ * then the infos object udpated with the newly created info objects. Note that no cloning of the infos object
+ * is performed.</p>
+ *
+ * @param locale the locale
+ * @param infos the infos
+ * @return A info object for the given locale
+ */
+ private static LocaleInfo getInfo(Locale locale, final Infos infos)
+ {
+ // Perform a lookup first
+ Infos workInfos = null;
+ if (infos != null)
+ {
+ workInfos = infos;
+ }
+ else
+ {
+ workInfos = sharedInfos;
+ }
+ LocaleInfo info = (LocaleInfo)workInfos.byLocaleCode.get(locale.toString());
+
+ // If the lookup fail we create a new object
+ if (info == null)
+ {
+ // Clone if it is shared
+ if (infos == null)
+ {
+ workInfos = new Infos(workInfos);
+ }
+
+ // Perform parent resolution
+ LocaleInfo parent = null;
+ if (locale.getVariant() != null && locale.getVariant().length() > 0)
+ {
+ // If this is a language/country/variant, try to get language/country
+ Locale parentLocale = new Locale(locale.getLanguage(), locale.getCountry());
+ parent = getInfo(parentLocale, workInfos);
+ }
+ else if (locale.getCountry() != null && locale.getCountry().length() > 0)
+ {
+ // If this is a language/country, try to get language
+ Locale parentLocale = new Locale(locale.getLanguage());
+ parent = getInfo(parentLocale, workInfos);
+ }
+ else
+ {
+ // When it is language then the parent is null
+ parent = null;
+ }
+
+ //
+ info = new LocaleInfo(parent, locale);
+ log.debug("LocaleInfo " + locale.toString() + " initialized");
+
+ // Add to map
+ workInfos.byLocale.put(info.getLocale(), info);
+ workInfos.byLocaleCode.put(info.getLocale().toString(), info);
+ workInfos.byRFC3066LanguageTag.put(info.getRFC3066LanguageTag(), info);
+ workInfos.list.add(info);
+// Collections.sort(workInfos.list, c);
+
+ // Replace if we have cloned
+ if (infos == null)
+ {
+ sharedInfos = workInfos;
+ }
+ }
+ return info;
+ }
+
+
+ /**
+ * Create an infos object from the set of locales returned by <code>Locale.getAvailableLocales()</code>.
+ */
+ private static Infos createFromAvailableLocales()
+ {
+ // Initialize all objects
+ Infos workInfos = new Infos();
+ Locale[] temp = Locale.getAvailableLocales();
+ for (int i = 0; i < temp.length; i++)
+ {
+ Locale locale = temp[i];
+ getInfo(locale, workInfos);
+ }
+ return workInfos;
+ }
+
+ /**
+ * Return a collection of all available locale info for the platform.
+ */
+ public static Collection getAll()
+ {
+ return sharedInfos.unmodifiableList;
+ }
+
+ /**
+ * Return the locale info for a specific code.
+ *
+ * @throws IllegalArgumentException if the locale info is not found for the code
+ */
+ public static LocaleInfo decodeLocaleInfo(String code) throws IllegalArgumentException
+ {
+ LocaleInfo info = (LocaleInfo)sharedInfos.byLocaleCode.get(code);
+ if (info == null)
+ {
+ throw new IllegalArgumentException("No locale info found for " + code);
+ }
+ return info;
+ }
+
+ /**
+ * Return the locale info for a specific locale.
+ *
+ * @throws IllegalArgumentException if the locale is not found for the code
+ */
+ public static LocaleInfo decodeLocaleInfo(Locale locale)
+ {
+ LocaleInfo info = (LocaleInfo)sharedInfos.byLocale.get(locale);
+ if (info == null)
+ {
+ throw new IllegalArgumentException("No locale info found for " + locale);
+ }
+ return info;
+ }
+
+ /**
+ * Returns an info object based on the given language identification tag as defined by
+ * <a href="http://www.ietf.org/rfc/rfc3066.txt">IETF RFC 3066</a> limited to 2-letter
+ * language code per ISO standard 639, a "-" (dash) and a 2-letter country code per
+ * ISO 3166 alpha-2 country codes. E.g. "en-US" for American English, "en-GB" for
+ * British English, etc.
+ *
+ * @param languageIdentificationTag the language tag to build the Locale from
+ * @return a LocaleInfo associated to the given compound language tag
+ * @throws IllegalArgumentException if the given compound language is not a valid one or null
+ * @since 2.4
+ */
+ public static LocaleInfo decodeLocaleInfoFromRFC3066LanguageTag(String languageIdentificationTag)
+ {
+ if (languageIdentificationTag == null)
+ {
+ throw new IllegalArgumentException("Null language identification tag not accepted");
+ }
+
+ LocaleInfo info = (LocaleInfo)sharedInfos.byRFC3066LanguageTag.get(languageIdentificationTag);
+ if (info == null)
+ {
+ Matcher matcher = RFC3066_COMPOUND_LANG_PATTERN.matcher(languageIdentificationTag);
+ if (matcher.matches())
+ {
+ String language = matcher.group(1);
+ if (Arrays.binarySearch(SORTED_ISO_LANGUAGES, language) < 0)
+ {
+ throw new IllegalArgumentException("Invalid ISO language code: " + language);
+ }
+ String country = matcher.group(3);
+ if (country != null && Arrays.binarySearch(SORTED_ISO_COUNTRIES, country) < 0)
+ {
+ throw new IllegalArgumentException("Invalid ISO country code: " + country);
+ }
+ return new LocaleInfo(LocaleInfo.decodeLocaleInfo(language), new Locale(language, country));
+ }
+ throw new IllegalArgumentException(languageIdentificationTag + " is not a valid compound language : accepted " +
+ "format is xx-YY where xx is a valid ISO language code and YY is a valid country code. See " +
+ "java.util.Locale javadoc for more info.");
+ }
+ return info;
+ }
+
+
+ /**
+ * Hold the several ways to retrieve infos object.
+ */
+ private static class Infos
+ {
+ /**
+ * The info by locale.
+ */
+ private Map byLocale;
+
+ /**
+ * The info by locale#toString() code.
+ */
+ private Map byLocaleCode;
+
+ /**
+ * The info by locale RFC3066 language tag.
+ */
+ private Map byRFC3066LanguageTag;
+
+ /**
+ * All the infos.
+ */
+ private List list;
+
+ /**
+ * All the infos as an unmodifiable list.
+ */
+ private List unmodifiableList;
+
+ /**
+ * Construct a new info object.
+ */
+ public Infos()
+ {
+ this.byLocale = new HashMap();
+ this.byLocaleCode = new HashMap();
+ this.byRFC3066LanguageTag = new HashMap();
+ this.list = new ArrayList();
+ this.unmodifiableList = Collections.unmodifiableList(list);
+ }
+
+ /**
+ * Clone the info object state passed as argument.
+ */
+ public Infos(Infos that)
+ {
+ this.byLocale = new HashMap(that.byLocale);
+ this.byLocaleCode = new HashMap(that.byLocaleCode);
+ this.byRFC3066LanguageTag = new HashMap(that.byRFC3066LanguageTag);
+ this.list = new ArrayList(that.list);
+ this.unmodifiableList = Collections.unmodifiableList(list);
+ }
+ }
+}
Property changes on: trunk/common/src/main/org/jboss/portal/common/i18n/LocaleInfo.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: trunk/common/src/main/org/jboss/portal/common/i18n/LocalizedString.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/i18n/LocalizedString.java 2007-03-25 12:48:44 UTC (rev 6820)
+++ trunk/common/src/main/org/jboss/portal/common/i18n/LocalizedString.java 2007-03-25 13:20:26 UTC (rev 6821)
@@ -23,7 +23,7 @@
package org.jboss.portal.common.i18n;
import org.apache.log4j.Logger;
-import org.jboss.portal.common.util.LocaleInfo;
+import org.jboss.portal.common.i18n.LocaleInfo;
import java.util.Collections;
import java.util.HashMap;
@@ -32,29 +32,36 @@
import java.util.Map;
/**
- * An immutable localized string.
+ * An immutable locale sensitive object that returns strings.
*
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
* @version $Revision$
*/
-public class LocalizedString
+public final class LocalizedString
{
/** The logger. */
private static final Logger log = Logger.getLogger(LocalizedString.class);
- /** The descriptions. */
+ /** An unmodifiable <Locale,String>Map. */
private final Map values;
/** The default locale. */
private final Locale defaultLocale;
+ /** The cached hashCode. */
+ private Integer hashCode;
+
+ /** The cached toString. */
+ private String cachedToString;
+
/**
* Convenience constructor for simple localized strings with only one value using the default locale.
*
* @param defaultValue the localized value using the specified default locale
* @param defaultLocale the default locale
+ * @throws IllegalArgumentException if no default value or locale is provided
* @since 2.4
*/
public LocalizedString(String defaultValue, Locale defaultLocale) throws IllegalArgumentException
@@ -69,7 +76,7 @@
}
//
- Map values = new HashMap(3);
+ Map values = new HashMap(1);
addValueForLocale(values, defaultLocale, defaultValue);
//
@@ -77,6 +84,12 @@
this.values = Collections.unmodifiableMap(values);
}
+ /**
+ * Build an empty localized string.
+ *
+ * @param defaultLocale the default locale
+ * @throws IllegalArgumentException if no default locale is provided
+ */
public LocalizedString(Locale defaultLocale) throws IllegalArgumentException
{
if (defaultLocale == null)
@@ -89,6 +102,13 @@
this.values = Collections.EMPTY_MAP;
}
+ /**
+ * Build a localized string using a <Locale,String>Map object.
+ *
+ * @param values the <Locale,String>Map
+ * @param defaultLocale
+ * @throws IllegalArgumentException if one argument if null or if the map entries are different from <Locale,String>Map.Entry
+ */
public LocalizedString(Map values, Locale defaultLocale) throws IllegalArgumentException
{
if (values == null)
@@ -131,7 +151,7 @@
* @param value the value
* @since 2.4
*/
- private void addValueForLocale(Map values, Locale locale, String value)
+ private static void addValueForLocale(Map values, Locale locale, String value)
{
values.put(locale, new Value(locale, value));
}
@@ -158,7 +178,7 @@
}
/**
- * Return the value for the default locale.
+ * Returns the value for the default locale.
*
* @return the value for the default locale
*/
@@ -168,11 +188,11 @@
}
/**
- * Return the string of the localized value of the description.
+ * Returns a string value.
*
- * @param locale the desired locale for the description
+ * @param locale the desired locale
* @param resolve true if the locale must be resolved to the most appropriate
- * @return the description string or null if it is not found when resolving is false
+ * @return the description string or null if it is not found
*/
public String getString(Locale locale, boolean resolve)
{
@@ -188,11 +208,13 @@
}
/**
- * Return a localized value of the description.
+ * Returns a localized value. The lookup operation can be done without resolution which
+ * means that the locale is just used as a key during the lookup. If the lookup operation is done with
+ * resolution then the different parts of the locale will be used during the operation.
*
- * @param locale the desired locale for the description
+ * @param locale the desired locale
* @param resolve true if the locale must be resolved to the most appropriate
- * @return the description value or null if it is not found when resolving is false
+ * @return the value or null if it is not found
*/
public Value getValue(Locale locale, boolean resolve)
{
@@ -209,20 +231,20 @@
if (resolve)
{
- Value desc = (Value)values.get(locale);
- if (desc == null && !locale.getVariant().equals(""))
+ Value value = (Value)values.get(locale);
+ if (value == null && !locale.getVariant().equals(""))
{
- desc = (Value)values.get(new Locale(locale.getLanguage(), locale.getCountry()));
+ value = (Value)values.get(new Locale(locale.getLanguage(), locale.getCountry()));
}
- if (desc == null && !locale.getCountry().equals(""))
+ if (value == null && !locale.getCountry().equals(""))
{
- desc = (Value)values.get(new Locale(locale.getLanguage()));
+ value = (Value)values.get(new Locale(locale.getLanguage()));
}
- if (desc == null)
+ if (value == null)
{
- desc = (Value)values.get(defaultLocale);
+ value = (Value)values.get(defaultLocale);
}
- return desc;
+ return value;
}
else
{
@@ -230,7 +252,11 @@
}
}
- /** Return the default locale of this description. */
+ /**
+ * Return the default locale of this localized string.
+ *
+ * @return the default locale
+ */
public Locale getDefaultLocale()
{
return defaultLocale;
@@ -261,7 +287,7 @@
* @return a Map.Entry representing the most appropriate mapping between Locale and localized value, based on locale
* preferences.
* @throws IllegalArgumentException if the array is null or one of the array string is null or invalid (see {@link
- * org.jboss.portal.common.util.LocaleInfo#decodeLocaleInfoFromRFC3066LanguageTag(String)}
+ * LocaleInfo#decodeLocaleInfoFromRFC3066LanguageTag(String)}
* @since 2.4
*/
public Value getPreferredOrBestLocalizedMappingFor(String[] desiredLocales) throws IllegalArgumentException
@@ -271,6 +297,7 @@
throw new IllegalArgumentException("No null desired locale array accepted");
}
+ //
if (values.isEmpty())
{
return null;
@@ -278,21 +305,22 @@
//
Value value = null;
-
- //
if (desiredLocales.length > 0)
{
- LocaleInfo info;
for (int i = 0; value == null && i < desiredLocales.length; i++)
{
String desiredLocale = desiredLocales[i];
+
+ //
if (desiredLocale == null)
{
throw new IllegalArgumentException("Null desired locale not accepted");
}
+
+ //
try
{
- info = LocaleInfo.decodeLocaleInfoFromRFC3066LanguageTag(desiredLocale);
+ LocaleInfo info = LocaleInfo.decodeLocaleInfoFromRFC3066LanguageTag(desiredLocale);
Locale locale = info.getLocale();
value = getValue(locale, true);
}
@@ -320,19 +348,67 @@
return value;
}
- /** A localized value. */
+ public String toString()
+ {
+ if (cachedToString == null)
+ {
+ cachedToString = "LocalizedString: '" + getMostAppropriateValueFor(new String[0]) + "' default: " + getDefaultLocale();
+ }
+ return cachedToString;
+ }
+
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || LocalizedString.class != o.getClass())
+ {
+ return false;
+ }
+
+ //
+ LocalizedString that = (LocalizedString)o;
+ return defaultLocale.equals(that.defaultLocale) && getMostAppropriateValueFor(new String[0]).equals(that.getMostAppropriateValueFor(new String[0]));
+ }
+
+ public int hashCode()
+ {
+ if (hashCode == null)
+ {
+ hashCode = new Integer(31 * getMostAppropriateValueFor(new String[0]).hashCode() + defaultLocale.hashCode());
+ }
+ return hashCode.intValue();
+ }
+
+ /**
+ * A localized string value.
+ */
public static class Value
{
+ /** The locale that describes the string. */
private final Locale locale;
+
+ /** the string value. */
private final String string;
- public Value(Locale locale, String string)
+ /**
+ * @param locale the locale
+ * @param string the string
+ * @throws IllegalArgumentException if one argument is null
+ */
+ public Value(Locale locale, String string) throws IllegalArgumentException
{
if (locale == null)
{
throw new IllegalArgumentException();
}
+ if (string == null)
+ {
+ throw new IllegalArgumentException();
+ }
this.locale = locale;
this.string = string;
}
@@ -347,35 +423,4 @@
return string;
}
}
-
- public String toString()
- {
- return "LocalizedString: '" + getMostAppropriateValueFor(new String[0]) + "' default: " + getDefaultLocale();
- }
-
-
- public boolean equals(Object o)
- {
- if (this == o)
- {
- return true;
- }
- if (o == null || getClass() != o.getClass())
- {
- return false;
- }
-
- LocalizedString that = (LocalizedString)o;
-
- return getMostAppropriateValueFor(new String[0]).equals(that.getMostAppropriateValueFor(new String[0]))
- && defaultLocale.equals(that.defaultLocale);
- }
-
- public int hashCode()
- {
- int result;
- result = getMostAppropriateValueFor(new String[0]).hashCode();
- result = 31 * result + defaultLocale.hashCode();
- return result;
- }
}
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-25 12:48:44 UTC (rev 6820)
+++ trunk/common/src/main/org/jboss/portal/common/i18n/ResourceBundleManager.java 2007-03-25 13:20:26 UTC (rev 6821)
@@ -77,7 +77,8 @@
/**
* Return a localized value constructed from the various resource bundles. The supported locales of the manager are
* used in combination with the specified key. The default value is used if no value is found for the
- * <code>Locale.ENGLISH</code>.
+ * <code>Locale.ENGLISH</code>. Two successive calls to this method may not return identical results since the
+ * returned <code>LocalizedString</code> is built using the bundles known by the manager.
*
* @param key the key to lookup in the bundles
* @param defaultValue the default value
Deleted: trunk/common/src/main/org/jboss/portal/common/util/LocaleInfo.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/util/LocaleInfo.java 2007-03-25 12:48:44 UTC (rev 6820)
+++ trunk/common/src/main/org/jboss/portal/common/util/LocaleInfo.java 2007-03-25 13:20:26 UTC (rev 6821)
@@ -1,460 +0,0 @@
-/******************************************************************************
- * 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.util;
-
-import org.apache.log4j.Logger;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * Additional infos about a locale.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision$
- * @noinspection ALL
- */
-public final class LocaleInfo
-{
-
- // Static fields ****************************************************************************************************
-
- /**
- * The logger.
- */
- private static Logger log = Logger.getLogger(LocaleInfo.class);
-
- /**
- * The locale info map.
- */
- private static volatile Infos sharedInfos = createFromAvailableLocales();
-
- /**
- * Separator.
- */
- private static final String RFC3066_SEPARATOR = "-";
-
- /**
- * Valid language tag matcher (see <a href="http://www.ietf.org/rfc/rfc3066.txt">IETF RFC 3066</a>).
- */
- private static final Pattern RFC3066_COMPOUND_LANG_PATTERN = Pattern.compile("(\\p{Lower}{2})(-(\\p{Upper}{2}))?");
-
- /**
- * Sorted valid ISO country codes (needed for Arrays.binarySearch).
- */
- private static final String[] SORTED_ISO_COUNTRIES = Locale.getISOCountries();
-
- /**
- * Sorted valid ISO language codes (needed for Arrays.binarySearch).
- */
- private static final String[] SORTED_ISO_LANGUAGES = Locale.getISOLanguages();
-
- private static final Comparator c = new Comparator()
- {
- public int compare(Object o1, Object o2)
- {
- String s1 = ((LocaleInfo)o1).getTrailingName();
- String s2 = ((LocaleInfo)o2).getTrailingName();
- return s1.compareTo(s2);
- }
- };
-
-
- static
- {
- // should already be sorted but in case they're not...
- Arrays.sort(SORTED_ISO_COUNTRIES);
- Arrays.sort(SORTED_ISO_LANGUAGES);
- }
-
- // Fields ***********************************************************************************************************
-
- /**
- * The parent locale info or null if no parent.
- */
- private LocaleInfo parent;
-
- /**
- * The relaled locale.
- */
- private Locale locale;
-
- /**
- * The trailing name used to compute resource bundle name.
- */
- private String trailingName;
-
- /**
- * The RFC3066 language tag.
- */
- private String rfc3066LangageTag;
-
- // Constructor ******************************************************************************************************
-
- private LocaleInfo(LocaleInfo parent, Locale locale)
- {
- this.locale = locale;
- this.trailingName = computeTrailingName(locale);
- this.parent = parent;
-
- //
- this.rfc3066LangageTag = getRFC3066LanguageTagFor(locale);
- }
-
- // Public ***********************************************************************************************************
-
- public LocaleInfo getParent()
- {
- return parent;
- }
-
- public Locale getLocale()
- {
- return locale;
- }
-
- public String getTrailingName()
- {
- return trailingName;
- }
-
- /**
- * Retrieves the language identification tag associated to this LocaleInfo as defined by
- * <a href="http://www.ietf.org/rfc/rfc3066.txt">IETF RFC 3066</a> limited to 2-letter
- * language code per ISO standard 639, a "-" (dash) and a 2-letter country code per
- * ISO 3166 alpha-2 country codes. E.g. "en-US" for American English, "en-GB" for
- * British English, etc.
- *
- * @return a <a href="http://www.ietf.org/rfc/rfc3066.txt">IETF RFC 3066</a>-compatible language tag.
- * @throws IllegalArgumentException if the given locale is not valid
- * @since 2.4
- */
- public String getRFC3066LanguageTag()
- {
- return rfc3066LangageTag;
- }
-
- /**
- * Retrieves the language identification tag associated to the specified Locale as defined by
- * <a href="http://www.ietf.org/rfc/rfc3066.txt">IETF RFC 3066</a> limited to 2-letter
- * language code per ISO standard 639, a "-" (dash) and a 2-letter country code per
- * ISO 3166 alpha-2 country codes. E.g. "en-US" for American English, "en-GB" for
- * British English, etc.
- *
- * @param locale the locale which language tag is wanted
- * @return a <a href="http://www.ietf.org/rfc/rfc3066.txt">IETF RFC 3066</a>-compatible language tag.
- * @throws IllegalArgumentException if the given locale is not valid
- * @since 2.4
- */
- public static String getRFC3066LanguageTagFor(Locale locale)
- {
- String country = locale.getCountry(); // country will be empty if no country was specified in the locale
- return locale.getLanguage() + ((country.length() == 2) ? RFC3066_SEPARATOR + country : country);
- }
-
- // Object override **************************************************************************************************
-
- public String toString()
- {
- return locale.toString();
- }
-
- // Static ***********************************************************************************************************
-
- /**
- * Compute the trailing name for a given locale.
- *
- * @param locale the locale
- * @return the trailing name
- * @throws IllegalArgumentException if locale is null
- */
- public static String computeTrailingName(Locale locale) throws IllegalArgumentException
- {
- if (locale == null)
- {
- throw new IllegalArgumentException("locale parameter is null");
- }
- StringBuffer tmp = new StringBuffer();
- if (locale.getLanguage() != null && locale.getLanguage().length() > 0)
- {
- tmp.append('_').append(locale.getLanguage());
- if (locale.getCountry() != null && locale.getCountry().length() > 0)
- {
- tmp.append('_').append(locale.getCountry());
- {
- if (locale.getVariant() != null && locale.getVariant().length() > 0)
- {
- tmp.append('_').append(locale.getVariant());
- }
- }
- }
- }
- return tmp.toString();
- }
-
- /**
- * <p>Get an info object.</p>
- * <p/>
- * <p>Whenever the info object cannot be found then it creates a new one and possibly several
- * since each info object may have a non null parent.</p>
- * <p/>
- * <p>If the infos argument is null, then the static shared infos is used to perform a lookup.
- * If the lookup returns null then the shared infos is cloned and updated with the newly created
- * info objects. The operation performed is a copy on write and is thread safe. Note that concurrent
- * updates may cause the lost of info object in the shared infos.</p>
- * <p/>
- * <p>If the infos argument is not null, then it is used to perform a lookup first. If the lookup returns null
- * then the infos object udpated with the newly created info objects. Note that no cloning of the infos object
- * is performed.</p>
- *
- * @param locale the locale
- * @param infos the infos
- * @return A info object for the given locale
- */
- private static LocaleInfo getInfo(Locale locale, final Infos infos)
- {
- // Perform a lookup first
- Infos workInfos = null;
- if (infos != null)
- {
- workInfos = infos;
- }
- else
- {
- workInfos = sharedInfos;
- }
- LocaleInfo info = (LocaleInfo)workInfos.byLocaleCode.get(locale.toString());
-
- // If the lookup fail we create a new object
- if (info == null)
- {
- // Clone if it is shared
- if (infos == null)
- {
- workInfos = new Infos(workInfos);
- }
-
- // Perform parent resolution
- LocaleInfo parent = null;
- if (locale.getVariant() != null && locale.getVariant().length() > 0)
- {
- // If this is a language/country/variant, try to get language/country
- Locale parentLocale = new Locale(locale.getLanguage(), locale.getCountry());
- parent = getInfo(parentLocale, workInfos);
- }
- else if (locale.getCountry() != null && locale.getCountry().length() > 0)
- {
- // If this is a language/country, try to get language
- Locale parentLocale = new Locale(locale.getLanguage());
- parent = getInfo(parentLocale, workInfos);
- }
- else
- {
- // When it is language then the parent is null
- parent = null;
- }
-
- //
- info = new LocaleInfo(parent, locale);
- log.debug("LocaleInfo " + locale.toString() + " initialized");
-
- // Add to map
- workInfos.byLocale.put(info.getLocale(), info);
- workInfos.byLocaleCode.put(info.getLocale().toString(), info);
- workInfos.byRFC3066LanguageTag.put(info.getRFC3066LanguageTag(), info);
- workInfos.list.add(info);
-// Collections.sort(workInfos.list, c);
-
- // Replace if we have cloned
- if (infos == null)
- {
- sharedInfos = workInfos;
- }
- }
- return info;
- }
-
-
- /**
- * Create an infos object from the set of locales returned by <code>Locale.getAvailableLocales()</code>.
- */
- private static Infos createFromAvailableLocales()
- {
- // Initialize all objects
- Infos workInfos = new Infos();
- Locale[] temp = Locale.getAvailableLocales();
- for (int i = 0; i < temp.length; i++)
- {
- Locale locale = temp[i];
- getInfo(locale, workInfos);
- }
- return workInfos;
- }
-
- /**
- * Return a collection of all available locale info for the platform.
- */
- public static Collection getAll()
- {
- return sharedInfos.unmodifiableList;
- }
-
- /**
- * Return the locale info for a specific code.
- *
- * @throws IllegalArgumentException if the locale info is not found for the code
- */
- public static LocaleInfo decodeLocaleInfo(String code) throws IllegalArgumentException
- {
- LocaleInfo info = (LocaleInfo)sharedInfos.byLocaleCode.get(code);
- if (info == null)
- {
- throw new IllegalArgumentException("No locale info found for " + code);
- }
- return info;
- }
-
- /**
- * Return the locale info for a specific locale.
- *
- * @throws IllegalArgumentException if the locale is not found for the code
- */
- public static LocaleInfo decodeLocaleInfo(Locale locale)
- {
- LocaleInfo info = (LocaleInfo)sharedInfos.byLocale.get(locale);
- if (info == null)
- {
- throw new IllegalArgumentException("No locale info found for " + locale);
- }
- return info;
- }
-
- /**
- * Returns an info object based on the given language identification tag as defined by
- * <a href="http://www.ietf.org/rfc/rfc3066.txt">IETF RFC 3066</a> limited to 2-letter
- * language code per ISO standard 639, a "-" (dash) and a 2-letter country code per
- * ISO 3166 alpha-2 country codes. E.g. "en-US" for American English, "en-GB" for
- * British English, etc.
- *
- * @param languageIdentificationTag the language tag to build the Locale from
- * @return a LocaleInfo associated to the given compound language tag
- * @throws IllegalArgumentException if the given compound language is not a valid one or null
- * @since 2.4
- */
- public static LocaleInfo decodeLocaleInfoFromRFC3066LanguageTag(String languageIdentificationTag)
- {
- if (languageIdentificationTag == null)
- {
- throw new IllegalArgumentException("Null language identification tag not accepted");
- }
-
- LocaleInfo info = (LocaleInfo)sharedInfos.byRFC3066LanguageTag.get(languageIdentificationTag);
- if (info == null)
- {
- Matcher matcher = RFC3066_COMPOUND_LANG_PATTERN.matcher(languageIdentificationTag);
- if (matcher.matches())
- {
- String language = matcher.group(1);
- if (Arrays.binarySearch(SORTED_ISO_LANGUAGES, language) < 0)
- {
- throw new IllegalArgumentException("Invalid ISO language code: " + language);
- }
- String country = matcher.group(3);
- if (country != null && Arrays.binarySearch(SORTED_ISO_COUNTRIES, country) < 0)
- {
- throw new IllegalArgumentException("Invalid ISO country code: " + country);
- }
- return new LocaleInfo(LocaleInfo.decodeLocaleInfo(language), new Locale(language, country));
- }
- throw new IllegalArgumentException(languageIdentificationTag + " is not a valid compound language : accepted " +
- "format is xx-YY where xx is a valid ISO language code and YY is a valid country code. See " +
- "java.util.Locale javadoc for more info.");
- }
- return info;
- }
-
-
- /**
- * Hold the several ways to retrieve infos object.
- */
- private static class Infos
- {
- /**
- * The info by locale.
- */
- private Map byLocale;
-
- /**
- * The info by locale#toString() code.
- */
- private Map byLocaleCode;
-
- /**
- * The info by locale RFC3066 language tag.
- */
- private Map byRFC3066LanguageTag;
-
- /**
- * All the infos.
- */
- private List list;
-
- /**
- * All the infos as an unmodifiable list.
- */
- private List unmodifiableList;
-
- /**
- * Construct a new info object.
- */
- public Infos()
- {
- this.byLocale = new HashMap();
- this.byLocaleCode = new HashMap();
- this.byRFC3066LanguageTag = new HashMap();
- this.list = new ArrayList();
- this.unmodifiableList = Collections.unmodifiableList(list);
- }
-
- /**
- * Clone the info object state passed as argument.
- */
- public Infos(Infos that)
- {
- this.byLocale = new HashMap(that.byLocale);
- this.byLocaleCode = new HashMap(that.byLocaleCode);
- this.byRFC3066LanguageTag = new HashMap(that.byRFC3066LanguageTag);
- this.list = new ArrayList(that.list);
- this.unmodifiableList = Collections.unmodifiableList(list);
- }
- }
-}
Modified: trunk/common/src/main/org/jboss/portal/test/common/LocaleInfoTestCase.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/test/common/LocaleInfoTestCase.java 2007-03-25 12:48:44 UTC (rev 6820)
+++ trunk/common/src/main/org/jboss/portal/test/common/LocaleInfoTestCase.java 2007-03-25 13:20:26 UTC (rev 6821)
@@ -23,7 +23,7 @@
package org.jboss.portal.test.common;
import junit.framework.TestCase;
-import org.jboss.portal.common.util.LocaleInfo;
+import org.jboss.portal.common.i18n.LocaleInfo;
import java.util.Iterator;
import java.util.Locale;
Modified: trunk/core/src/main/org/jboss/portal/core/portlet/user/UserPortlet.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/portlet/user/UserPortlet.java 2007-03-25 12:48:44 UTC (rev 6820)
+++ trunk/core/src/main/org/jboss/portal/core/portlet/user/UserPortlet.java 2007-03-25 13:20:26 UTC (rev 6821)
@@ -49,7 +49,7 @@
import org.jboss.portal.api.node.PortalNode;
import org.jboss.portal.api.node.PortalNodeURL;
import org.jboss.portal.common.p3p.P3PConstants;
-import org.jboss.portal.common.util.LocaleInfo;
+import org.jboss.portal.common.i18n.LocaleInfo;
import org.jboss.portal.common.util.Tools;
import org.jboss.portal.common.util.URLTools;
import org.jboss.portal.core.aspects.controller.node.Navigation;
Modified: trunk/identity/src/main/org/jboss/portal/identity/config/metadata/profile/ProfileMetaDataFactory.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity/config/metadata/profile/ProfileMetaDataFactory.java 2007-03-25 12:48:44 UTC (rev 6820)
+++ trunk/identity/src/main/org/jboss/portal/identity/config/metadata/profile/ProfileMetaDataFactory.java 2007-03-25 13:20:26 UTC (rev 6821)
@@ -23,7 +23,7 @@
import org.jboss.xb.binding.GenericObjectModelFactory;
import org.jboss.xb.binding.UnmarshallingContext;
-import org.jboss.portal.common.util.LocaleInfo;
+import org.jboss.portal.common.i18n.LocaleInfo;
import org.xml.sax.Attributes;
import java.util.Locale;
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/deployment/PortletApplicationMetaDataFactory.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/deployment/PortletApplicationMetaDataFactory.java 2007-03-25 12:48:44 UTC (rev 6820)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/deployment/PortletApplicationMetaDataFactory.java 2007-03-25 13:20:26 UTC (rev 6821)
@@ -23,7 +23,7 @@
package org.jboss.portal.portlet.deployment;
import org.jboss.portal.Mode;
-import org.jboss.portal.common.util.LocaleInfo;
+import org.jboss.portal.common.i18n.LocaleInfo;
import org.jboss.portal.common.util.Tools;
import org.jboss.portal.portlet.TransportGuarantee;
import org.jboss.portal.portlet.impl.jsr168.metadata.CacheConfigMetaData;
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/UserContextConverter.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/UserContextConverter.java 2007-03-25 12:48:44 UTC (rev 6820)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/UserContextConverter.java 2007-03-25 13:20:26 UTC (rev 6821)
@@ -24,7 +24,7 @@
package org.jboss.portal.wsrp;
import org.jboss.portal.common.p3p.P3PConstants;
-import org.jboss.portal.common.util.LocaleInfo;
+import org.jboss.portal.common.i18n.LocaleInfo;
import org.jboss.portal.portlet.spi.UserContext;
import org.jboss.portal.wsrp.core.Contact;
import org.jboss.portal.wsrp.core.EmployerInfo;
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPUtils.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPUtils.java 2007-03-25 12:48:44 UTC (rev 6820)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPUtils.java 2007-03-25 13:20:26 UTC (rev 6821)
@@ -25,7 +25,7 @@
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
-import org.jboss.portal.common.util.LocaleInfo;
+import org.jboss.portal.common.i18n.LocaleInfo;
import org.jboss.portal.common.util.ParameterValidation;
import org.jboss.portal.portlet.ActionURL;
import org.jboss.portal.portlet.PortletContext;
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java 2007-03-25 12:48:44 UTC (rev 6820)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java 2007-03-25 13:20:26 UTC (rev 6821)
@@ -23,7 +23,7 @@
package org.jboss.portal.wsrp.consumer;
import org.jboss.portal.common.invocation.InvocationException;
-import org.jboss.portal.common.util.LocaleInfo;
+import org.jboss.portal.common.i18n.LocaleInfo;
import org.jboss.portal.common.util.ParameterValidation;
import org.jboss.portal.common.value.StringValue;
import org.jboss.portal.jems.as.system.AbstractJBossService;
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/portlet/info/WSRPPortletInfo.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/portlet/info/WSRPPortletInfo.java 2007-03-25 12:48:44 UTC (rev 6820)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/portlet/info/WSRPPortletInfo.java 2007-03-25 13:20:26 UTC (rev 6821)
@@ -25,7 +25,7 @@
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
-import org.jboss.portal.common.util.LocaleInfo;
+import org.jboss.portal.common.i18n.LocaleInfo;
import org.jboss.portal.common.util.ParameterValidation;
import org.jboss.portal.portlet.info.CacheInfo;
import org.jboss.portal.portlet.info.CapabilitiesInfo;
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupRequest.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupRequest.java 2007-03-25 12:48:44 UTC (rev 6820)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupRequest.java 2007-03-25 13:20:26 UTC (rev 6821)
@@ -23,7 +23,7 @@
package org.jboss.portal.wsrp.producer;
-import org.jboss.portal.common.util.LocaleInfo;
+import org.jboss.portal.common.i18n.LocaleInfo;
import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.wsrp.WSRPUtils;
import org.jboss.portal.wsrp.core.MarkupType;
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/PortletManagementHandler.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/PortletManagementHandler.java 2007-03-25 12:48:44 UTC (rev 6820)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/PortletManagementHandler.java 2007-03-25 13:20:26 UTC (rev 6821)
@@ -24,7 +24,7 @@
package org.jboss.portal.wsrp.producer;
import org.jboss.logging.Logger;
-import org.jboss.portal.common.util.LocaleInfo;
+import org.jboss.portal.common.i18n.LocaleInfo;
import org.jboss.portal.common.i18n.LocalizedString;
import org.jboss.portal.common.util.Tools;
import org.jboss.portal.common.value.StringValue;
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java 2007-03-25 12:48:44 UTC (rev 6820)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java 2007-03-25 13:20:26 UTC (rev 6821)
@@ -24,7 +24,7 @@
package org.jboss.portal.wsrp.producer;
import org.jboss.logging.Logger;
-import org.jboss.portal.common.util.LocaleInfo;
+import org.jboss.portal.common.i18n.LocaleInfo;
import org.jboss.portal.common.util.ParameterValidation;
import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.PortletInvokerException;
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/config/ProducerConfigurationFactory.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/config/ProducerConfigurationFactory.java 2007-03-25 12:48:44 UTC (rev 6820)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/config/ProducerConfigurationFactory.java 2007-03-25 13:20:26 UTC (rev 6821)
@@ -23,7 +23,7 @@
package org.jboss.portal.wsrp.producer.config;
-import org.jboss.portal.common.util.LocaleInfo;
+import org.jboss.portal.common.i18n.LocaleInfo;
import org.jboss.portal.common.util.ParameterValidation;
import org.jboss.portal.wsrp.producer.config.impl.ProducerConfigurationImpl;
import org.jboss.portal.wsrp.producer.config.impl.ProducerRegistrationRequirementsImpl;
17 years, 3 months
JBoss Portal SVN: r6820 - trunk/common/src/main/org/jboss/portal/common/i18n.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-03-25 08:48:44 -0400 (Sun, 25 Mar 2007)
New Revision: 6820
Modified:
trunk/common/src/main/org/jboss/portal/common/i18n/ResourceBundleFactory.java
trunk/common/src/main/org/jboss/portal/common/i18n/ResourceBundleManager.java
Log:
resource bundle manager and factory basic javadoc
Modified: trunk/common/src/main/org/jboss/portal/common/i18n/ResourceBundleFactory.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/i18n/ResourceBundleFactory.java 2007-03-25 02:23:56 UTC (rev 6819)
+++ trunk/common/src/main/org/jboss/portal/common/i18n/ResourceBundleFactory.java 2007-03-25 12:48:44 UTC (rev 6820)
@@ -26,6 +26,8 @@
import java.util.Locale;
/**
+ * Definition of a factory for resource bundles.
+ *
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
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-25 02:23:56 UTC (rev 6819)
+++ trunk/common/src/main/org/jboss/portal/common/i18n/ResourceBundleManager.java 2007-03-25 12:48:44 UTC (rev 6820)
@@ -33,8 +33,12 @@
import java.util.MissingResourceException;
/**
- * Manage a set of resource bundles.
+ * <p>Manage a set of resource bundles. Obtention of bundles is done using a ResourceBundleFactory object.
+ * A bundle obtained succesfully is cached in order to avoid the potential expensive cost of bundle obtention.</p>
*
+ * <p>The manager can also be used to build LocalizedString object from the loaded bundles.</p>
+ *
+ *
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
* @version $Revision: 6697 $
@@ -42,20 +46,29 @@
public class ResourceBundleManager
{
- /** */
+ /** . */
private Logger log = Logger.getLogger(getClass());
- /** */
+ /** . */
private volatile Map localeBundles;
- /** */
+ /** . */
private ResourceBundle defaultBundle;
- /** */
+ /** . */
private ResourceBundleFactory resourceBundleFactory;
- public ResourceBundleManager(ResourceBundle defaultBundle, ResourceBundleFactory resourceBundleFactory)
+ /**
+ * @param defaultBundle the default bundle returned when no bundle has been obtained for the locale
+ * @param resourceBundleFactory the resource bundle factory
+ * @throws IllegalArgumentException IllegalArgumentException if the resource bundle factory is null
+ */
+ public ResourceBundleManager(ResourceBundle defaultBundle, ResourceBundleFactory resourceBundleFactory) throws IllegalArgumentException
{
+ if (resourceBundleFactory == null)
+ {
+ throw new IllegalArgumentException("Need a resource bundle factory");
+ }
this.localeBundles = new HashMap();
this.defaultBundle = defaultBundle;
this.resourceBundleFactory = resourceBundleFactory;
17 years, 3 months
JBoss Portal SVN: r6819 - trunk/core/src/main/org/jboss/portal/core/impl/model/content/portlet.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-03-24 22:23:56 -0400 (Sat, 24 Mar 2007)
New Revision: 6819
Modified:
trunk/core/src/main/org/jboss/portal/core/impl/model/content/portlet/InternalPortletContentProvider.java
Log:
commenting a line of code that should not have been commited yet during i18n work
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-24 23:13:11 UTC (rev 6818)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/content/portlet/InternalPortletContentProvider.java 2007-03-25 02:23:56 UTC (rev 6819)
@@ -86,7 +86,7 @@
public void start() throws Exception
{
- bundle = ResourceBundle.getBundle("conf/bundles/PortletContent", Locale.ENGLISH, Thread.currentThread().getContextClassLoader());
+ // bundle = ResourceBundle.getBundle("conf/bundles/PortletContent", Locale.ENGLISH, Thread.currentThread().getContextClassLoader());
// displayName = new LocalizedString();
17 years, 3 months
JBoss Portal SVN: r6818 - in trunk: common/src/main/org/jboss/portal/common/util and 24 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-03-24 19:13:11 -0400 (Sat, 24 Mar 2007)
New Revision: 6818
Added:
trunk/common/src/main/org/jboss/portal/common/i18n/LocalizedPropertyResourceBundle.java
trunk/common/src/main/org/jboss/portal/common/i18n/LocalizedString.java
trunk/common/src/main/org/jboss/portal/common/i18n/MapResourceBundle.java
trunk/common/src/main/org/jboss/portal/common/i18n/ParentChildResourceBundle.java
Removed:
trunk/common/src/main/org/jboss/portal/common/util/LocalizedPropertyResourceBundle.java
trunk/common/src/main/org/jboss/portal/common/util/LocalizedString.java
trunk/common/src/main/org/jboss/portal/common/util/MapResourceBundle.java
trunk/common/src/main/org/jboss/portal/common/util/ParentChildResourceBundle.java
Modified:
trunk/common/src/main/org/jboss/portal/common/i18n/ResourceBundleManager.java
trunk/common/src/main/org/jboss/portal/test/common/DescriptionTestCase.java
trunk/common/src/main/org/jboss/portal/test/common/LocalizedStringTestCase.java
trunk/common/src/main/org/jboss/portal/test/common/ParentChildResourceBundleTestCase.java
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/AdminPropertyResolver.java
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PreferenceBean.java
trunk/core/src/main/org/jboss/portal/core/impl/model/content/generic/GenericContent.java
trunk/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java
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/PortletContent.java
trunk/core/src/main/org/jboss/portal/core/model/content/Content.java
trunk/core/src/main/org/jboss/portal/core/model/content/ContentProvider.java
trunk/core/src/main/org/jboss/portal/test/core/model/content/NullContent.java
trunk/core/src/main/org/jboss/portal/test/core/model/content/NullContentProvider.java
trunk/format/src/main/org/jboss/portal/test/format/BBCodeHTML2HTMLTestCase.java
trunk/identity/src/main/org/jboss/portal/identity/config/info/PropertyInfoSupport.java
trunk/identity/src/main/org/jboss/portal/identity/info/PropertyInfo.java
trunk/portlet-federation/src/main/org/jboss/portal/test/portlet/federation/FederatingPortletInvokerTestCase.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletResourceBundleFactory.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerMetaInfo.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerModeInfo.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerPreferenceInfo.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerPreferencesInfo.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerWindowStateInfo.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/Utils.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/metadata/SecurityRoleRefMetaData.java
trunk/portlet/src/main/org/jboss/portal/portlet/info/MetaInfo.java
trunk/portlet/src/main/org/jboss/portal/portlet/info/ModeInfo.java
trunk/portlet/src/main/org/jboss/portal/portlet/info/PreferenceInfo.java
trunk/portlet/src/main/org/jboss/portal/portlet/info/WindowStateInfo.java
trunk/portlet/src/main/org/jboss/portal/portlet/support/info/MetaInfoSupport.java
trunk/portlet/src/main/org/jboss/portal/portlet/support/info/ModeInfoSupport.java
trunk/portlet/src/main/org/jboss/portal/portlet/support/info/PreferenceInfoSupport.java
trunk/portlet/src/main/org/jboss/portal/portlet/support/info/WindowStateInfoSupport.java
trunk/portlet/src/main/org/jboss/portal/test/portlet/info/MetaInfoTest.java
trunk/portlet/src/main/org/jboss/portal/test/portlet/state/AbstractStatefulPortletInvokerTestCase.java
trunk/widget/src/main/org/jboss/portal/widget/Widget.java
trunk/widget/src/main/org/jboss/portal/widget/google/GGWidget.java
trunk/widget/src/main/org/jboss/portal/widget/google/provider/GGWidgetBuilder.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/ServiceObjectFactory.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPUtils.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/portlet/info/WSRPPortletInfo.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/PortletManagementHandler.java
Log:
moved i18n stuff from common.util to common.i18n package
Copied: trunk/common/src/main/org/jboss/portal/common/i18n/LocalizedPropertyResourceBundle.java (from rev 6816, trunk/common/src/main/org/jboss/portal/common/util/LocalizedPropertyResourceBundle.java)
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/i18n/LocalizedPropertyResourceBundle.java (rev 0)
+++ trunk/common/src/main/org/jboss/portal/common/i18n/LocalizedPropertyResourceBundle.java 2007-03-24 23:13:11 UTC (rev 6818)
@@ -0,0 +1,60 @@
+/******************************************************************************
+ * 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.PropertyResourceBundle;
+import java.util.Locale;
+import java.io.InputStream;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+public class LocalizedPropertyResourceBundle extends PropertyResourceBundle
+{
+
+ private final Locale locale;
+
+ /**
+ * Create an instanceof of localized property resource bundle.
+ *
+ * @param stream the stream to decode the property file
+ * @param locale the locale to use
+ * @throws IllegalArgumentException if the locale is null
+ */
+ public LocalizedPropertyResourceBundle(InputStream stream, Locale locale) throws IOException
+ {
+ super(stream);
+ if (locale == null)
+ {
+ throw new IllegalArgumentException("Locale cannot be null");
+ }
+ this.locale = locale;
+ }
+
+ public Locale getLocale()
+ {
+ return locale;
+ }
+}
Property changes on: trunk/common/src/main/org/jboss/portal/common/i18n/LocalizedPropertyResourceBundle.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/common/src/main/org/jboss/portal/common/i18n/LocalizedString.java (from rev 6816, trunk/common/src/main/org/jboss/portal/common/util/LocalizedString.java)
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/i18n/LocalizedString.java (rev 0)
+++ trunk/common/src/main/org/jboss/portal/common/i18n/LocalizedString.java 2007-03-24 23:13:11 UTC (rev 6818)
@@ -0,0 +1,381 @@
+/******************************************************************************
+ * 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.apache.log4j.Logger;
+import org.jboss.portal.common.util.LocaleInfo;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+
+/**
+ * An immutable localized string.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ */
+public class LocalizedString
+{
+
+ /** The logger. */
+ private static final Logger log = Logger.getLogger(LocalizedString.class);
+
+ /** The descriptions. */
+ private final Map values;
+
+ /** The default locale. */
+ private final Locale defaultLocale;
+
+ /**
+ * Convenience constructor for simple localized strings with only one value using the default locale.
+ *
+ * @param defaultValue the localized value using the specified default locale
+ * @param defaultLocale the default locale
+ * @since 2.4
+ */
+ public LocalizedString(String defaultValue, Locale defaultLocale) throws IllegalArgumentException
+ {
+ if (defaultValue == null)
+ {
+ throw new IllegalArgumentException("No null default value allowed");
+ }
+ if (defaultLocale == null)
+ {
+ throw new IllegalArgumentException("No null default locale allowed");
+ }
+
+ //
+ Map values = new HashMap(3);
+ addValueForLocale(values, defaultLocale, defaultValue);
+
+ //
+ this.defaultLocale = defaultLocale;
+ this.values = Collections.unmodifiableMap(values);
+ }
+
+ public LocalizedString(Locale defaultLocale) throws IllegalArgumentException
+ {
+ if (defaultLocale == null)
+ {
+ throw new IllegalArgumentException("No null default locale allowed");
+ }
+
+ //
+ this.defaultLocale = defaultLocale;
+ this.values = Collections.EMPTY_MAP;
+ }
+
+ public LocalizedString(Map values, Locale defaultLocale) throws IllegalArgumentException
+ {
+ if (values == null)
+ {
+ throw new IllegalArgumentException("No null description map allowed");
+ }
+ if (defaultLocale == null)
+ {
+ throw new IllegalArgumentException("No null default locale allowed");
+ }
+
+ // Convert strings to value
+ Map tmp = new HashMap(values.size());
+ for (Iterator i = values.entrySet().iterator(); i.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry)i.next();
+ Object key = entry.getKey();
+ if (!(key instanceof Locale))
+ {
+ throw new IllegalArgumentException("Key not a locale " + entry.getKey());
+ }
+ Object value = entry.getValue();
+ if (!(value instanceof String))
+ {
+ throw new IllegalArgumentException("Value not a string " + entry.getValue());
+ }
+ addValueForLocale(tmp, (Locale)key, (String)value);
+ }
+
+ //
+ this.defaultLocale = defaultLocale;
+ this.values = Collections.unmodifiableMap(tmp);
+ }
+
+ /**
+ * Adds a new value for the specified locale to this LocalizedString. Note that if a value existed for this Locale,
+ * it will be overwritten.
+ *
+ * @param locale the locale of the value
+ * @param value the value
+ * @since 2.4
+ */
+ private void addValueForLocale(Map values, Locale locale, String value)
+ {
+ values.put(locale, new Value(locale, value));
+ }
+
+ /**
+ * Determines if this LocalizedString contains any values.
+ *
+ * @return <code>true</code> if this LocalizedString contains localized values, <code>false</code> otherwise.
+ * @since 2.4
+ */
+ public boolean hasValues()
+ {
+ return values.isEmpty() == false;
+ }
+
+ /**
+ * Return the string for the default locale.
+ *
+ * @return the string for the default locale
+ */
+ public String getDefaultString()
+ {
+ return getString(defaultLocale, false);
+ }
+
+ /**
+ * Return the value for the default locale.
+ *
+ * @return the value for the default locale
+ */
+ public Value getDefaultValue()
+ {
+ return getValue(defaultLocale, false);
+ }
+
+ /**
+ * Return the string of the localized value of the description.
+ *
+ * @param locale the desired locale for the description
+ * @param resolve true if the locale must be resolved to the most appropriate
+ * @return the description string or null if it is not found when resolving is false
+ */
+ public String getString(Locale locale, boolean resolve)
+ {
+ Value value = getValue(locale, resolve);
+ if (value != null)
+ {
+ return value.getString();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ /**
+ * Return a localized value of the description.
+ *
+ * @param locale the desired locale for the description
+ * @param resolve true if the locale must be resolved to the most appropriate
+ * @return the description value or null if it is not found when resolving is false
+ */
+ public Value getValue(Locale locale, boolean resolve)
+ {
+ if (locale == null)
+ {
+ throw new IllegalArgumentException("No null locale accepted as argument");
+ }
+
+ // fail fast is there aren't any values
+ if (values.isEmpty())
+ {
+ return null;
+ }
+
+ if (resolve)
+ {
+ Value desc = (Value)values.get(locale);
+ if (desc == null && !locale.getVariant().equals(""))
+ {
+ desc = (Value)values.get(new Locale(locale.getLanguage(), locale.getCountry()));
+ }
+ if (desc == null && !locale.getCountry().equals(""))
+ {
+ desc = (Value)values.get(new Locale(locale.getLanguage()));
+ }
+ if (desc == null)
+ {
+ desc = (Value)values.get(defaultLocale);
+ }
+ return desc;
+ }
+ else
+ {
+ return (Value)values.get(locale);
+ }
+ }
+
+ /** Return the default locale of this description. */
+ public Locale getDefaultLocale()
+ {
+ return defaultLocale;
+ }
+
+ /**
+ * Retrieves the localized value most appropriate based on the given desired locales.
+ *
+ * @param desiredLocales an array of compound language tags (as defined by <a href="http://www.ietf.org/rfc/rfc3066.txt">IETF
+ * RFC 3066</a>) ordered according to locale preferences.
+ * @return the most appropriate localized value based on locale preferences.
+ * @throws IllegalArgumentException if the array is null or one of the array string is null or invalid (see
+ * #getLocaleFromRFC3066LanguageTag(String))
+ * @since 2.4
+ */
+ public String getMostAppropriateValueFor(String[] desiredLocales) throws IllegalArgumentException
+ {
+ Value mapping = getPreferredOrBestLocalizedMappingFor(desiredLocales);
+ return (mapping == null) ? null : mapping.getString();
+ }
+
+ /**
+ * Retrieves the Locale-String mapping most appropriate based on the given desired locales, which are ordered
+ * according to locale preferences.
+ *
+ * @param desiredLocales an array of compound language tags (as defined by <a href="http://www.ietf.org/rfc/rfc3066.txt">IETF
+ * RFC 3066</a>) ordered according to locale preferences.
+ * @return a Map.Entry representing the most appropriate mapping between Locale and localized value, based on locale
+ * preferences.
+ * @throws IllegalArgumentException if the array is null or one of the array string is null or invalid (see {@link
+ * org.jboss.portal.common.util.LocaleInfo#decodeLocaleInfoFromRFC3066LanguageTag(String)}
+ * @since 2.4
+ */
+ public Value getPreferredOrBestLocalizedMappingFor(String[] desiredLocales) throws IllegalArgumentException
+ {
+ if (desiredLocales == null)
+ {
+ throw new IllegalArgumentException("No null desired locale array accepted");
+ }
+
+ if (values.isEmpty())
+ {
+ return null;
+ }
+
+ //
+ Value value = null;
+
+ //
+ if (desiredLocales.length > 0)
+ {
+ LocaleInfo info;
+ for (int i = 0; value == null && i < desiredLocales.length; i++)
+ {
+ String desiredLocale = desiredLocales[i];
+ if (desiredLocale == null)
+ {
+ throw new IllegalArgumentException("Null desired locale not accepted");
+ }
+ try
+ {
+ info = LocaleInfo.decodeLocaleInfoFromRFC3066LanguageTag(desiredLocale);
+ Locale locale = info.getLocale();
+ value = getValue(locale, true);
+ }
+ catch (IllegalArgumentException e)
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("Invalid desired locale " + desiredLocale);
+ }
+ }
+ }
+
+ // todo julien
+ // We could have a smarter version of this method but this version requires that desiredLocales
+ // are ordered by locale preference. Hence the first found is by definition the best.
+ }
+
+ //
+ if (value == null)
+ {
+ value = getValue(defaultLocale, true);
+ }
+
+ //
+ return value;
+ }
+
+ /** A localized value. */
+ public static class Value
+ {
+
+ private final Locale locale;
+ private final String string;
+
+ public Value(Locale locale, String string)
+ {
+ if (locale == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.locale = locale;
+ this.string = string;
+ }
+
+ public Locale getLocale()
+ {
+ return locale;
+ }
+
+ public String getString()
+ {
+ return string;
+ }
+ }
+
+ public String toString()
+ {
+ return "LocalizedString: '" + getMostAppropriateValueFor(new String[0]) + "' default: " + getDefaultLocale();
+ }
+
+
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass())
+ {
+ return false;
+ }
+
+ LocalizedString that = (LocalizedString)o;
+
+ return getMostAppropriateValueFor(new String[0]).equals(that.getMostAppropriateValueFor(new String[0]))
+ && defaultLocale.equals(that.defaultLocale);
+ }
+
+ public int hashCode()
+ {
+ int result;
+ result = getMostAppropriateValueFor(new String[0]).hashCode();
+ result = 31 * result + defaultLocale.hashCode();
+ return result;
+ }
+}
Property changes on: trunk/common/src/main/org/jboss/portal/common/i18n/LocalizedString.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/common/src/main/org/jboss/portal/common/i18n/MapResourceBundle.java (from rev 6816, trunk/common/src/main/org/jboss/portal/common/util/MapResourceBundle.java)
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/i18n/MapResourceBundle.java (rev 0)
+++ trunk/common/src/main/org/jboss/portal/common/i18n/MapResourceBundle.java 2007-03-24 23:13:11 UTC (rev 6818)
@@ -0,0 +1,60 @@
+/******************************************************************************
+ * 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.Map;
+import java.util.HashMap;
+import java.util.Enumeration;
+import java.util.Collections;
+
+/**
+ * A resource bundle that use a map as content.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+public class MapResourceBundle extends ResourceBundle
+{
+
+ protected Map content;
+
+ public MapResourceBundle(Map content)
+ {
+ this.content = new HashMap(content);
+ }
+
+ protected Object handleGetObject(String key)
+ {
+ if (key == null)
+ {
+ throw new NullPointerException();
+ }
+ return content.get(key);
+ }
+
+ public Enumeration getKeys()
+ {
+ return Collections.enumeration(content.keySet());
+ }
+}
Property changes on: trunk/common/src/main/org/jboss/portal/common/i18n/MapResourceBundle.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/common/src/main/org/jboss/portal/common/i18n/ParentChildResourceBundle.java (from rev 6816, trunk/common/src/main/org/jboss/portal/common/util/ParentChildResourceBundle.java)
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/i18n/ParentChildResourceBundle.java (rev 0)
+++ trunk/common/src/main/org/jboss/portal/common/i18n/ParentChildResourceBundle.java 2007-03-24 23:13:11 UTC (rev 6818)
@@ -0,0 +1,110 @@
+/******************************************************************************
+ * 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.Enumeration;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import java.util.ResourceBundle;
+
+/**
+ * This resource bundle takes two resource bundle to make one :
+ * - The locale of this resource bundle is given by the child.
+ * - For a given key present in the child and the parent, the child
+ * value overrides the parent value.
+ *
+ * The locale used for the bundle is the child locale.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class ParentChildResourceBundle extends ResourceBundle
+{
+
+ /** The bundle locale. */
+ private Locale locale;
+
+ /** The bundle values. */
+ private Map values;
+
+ /**
+ * Construct a new resource bundle whose content is based on the child
+ * and parent content.
+ *
+ * @param parent the parent eventually null
+ * @param child the child
+ * @throws IllegalArgumentException if the child is null or its locale is null
+ */
+ public ParentChildResourceBundle(ResourceBundle parent, ResourceBundle child) throws IllegalArgumentException
+ {
+ // Arg check
+ if (child == null)
+ {
+ throw new IllegalArgumentException("Child cannot be null");
+ }
+ if (child.getLocale() == null)
+ {
+ throw new IllegalArgumentException("Child locale must not be null");
+ }
+ this.locale = child.getLocale();
+ this.values = new HashMap();
+
+ // Set the parent content
+ if (parent != null)
+ {
+ for (Enumeration e = parent.getKeys();e.hasMoreElements();)
+ {
+ String key = (String)e.nextElement();
+ Object value = parent.getObject(key);
+ values.put(key, value);
+ }
+ }
+
+ // Set the child content
+ for (Enumeration e = child.getKeys();e.hasMoreElements();)
+ {
+ String key = (String)e.nextElement();
+ Object value = child.getObject(key);
+ values.put(key, value);
+ }
+ }
+
+ public Locale getLocale()
+ {
+ return locale;
+ }
+
+ protected Object handleGetObject(String key)
+ {
+ return values.get(key);
+ }
+
+ public Enumeration getKeys()
+ {
+ return Tools.toEnumeration(values.keySet().iterator());
+ }
+}
Property changes on: trunk/common/src/main/org/jboss/portal/common/i18n/ParentChildResourceBundle.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
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-24 22:32:21 UTC (rev 6817)
+++ trunk/common/src/main/org/jboss/portal/common/i18n/ResourceBundleManager.java 2007-03-24 23:13:11 UTC (rev 6818)
@@ -23,7 +23,7 @@
package org.jboss.portal.common.i18n;
import org.apache.log4j.Logger;
-import org.jboss.portal.common.util.LocalizedString;
+import org.jboss.portal.common.i18n.LocalizedString;
import java.util.Map;
import java.util.ResourceBundle;
Deleted: trunk/common/src/main/org/jboss/portal/common/util/LocalizedPropertyResourceBundle.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/util/LocalizedPropertyResourceBundle.java 2007-03-24 22:32:21 UTC (rev 6817)
+++ trunk/common/src/main/org/jboss/portal/common/util/LocalizedPropertyResourceBundle.java 2007-03-24 23:13:11 UTC (rev 6818)
@@ -1,60 +0,0 @@
-/******************************************************************************
- * 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.util;
-
-import java.util.PropertyResourceBundle;
-import java.util.Locale;
-import java.io.InputStream;
-import java.io.IOException;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class LocalizedPropertyResourceBundle extends PropertyResourceBundle
-{
-
- private final Locale locale;
-
- /**
- * Create an instanceof of localized property resource bundle.
- *
- * @param stream the stream to decode the property file
- * @param locale the locale to use
- * @throws IllegalArgumentException if the locale is null
- */
- public LocalizedPropertyResourceBundle(InputStream stream, Locale locale) throws IOException
- {
- super(stream);
- if (locale == null)
- {
- throw new IllegalArgumentException("Locale cannot be null");
- }
- this.locale = locale;
- }
-
- public Locale getLocale()
- {
- return locale;
- }
-}
Deleted: trunk/common/src/main/org/jboss/portal/common/util/LocalizedString.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/util/LocalizedString.java 2007-03-24 22:32:21 UTC (rev 6817)
+++ trunk/common/src/main/org/jboss/portal/common/util/LocalizedString.java 2007-03-24 23:13:11 UTC (rev 6818)
@@ -1,380 +0,0 @@
-/******************************************************************************
- * 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.util;
-
-import org.apache.log4j.Logger;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Locale;
-import java.util.Map;
-
-/**
- * An immutable localized string.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
- * @version $Revision$
- */
-public class LocalizedString
-{
-
- /** The logger. */
- private static final Logger log = Logger.getLogger(LocalizedString.class);
-
- /** The descriptions. */
- private final Map values;
-
- /** The default locale. */
- private final Locale defaultLocale;
-
- /**
- * Convenience constructor for simple localized strings with only one value using the default locale.
- *
- * @param defaultValue the localized value using the specified default locale
- * @param defaultLocale the default locale
- * @since 2.4
- */
- public LocalizedString(String defaultValue, Locale defaultLocale) throws IllegalArgumentException
- {
- if (defaultValue == null)
- {
- throw new IllegalArgumentException("No null default value allowed");
- }
- if (defaultLocale == null)
- {
- throw new IllegalArgumentException("No null default locale allowed");
- }
-
- //
- Map values = new HashMap(3);
- addValueForLocale(values, defaultLocale, defaultValue);
-
- //
- this.defaultLocale = defaultLocale;
- this.values = Collections.unmodifiableMap(values);
- }
-
- public LocalizedString(Locale defaultLocale) throws IllegalArgumentException
- {
- if (defaultLocale == null)
- {
- throw new IllegalArgumentException("No null default locale allowed");
- }
-
- //
- this.defaultLocale = defaultLocale;
- this.values = Collections.EMPTY_MAP;
- }
-
- public LocalizedString(Map values, Locale defaultLocale) throws IllegalArgumentException
- {
- if (values == null)
- {
- throw new IllegalArgumentException("No null description map allowed");
- }
- if (defaultLocale == null)
- {
- throw new IllegalArgumentException("No null default locale allowed");
- }
-
- // Convert strings to value
- Map tmp = new HashMap(values.size());
- for (Iterator i = values.entrySet().iterator(); i.hasNext();)
- {
- Map.Entry entry = (Map.Entry)i.next();
- Object key = entry.getKey();
- if (!(key instanceof Locale))
- {
- throw new IllegalArgumentException("Key not a locale " + entry.getKey());
- }
- Object value = entry.getValue();
- if (!(value instanceof String))
- {
- throw new IllegalArgumentException("Value not a string " + entry.getValue());
- }
- addValueForLocale(tmp, (Locale)key, (String)value);
- }
-
- //
- this.defaultLocale = defaultLocale;
- this.values = Collections.unmodifiableMap(tmp);
- }
-
- /**
- * Adds a new value for the specified locale to this LocalizedString. Note that if a value existed for this Locale,
- * it will be overwritten.
- *
- * @param locale the locale of the value
- * @param value the value
- * @since 2.4
- */
- private void addValueForLocale(Map values, Locale locale, String value)
- {
- values.put(locale, new Value(locale, value));
- }
-
- /**
- * Determines if this LocalizedString contains any values.
- *
- * @return <code>true</code> if this LocalizedString contains localized values, <code>false</code> otherwise.
- * @since 2.4
- */
- public boolean hasValues()
- {
- return values.isEmpty() == false;
- }
-
- /**
- * Return the string for the default locale.
- *
- * @return the string for the default locale
- */
- public String getDefaultString()
- {
- return getString(defaultLocale, false);
- }
-
- /**
- * Return the value for the default locale.
- *
- * @return the value for the default locale
- */
- public Value getDefaultValue()
- {
- return getValue(defaultLocale, false);
- }
-
- /**
- * Return the string of the localized value of the description.
- *
- * @param locale the desired locale for the description
- * @param resolve true if the locale must be resolved to the most appropriate
- * @return the description string or null if it is not found when resolving is false
- */
- public String getString(Locale locale, boolean resolve)
- {
- Value value = getValue(locale, resolve);
- if (value != null)
- {
- return value.getString();
- }
- else
- {
- return null;
- }
- }
-
- /**
- * Return a localized value of the description.
- *
- * @param locale the desired locale for the description
- * @param resolve true if the locale must be resolved to the most appropriate
- * @return the description value or null if it is not found when resolving is false
- */
- public Value getValue(Locale locale, boolean resolve)
- {
- if (locale == null)
- {
- throw new IllegalArgumentException("No null locale accepted as argument");
- }
-
- // fail fast is there aren't any values
- if (values.isEmpty())
- {
- return null;
- }
-
- if (resolve)
- {
- Value desc = (Value)values.get(locale);
- if (desc == null && !locale.getVariant().equals(""))
- {
- desc = (Value)values.get(new Locale(locale.getLanguage(), locale.getCountry()));
- }
- if (desc == null && !locale.getCountry().equals(""))
- {
- desc = (Value)values.get(new Locale(locale.getLanguage()));
- }
- if (desc == null)
- {
- desc = (Value)values.get(defaultLocale);
- }
- return desc;
- }
- else
- {
- return (Value)values.get(locale);
- }
- }
-
- /** Return the default locale of this description. */
- public Locale getDefaultLocale()
- {
- return defaultLocale;
- }
-
- /**
- * Retrieves the localized value most appropriate based on the given desired locales.
- *
- * @param desiredLocales an array of compound language tags (as defined by <a href="http://www.ietf.org/rfc/rfc3066.txt">IETF
- * RFC 3066</a>) ordered according to locale preferences.
- * @return the most appropriate localized value based on locale preferences.
- * @throws IllegalArgumentException if the array is null or one of the array string is null or invalid (see
- * #getLocaleFromRFC3066LanguageTag(String))
- * @since 2.4
- */
- public String getMostAppropriateValueFor(String[] desiredLocales) throws IllegalArgumentException
- {
- Value mapping = getPreferredOrBestLocalizedMappingFor(desiredLocales);
- return (mapping == null) ? null : mapping.getString();
- }
-
- /**
- * Retrieves the Locale-String mapping most appropriate based on the given desired locales, which are ordered
- * according to locale preferences.
- *
- * @param desiredLocales an array of compound language tags (as defined by <a href="http://www.ietf.org/rfc/rfc3066.txt">IETF
- * RFC 3066</a>) ordered according to locale preferences.
- * @return a Map.Entry representing the most appropriate mapping between Locale and localized value, based on locale
- * preferences.
- * @throws IllegalArgumentException if the array is null or one of the array string is null or invalid (see {@link
- * LocaleInfo#decodeLocaleInfoFromRFC3066LanguageTag(String)}
- * @since 2.4
- */
- public Value getPreferredOrBestLocalizedMappingFor(String[] desiredLocales) throws IllegalArgumentException
- {
- if (desiredLocales == null)
- {
- throw new IllegalArgumentException("No null desired locale array accepted");
- }
-
- if (values.isEmpty())
- {
- return null;
- }
-
- //
- Value value = null;
-
- //
- if (desiredLocales.length > 0)
- {
- LocaleInfo info;
- for (int i = 0; value == null && i < desiredLocales.length; i++)
- {
- String desiredLocale = desiredLocales[i];
- if (desiredLocale == null)
- {
- throw new IllegalArgumentException("Null desired locale not accepted");
- }
- try
- {
- info = LocaleInfo.decodeLocaleInfoFromRFC3066LanguageTag(desiredLocale);
- Locale locale = info.getLocale();
- value = getValue(locale, true);
- }
- catch (IllegalArgumentException e)
- {
- if (log.isDebugEnabled())
- {
- log.debug("Invalid desired locale " + desiredLocale);
- }
- }
- }
-
- // todo julien
- // We could have a smarter version of this method but this version requires that desiredLocales
- // are ordered by locale preference. Hence the first found is by definition the best.
- }
-
- //
- if (value == null)
- {
- value = getValue(defaultLocale, true);
- }
-
- //
- return value;
- }
-
- /** A localized value. */
- public static class Value
- {
-
- private final Locale locale;
- private final String string;
-
- public Value(Locale locale, String string)
- {
- if (locale == null)
- {
- throw new IllegalArgumentException();
- }
- this.locale = locale;
- this.string = string;
- }
-
- public Locale getLocale()
- {
- return locale;
- }
-
- public String getString()
- {
- return string;
- }
- }
-
- public String toString()
- {
- return "LocalizedString: '" + getMostAppropriateValueFor(new String[0]) + "' default: " + getDefaultLocale();
- }
-
-
- public boolean equals(Object o)
- {
- if (this == o)
- {
- return true;
- }
- if (o == null || getClass() != o.getClass())
- {
- return false;
- }
-
- LocalizedString that = (LocalizedString)o;
-
- return getMostAppropriateValueFor(new String[0]).equals(that.getMostAppropriateValueFor(new String[0]))
- && defaultLocale.equals(that.defaultLocale);
- }
-
- public int hashCode()
- {
- int result;
- result = getMostAppropriateValueFor(new String[0]).hashCode();
- result = 31 * result + defaultLocale.hashCode();
- return result;
- }
-}
Deleted: trunk/common/src/main/org/jboss/portal/common/util/MapResourceBundle.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/util/MapResourceBundle.java 2007-03-24 22:32:21 UTC (rev 6817)
+++ trunk/common/src/main/org/jboss/portal/common/util/MapResourceBundle.java 2007-03-24 23:13:11 UTC (rev 6818)
@@ -1,60 +0,0 @@
-/******************************************************************************
- * 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.util;
-
-import java.util.ResourceBundle;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Enumeration;
-import java.util.Collections;
-
-/**
- * A resource bundle that use a map as content.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class MapResourceBundle extends ResourceBundle
-{
-
- protected Map content;
-
- public MapResourceBundle(Map content)
- {
- this.content = new HashMap(content);
- }
-
- protected Object handleGetObject(String key)
- {
- if (key == null)
- {
- throw new NullPointerException();
- }
- return content.get(key);
- }
-
- public Enumeration getKeys()
- {
- return Collections.enumeration(content.keySet());
- }
-}
Deleted: trunk/common/src/main/org/jboss/portal/common/util/ParentChildResourceBundle.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/util/ParentChildResourceBundle.java 2007-03-24 22:32:21 UTC (rev 6817)
+++ trunk/common/src/main/org/jboss/portal/common/util/ParentChildResourceBundle.java 2007-03-24 23:13:11 UTC (rev 6818)
@@ -1,108 +0,0 @@
-/******************************************************************************
- * 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.util;
-
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-import java.util.ResourceBundle;
-
-/**
- * This resource bundle takes two resource bundle to make one :
- * - The locale of this resource bundle is given by the child.
- * - For a given key present in the child and the parent, the child
- * value overrides the parent value.
- *
- * The locale used for the bundle is the child locale.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
- * @version $Revision$
- */
-public class ParentChildResourceBundle extends ResourceBundle
-{
-
- /** The bundle locale. */
- private Locale locale;
-
- /** The bundle values. */
- private Map values;
-
- /**
- * Construct a new resource bundle whose content is based on the child
- * and parent content.
- *
- * @param parent the parent eventually null
- * @param child the child
- * @throws IllegalArgumentException if the child is null or its locale is null
- */
- public ParentChildResourceBundle(ResourceBundle parent, ResourceBundle child) throws IllegalArgumentException
- {
- // Arg check
- if (child == null)
- {
- throw new IllegalArgumentException("Child cannot be null");
- }
- if (child.getLocale() == null)
- {
- throw new IllegalArgumentException("Child locale must not be null");
- }
- this.locale = child.getLocale();
- this.values = new HashMap();
-
- // Set the parent content
- if (parent != null)
- {
- for (Enumeration e = parent.getKeys();e.hasMoreElements();)
- {
- String key = (String)e.nextElement();
- Object value = parent.getObject(key);
- values.put(key, value);
- }
- }
-
- // Set the child content
- for (Enumeration e = child.getKeys();e.hasMoreElements();)
- {
- String key = (String)e.nextElement();
- Object value = child.getObject(key);
- values.put(key, value);
- }
- }
-
- public Locale getLocale()
- {
- return locale;
- }
-
- protected Object handleGetObject(String key)
- {
- return values.get(key);
- }
-
- public Enumeration getKeys()
- {
- return Tools.toEnumeration(values.keySet().iterator());
- }
-}
Modified: trunk/common/src/main/org/jboss/portal/test/common/DescriptionTestCase.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/test/common/DescriptionTestCase.java 2007-03-24 22:32:21 UTC (rev 6817)
+++ trunk/common/src/main/org/jboss/portal/test/common/DescriptionTestCase.java 2007-03-24 23:13:11 UTC (rev 6818)
@@ -28,7 +28,7 @@
import java.util.HashMap;
import java.util.Locale;
-import org.jboss.portal.common.util.LocalizedString;
+import org.jboss.portal.common.i18n.LocalizedString;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
Modified: trunk/common/src/main/org/jboss/portal/test/common/LocalizedStringTestCase.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/test/common/LocalizedStringTestCase.java 2007-03-24 22:32:21 UTC (rev 6817)
+++ trunk/common/src/main/org/jboss/portal/test/common/LocalizedStringTestCase.java 2007-03-24 23:13:11 UTC (rev 6818)
@@ -23,7 +23,7 @@
package org.jboss.portal.test.common;
import junit.framework.TestCase;
-import org.jboss.portal.common.util.LocalizedString;
+import org.jboss.portal.common.i18n.LocalizedString;
import java.util.HashMap;
import java.util.Locale;
Modified: trunk/common/src/main/org/jboss/portal/test/common/ParentChildResourceBundleTestCase.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/test/common/ParentChildResourceBundleTestCase.java 2007-03-24 22:32:21 UTC (rev 6817)
+++ trunk/common/src/main/org/jboss/portal/test/common/ParentChildResourceBundleTestCase.java 2007-03-24 23:13:11 UTC (rev 6818)
@@ -32,7 +32,7 @@
import junit.framework.TestCase;
-import org.jboss.portal.common.util.ParentChildResourceBundle;
+import org.jboss.portal.common.i18n.ParentChildResourceBundle;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
Modified: trunk/core/src/main/org/jboss/portal/core/impl/model/content/generic/GenericContent.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/content/generic/GenericContent.java 2007-03-24 22:32:21 UTC (rev 6817)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/content/generic/GenericContent.java 2007-03-24 23:13:11 UTC (rev 6818)
@@ -24,7 +24,7 @@
import org.jboss.portal.core.model.content.spi.ContentState;
import org.jboss.portal.core.impl.model.content.AbstractContent;
-import org.jboss.portal.common.util.LocalizedString;
+import org.jboss.portal.common.i18n.LocalizedString;
import java.util.Locale;
Modified: trunk/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java 2007-03-24 22:32:21 UTC (rev 6817)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java 2007-03-24 23:13:11 UTC (rev 6818)
@@ -38,7 +38,7 @@
import org.jboss.portal.portlet.PortletParametersStateString;
import org.jboss.portal.theme.page.WindowResult;
import org.jboss.portal.Mode;
-import org.jboss.portal.common.util.LocalizedString;
+import org.jboss.portal.common.i18n.LocalizedString;
import java.util.Iterator;
import java.util.Map;
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-24 22:32:21 UTC (rev 6817)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/content/portlet/InternalPortletContentProvider.java 2007-03-24 23:13:11 UTC (rev 6818)
@@ -37,7 +37,7 @@
import org.jboss.portal.core.impl.model.content.InternalContentProvider;
import org.jboss.portal.identity.User;
import org.jboss.portal.Mode;
-import org.jboss.portal.common.util.LocalizedString;
+import org.jboss.portal.common.i18n.LocalizedString;
import java.util.ResourceBundle;
import java.util.Locale;
Modified: trunk/core/src/main/org/jboss/portal/core/impl/model/content/portlet/PortletContent.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/content/portlet/PortletContent.java 2007-03-24 22:32:21 UTC (rev 6817)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/content/portlet/PortletContent.java 2007-03-24 23:13:11 UTC (rev 6818)
@@ -24,7 +24,7 @@
import org.jboss.portal.core.model.content.spi.ContentState;
import org.jboss.portal.core.impl.model.content.AbstractContent;
-import org.jboss.portal.common.util.LocalizedString;
+import org.jboss.portal.common.i18n.LocalizedString;
import java.util.Locale;
Modified: trunk/core/src/main/org/jboss/portal/core/model/content/Content.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/content/Content.java 2007-03-24 22:32:21 UTC (rev 6817)
+++ trunk/core/src/main/org/jboss/portal/core/model/content/Content.java 2007-03-24 23:13:11 UTC (rev 6818)
@@ -22,11 +22,8 @@
******************************************************************************/
package org.jboss.portal.core.model.content;
-import org.jboss.portal.common.util.LocalizedString;
+import org.jboss.portal.common.i18n.LocalizedString;
-import java.util.Map;
-import java.util.Set;
-import java.util.Collection;
import java.util.Iterator;
/**
Modified: trunk/core/src/main/org/jboss/portal/core/model/content/ContentProvider.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/content/ContentProvider.java 2007-03-24 22:32:21 UTC (rev 6817)
+++ trunk/core/src/main/org/jboss/portal/core/model/content/ContentProvider.java 2007-03-24 23:13:11 UTC (rev 6818)
@@ -24,7 +24,7 @@
import org.jboss.portal.core.model.content.spi.handler.ContentHandler;
import org.jboss.portal.core.model.content.spi.portlet.ContentPortlet;
-import org.jboss.portal.common.util.LocalizedString;
+import org.jboss.portal.common.i18n.LocalizedString;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
Modified: trunk/core/src/main/org/jboss/portal/test/core/model/content/NullContent.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/test/core/model/content/NullContent.java 2007-03-24 22:32:21 UTC (rev 6817)
+++ trunk/core/src/main/org/jboss/portal/test/core/model/content/NullContent.java 2007-03-24 23:13:11 UTC (rev 6818)
@@ -24,7 +24,7 @@
import org.jboss.portal.core.model.content.spi.ContentState;
import org.jboss.portal.core.impl.model.content.AbstractContent;
-import org.jboss.portal.common.util.LocalizedString;
+import org.jboss.portal.common.i18n.LocalizedString;
import java.util.Locale;
Modified: trunk/core/src/main/org/jboss/portal/test/core/model/content/NullContentProvider.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/test/core/model/content/NullContentProvider.java 2007-03-24 22:32:21 UTC (rev 6817)
+++ trunk/core/src/main/org/jboss/portal/test/core/model/content/NullContentProvider.java 2007-03-24 23:13:11 UTC (rev 6818)
@@ -26,7 +26,7 @@
import org.jboss.portal.core.model.content.ContentType;
import org.jboss.portal.core.model.content.spi.handler.ContentHandler;
import org.jboss.portal.core.model.content.spi.portlet.ContentPortlet;
-import org.jboss.portal.common.util.LocalizedString;
+import org.jboss.portal.common.i18n.LocalizedString;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
Modified: trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/AdminPropertyResolver.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/AdminPropertyResolver.java 2007-03-24 22:32:21 UTC (rev 6817)
+++ trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/AdminPropertyResolver.java 2007-03-24 23:13:11 UTC (rev 6818)
@@ -29,7 +29,7 @@
import org.jboss.portal.faces.el.DelegatingPropertyResolver;
import org.jboss.portal.identity.RoleModule;
import org.jboss.portal.identity.IdentityException;
-import org.jboss.portal.common.util.LocalizedString;
+import org.jboss.portal.common.i18n.LocalizedString;
import org.jboss.portal.common.util.IteratorStatus;
import org.jboss.portal.common.util.MediaType;
import org.jboss.portal.portlet.Portlet;
Modified: trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PreferenceBean.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PreferenceBean.java 2007-03-24 22:32:21 UTC (rev 6817)
+++ trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PreferenceBean.java 2007-03-24 23:13:11 UTC (rev 6818)
@@ -24,7 +24,7 @@
import org.jboss.portal.common.value.Value;
import org.jboss.portal.common.value.StringValue;
-import org.jboss.portal.common.util.LocalizedString;
+import org.jboss.portal.common.i18n.LocalizedString;
import org.jboss.portal.faces.el.dynamic.DynamicBean;
import org.jboss.portal.faces.el.PropertyValue;
import org.jboss.portal.portlet.info.PreferenceInfo;
Modified: trunk/format/src/main/org/jboss/portal/test/format/BBCodeHTML2HTMLTestCase.java
===================================================================
--- trunk/format/src/main/org/jboss/portal/test/format/BBCodeHTML2HTMLTestCase.java 2007-03-24 22:32:21 UTC (rev 6817)
+++ trunk/format/src/main/org/jboss/portal/test/format/BBCodeHTML2HTMLTestCase.java 2007-03-24 23:13:11 UTC (rev 6818)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.portal.test.format;
-import org.jboss.portal.common.util.MapResourceBundle;
+import org.jboss.portal.common.i18n.MapResourceBundle;
import org.jboss.portal.format.parser.bbcode.BBCodeParser;
import org.jboss.portal.format.render.bbcodehtml.ToHTMLConfig;
import org.jboss.portal.format.render.bbcodehtml.ToHTMLRenderer;
Modified: trunk/identity/src/main/org/jboss/portal/identity/config/info/PropertyInfoSupport.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity/config/info/PropertyInfoSupport.java 2007-03-24 22:32:21 UTC (rev 6817)
+++ trunk/identity/src/main/org/jboss/portal/identity/config/info/PropertyInfoSupport.java 2007-03-24 23:13:11 UTC (rev 6818)
@@ -24,7 +24,7 @@
import org.jboss.portal.identity.info.PropertyInfo;
import org.jboss.portal.identity.config.metadata.profile.PropertyMetaData;
import org.jboss.portal.identity.config.metadata.profile.LocalizedValueMetaData;
-import org.jboss.portal.common.util.LocalizedString;
+import org.jboss.portal.common.i18n.LocalizedString;
import org.jboss.portal.identity.IdentityException;
import org.jboss.logging.Logger;
Modified: trunk/identity/src/main/org/jboss/portal/identity/info/PropertyInfo.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity/info/PropertyInfo.java 2007-03-24 22:32:21 UTC (rev 6817)
+++ trunk/identity/src/main/org/jboss/portal/identity/info/PropertyInfo.java 2007-03-24 23:13:11 UTC (rev 6818)
@@ -21,7 +21,7 @@
*/
package org.jboss.portal.identity.info;
-import org.jboss.portal.common.util.LocalizedString;
+import org.jboss.portal.common.i18n.LocalizedString;
/**
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletResourceBundleFactory.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletResourceBundleFactory.java 2007-03-24 22:32:21 UTC (rev 6817)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletResourceBundleFactory.java 2007-03-24 23:13:11 UTC (rev 6818)
@@ -23,7 +23,7 @@
package org.jboss.portal.portlet.impl.jsr168;
import org.jboss.portal.common.util.EmptyResourceBundle;
-import org.jboss.portal.common.util.ParentChildResourceBundle;
+import org.jboss.portal.common.i18n.ParentChildResourceBundle;
import org.jboss.portal.common.i18n.ResourceBundleManager;
import org.jboss.portal.common.i18n.ResourceBundleFactory;
import org.jboss.portal.portlet.impl.jsr168.metadata.LanguagesMetaData;
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerMetaInfo.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerMetaInfo.java 2007-03-24 22:32:21 UTC (rev 6817)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerMetaInfo.java 2007-03-24 23:13:11 UTC (rev 6818)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.portal.portlet.impl.jsr168.info;
-import org.jboss.portal.common.util.LocalizedString;
+import org.jboss.portal.common.i18n.LocalizedString;
import org.jboss.portal.common.i18n.ResourceBundleManager;
import org.jboss.portal.portlet.impl.jsr168.metadata.PortletMetaData;
import org.jboss.portal.portlet.info.MetaInfo;
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerModeInfo.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerModeInfo.java 2007-03-24 22:32:21 UTC (rev 6817)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerModeInfo.java 2007-03-24 23:13:11 UTC (rev 6818)
@@ -24,7 +24,7 @@
package org.jboss.portal.portlet.impl.jsr168.info;
import org.jboss.portal.Mode;
-import org.jboss.portal.common.util.LocalizedString;
+import org.jboss.portal.common.i18n.LocalizedString;
import org.jboss.portal.portlet.info.ModeInfo;
import java.util.Locale;
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerPreferenceInfo.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerPreferenceInfo.java 2007-03-24 22:32:21 UTC (rev 6817)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerPreferenceInfo.java 2007-03-24 23:13:11 UTC (rev 6818)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.portal.portlet.impl.jsr168.info;
-import org.jboss.portal.common.util.LocalizedString;
+import org.jboss.portal.common.i18n.LocalizedString;
import org.jboss.portal.common.value.Value;
import org.jboss.portal.portlet.info.PreferenceInfo;
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerPreferencesInfo.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerPreferencesInfo.java 2007-03-24 22:32:21 UTC (rev 6817)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerPreferencesInfo.java 2007-03-24 23:13:11 UTC (rev 6818)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.portal.portlet.impl.jsr168.info;
-import org.jboss.portal.common.util.LocalizedString;
+import org.jboss.portal.common.i18n.LocalizedString;
import org.jboss.portal.common.value.StringValue;
import org.jboss.portal.common.value.Value;
import org.jboss.portal.common.i18n.ResourceBundleManager;
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerWindowStateInfo.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerWindowStateInfo.java 2007-03-24 22:32:21 UTC (rev 6817)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerWindowStateInfo.java 2007-03-24 23:13:11 UTC (rev 6818)
@@ -24,7 +24,7 @@
package org.jboss.portal.portlet.impl.jsr168.info;
import org.jboss.portal.WindowState;
-import org.jboss.portal.common.util.LocalizedString;
+import org.jboss.portal.common.i18n.LocalizedString;
import org.jboss.portal.portlet.info.WindowStateInfo;
import java.util.Locale;
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/Utils.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/Utils.java 2007-03-24 22:32:21 UTC (rev 6817)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/Utils.java 2007-03-24 23:13:11 UTC (rev 6818)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.portal.portlet.impl.jsr168.info;
-import org.jboss.portal.common.util.LocalizedString;
+import org.jboss.portal.common.i18n.LocalizedString;
import org.jboss.portal.portlet.impl.jsr168.metadata.LocalizedStringMetaData;
import org.jboss.portal.portlet.impl.jsr168.metadata.LocalizedValueMetaData;
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/metadata/SecurityRoleRefMetaData.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/metadata/SecurityRoleRefMetaData.java 2007-03-24 22:32:21 UTC (rev 6817)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/metadata/SecurityRoleRefMetaData.java 2007-03-24 23:13:11 UTC (rev 6818)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.portal.portlet.impl.jsr168.metadata;
-import org.jboss.portal.common.util.LocalizedString;
+import org.jboss.portal.common.i18n.LocalizedString;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/info/MetaInfo.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/info/MetaInfo.java 2007-03-24 22:32:21 UTC (rev 6817)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/info/MetaInfo.java 2007-03-24 23:13:11 UTC (rev 6818)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.portal.portlet.info;
-import org.jboss.portal.common.util.LocalizedString;
+import org.jboss.portal.common.i18n.LocalizedString;
/**
* Portlet metadata (display-name, title, short title, keywords).
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/info/ModeInfo.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/info/ModeInfo.java 2007-03-24 22:32:21 UTC (rev 6817)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/info/ModeInfo.java 2007-03-24 23:13:11 UTC (rev 6818)
@@ -23,7 +23,7 @@
package org.jboss.portal.portlet.info;
import org.jboss.portal.Mode;
-import org.jboss.portal.common.util.LocalizedString;
+import org.jboss.portal.common.i18n.LocalizedString;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/info/PreferenceInfo.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/info/PreferenceInfo.java 2007-03-24 22:32:21 UTC (rev 6817)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/info/PreferenceInfo.java 2007-03-24 23:13:11 UTC (rev 6818)
@@ -22,8 +22,7 @@
******************************************************************************/
package org.jboss.portal.portlet.info;
-import org.jboss.portal.common.util.LocalizedString;
-import org.jboss.portal.common.value.Value;
+import org.jboss.portal.common.i18n.LocalizedString;
/**
* Describes a Portlet preference.
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/info/WindowStateInfo.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/info/WindowStateInfo.java 2007-03-24 22:32:21 UTC (rev 6817)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/info/WindowStateInfo.java 2007-03-24 23:13:11 UTC (rev 6818)
@@ -23,7 +23,7 @@
package org.jboss.portal.portlet.info;
import org.jboss.portal.WindowState;
-import org.jboss.portal.common.util.LocalizedString;
+import org.jboss.portal.common.i18n.LocalizedString;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/support/info/MetaInfoSupport.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/support/info/MetaInfoSupport.java 2007-03-24 22:32:21 UTC (rev 6817)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/support/info/MetaInfoSupport.java 2007-03-24 23:13:11 UTC (rev 6818)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.portal.portlet.support.info;
-import org.jboss.portal.common.util.LocalizedString;
+import org.jboss.portal.common.i18n.LocalizedString;
import org.jboss.portal.portlet.info.MetaInfo;
import java.util.HashMap;
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/support/info/ModeInfoSupport.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/support/info/ModeInfoSupport.java 2007-03-24 22:32:21 UTC (rev 6817)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/support/info/ModeInfoSupport.java 2007-03-24 23:13:11 UTC (rev 6818)
@@ -23,7 +23,7 @@
package org.jboss.portal.portlet.support.info;
import org.jboss.portal.Mode;
-import org.jboss.portal.common.util.LocalizedString;
+import org.jboss.portal.common.i18n.LocalizedString;
import org.jboss.portal.portlet.info.ModeInfo;
import java.util.Locale;
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/support/info/PreferenceInfoSupport.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/support/info/PreferenceInfoSupport.java 2007-03-24 22:32:21 UTC (rev 6817)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/support/info/PreferenceInfoSupport.java 2007-03-24 23:13:11 UTC (rev 6818)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.portal.portlet.support.info;
-import org.jboss.portal.common.util.LocalizedString;
+import org.jboss.portal.common.i18n.LocalizedString;
import org.jboss.portal.portlet.info.PreferenceInfo;
import java.util.Locale;
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/support/info/WindowStateInfoSupport.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/support/info/WindowStateInfoSupport.java 2007-03-24 22:32:21 UTC (rev 6817)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/support/info/WindowStateInfoSupport.java 2007-03-24 23:13:11 UTC (rev 6818)
@@ -23,7 +23,7 @@
package org.jboss.portal.portlet.support.info;
import org.jboss.portal.WindowState;
-import org.jboss.portal.common.util.LocalizedString;
+import org.jboss.portal.common.i18n.LocalizedString;
import org.jboss.portal.portlet.info.WindowStateInfo;
import java.util.Locale;
Modified: trunk/portlet/src/main/org/jboss/portal/test/portlet/info/MetaInfoTest.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/test/portlet/info/MetaInfoTest.java 2007-03-24 22:32:21 UTC (rev 6817)
+++ trunk/portlet/src/main/org/jboss/portal/test/portlet/info/MetaInfoTest.java 2007-03-24 23:13:11 UTC (rev 6818)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.portal.test.portlet.info;
-import org.jboss.portal.common.util.LocalizedString;
+import org.jboss.portal.common.i18n.LocalizedString;
import org.jboss.portal.portlet.container.PortletContainer;
import org.jboss.portal.portlet.info.MetaInfo;
import org.jboss.portal.portlet.info.PortletInfo;
Modified: trunk/portlet/src/main/org/jboss/portal/test/portlet/state/AbstractStatefulPortletInvokerTestCase.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/test/portlet/state/AbstractStatefulPortletInvokerTestCase.java 2007-03-24 22:32:21 UTC (rev 6817)
+++ trunk/portlet/src/main/org/jboss/portal/test/portlet/state/AbstractStatefulPortletInvokerTestCase.java 2007-03-24 23:13:11 UTC (rev 6818)
@@ -24,7 +24,7 @@
import junit.framework.TestCase;
import org.jboss.portal.common.util.CollectionBuilder;
-import org.jboss.portal.common.util.LocalizedString;
+import org.jboss.portal.common.i18n.LocalizedString;
import org.jboss.portal.common.value.StringValue;
import org.jboss.portal.common.value.Value;
import org.jboss.portal.portlet.InvalidPortletIdException;
Modified: trunk/portlet-federation/src/main/org/jboss/portal/test/portlet/federation/FederatingPortletInvokerTestCase.java
===================================================================
--- trunk/portlet-federation/src/main/org/jboss/portal/test/portlet/federation/FederatingPortletInvokerTestCase.java 2007-03-24 22:32:21 UTC (rev 6817)
+++ trunk/portlet-federation/src/main/org/jboss/portal/test/portlet/federation/FederatingPortletInvokerTestCase.java 2007-03-24 23:13:11 UTC (rev 6818)
@@ -34,7 +34,7 @@
import org.jboss.portal.portlet.info.PortletInfo;
import org.jboss.portal.portlet.info.MetaInfo;
import org.jboss.portal.portlet.support.info.PortletInfoSupport;
-import org.jboss.portal.common.util.LocalizedString;
+import org.jboss.portal.common.i18n.LocalizedString;
import java.util.Collection;
import java.util.Set;
Modified: trunk/widget/src/main/org/jboss/portal/widget/Widget.java
===================================================================
--- trunk/widget/src/main/org/jboss/portal/widget/Widget.java 2007-03-24 22:32:21 UTC (rev 6817)
+++ trunk/widget/src/main/org/jboss/portal/widget/Widget.java 2007-03-24 23:13:11 UTC (rev 6818)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.portal.widget;
-import org.jboss.portal.common.util.LocalizedString;
+import org.jboss.portal.common.i18n.LocalizedString;
import java.util.Map;
Modified: trunk/widget/src/main/org/jboss/portal/widget/google/GGWidget.java
===================================================================
--- trunk/widget/src/main/org/jboss/portal/widget/google/GGWidget.java 2007-03-24 22:32:21 UTC (rev 6817)
+++ trunk/widget/src/main/org/jboss/portal/widget/google/GGWidget.java 2007-03-24 23:13:11 UTC (rev 6818)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.portal.widget.google;
-import org.jboss.portal.common.util.LocalizedString;
+import org.jboss.portal.common.i18n.LocalizedString;
import org.jboss.portal.common.util.UUIDGenerator;
import org.jboss.portal.common.text.FastURLEncoder;
import org.jboss.portal.widget.Widget;
Modified: trunk/widget/src/main/org/jboss/portal/widget/google/provider/GGWidgetBuilder.java
===================================================================
--- trunk/widget/src/main/org/jboss/portal/widget/google/provider/GGWidgetBuilder.java 2007-03-24 22:32:21 UTC (rev 6817)
+++ trunk/widget/src/main/org/jboss/portal/widget/google/provider/GGWidgetBuilder.java 2007-03-24 23:13:11 UTC (rev 6818)
@@ -23,7 +23,7 @@
package org.jboss.portal.widget.google.provider;
import org.jboss.portal.common.util.XML;
-import org.jboss.portal.common.util.LocalizedString;
+import org.jboss.portal.common.i18n.LocalizedString;
import org.jboss.portal.common.util.URLTools;
import org.jboss.portal.common.concurrent.loader.ObjectLoader;
import org.jboss.portal.widget.google.type.DataType;
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/ServiceObjectFactory.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/ServiceObjectFactory.java 2007-03-24 22:32:21 UTC (rev 6817)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/ServiceObjectFactory.java 2007-03-24 23:13:11 UTC (rev 6818)
@@ -55,7 +55,7 @@
}
/** Produces String from LocalizedString */
- public static String extractString(org.jboss.portal.common.util.LocalizedString ls)
+ public static String extractString(org.jboss.portal.common.i18n.LocalizedString ls)
{
return ls.getPreferredOrBestLocalizedMappingFor(new String[]{"en"}).getString();
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPUtils.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPUtils.java 2007-03-24 22:32:21 UTC (rev 6817)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPUtils.java 2007-03-24 23:13:11 UTC (rev 6818)
@@ -370,7 +370,7 @@
* <code>null</code> if no such value can be found.
* @since 2.6
*/
- public static org.jboss.portal.wsrp.core.LocalizedString convertToWSRPLocalizedString(org.jboss.portal.common.util.LocalizedString localizedString,
+ public static org.jboss.portal.wsrp.core.LocalizedString convertToWSRPLocalizedString(org.jboss.portal.common.i18n.LocalizedString localizedString,
String[] desiredLocales)
{
if (localizedString == null)
@@ -383,7 +383,7 @@
desiredLocales = new String[]{LocaleInfo.getRFC3066LanguageTagFor(Locale.getDefault())};
}
- org.jboss.portal.common.util.LocalizedString.Value bestMapping = localizedString.getPreferredOrBestLocalizedMappingFor(desiredLocales);
+ org.jboss.portal.common.i18n.LocalizedString.Value bestMapping = localizedString.getPreferredOrBestLocalizedMappingFor(desiredLocales);
if (bestMapping != null)
{
Locale locale = bestMapping.getLocale();
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/portlet/info/WSRPPortletInfo.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/portlet/info/WSRPPortletInfo.java 2007-03-24 22:32:21 UTC (rev 6817)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/portlet/info/WSRPPortletInfo.java 2007-03-24 23:13:11 UTC (rev 6818)
@@ -304,19 +304,19 @@
}
}
- metaInfos.put(MetaInfo.KEYWORDS, new org.jboss.portal.common.util.LocalizedString(keywordsString, locale));
+ metaInfos.put(MetaInfo.KEYWORDS, new org.jboss.portal.common.i18n.LocalizedString(keywordsString, locale));
metaInfo = new WSRPMetaInfo(metaInfos);
}
- private org.jboss.portal.common.util.LocalizedString createPortalLocalizedStringFrom(LocalizedString wsrpLocalizedString)
+ private org.jboss.portal.common.i18n.LocalizedString createPortalLocalizedStringFrom(LocalizedString wsrpLocalizedString)
{
if (wsrpLocalizedString == null)
{
- return new org.jboss.portal.common.util.LocalizedString(Locale.ENGLISH);
+ return new org.jboss.portal.common.i18n.LocalizedString(Locale.ENGLISH);
}
- return new org.jboss.portal.common.util.LocalizedString(wsrpLocalizedString.getValue(),
+ return new org.jboss.portal.common.i18n.LocalizedString(wsrpLocalizedString.getValue(),
LocaleInfo.decodeLocaleInfoFromRFC3066LanguageTag(wsrpLocalizedString.getLang()).getLocale());
}
@@ -372,9 +372,9 @@
this.state = state;
}
- public org.jboss.portal.common.util.LocalizedString getDescription()
+ public org.jboss.portal.common.i18n.LocalizedString getDescription()
{
- return new org.jboss.portal.common.util.LocalizedString(getWindowStateName() + " window state", Locale.ENGLISH);
+ return new org.jboss.portal.common.i18n.LocalizedString(getWindowStateName() + " window state", Locale.ENGLISH);
}
public WindowState getWindowState()
@@ -397,9 +397,9 @@
this.mode = mode;
}
- public org.jboss.portal.common.util.LocalizedString getDescription()
+ public org.jboss.portal.common.i18n.LocalizedString getDescription()
{
- return new org.jboss.portal.common.util.LocalizedString(getModeName() + " mode", Locale.ENGLISH);
+ return new org.jboss.portal.common.i18n.LocalizedString(getModeName() + " mode", Locale.ENGLISH);
}
public Mode getMode()
@@ -491,9 +491,9 @@
this.metaInfos = metaInfos;
}
- public org.jboss.portal.common.util.LocalizedString getMetaValue(String key)
+ public org.jboss.portal.common.i18n.LocalizedString getMetaValue(String key)
{
- return (org.jboss.portal.common.util.LocalizedString)metaInfos.get(key);
+ return (org.jboss.portal.common.i18n.LocalizedString)metaInfos.get(key);
}
}
@@ -520,10 +520,10 @@
static class WSRPPreferenceInfo implements PreferenceInfo
{
private String key;
- private org.jboss.portal.common.util.LocalizedString displayName;
- private org.jboss.portal.common.util.LocalizedString description;
+ private org.jboss.portal.common.i18n.LocalizedString displayName;
+ private org.jboss.portal.common.i18n.LocalizedString description;
- public WSRPPreferenceInfo(String key, org.jboss.portal.common.util.LocalizedString displayName, org.jboss.portal.common.util.LocalizedString description)
+ public WSRPPreferenceInfo(String key, org.jboss.portal.common.i18n.LocalizedString displayName, org.jboss.portal.common.i18n.LocalizedString description)
{
this.key = key;
this.displayName = displayName;
@@ -535,12 +535,12 @@
return key;
}
- public org.jboss.portal.common.util.LocalizedString getDisplayName()
+ public org.jboss.portal.common.i18n.LocalizedString getDisplayName()
{
return displayName;
}
- public org.jboss.portal.common.util.LocalizedString getDescription()
+ public org.jboss.portal.common.i18n.LocalizedString getDescription()
{
return description;
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/PortletManagementHandler.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/PortletManagementHandler.java 2007-03-24 22:32:21 UTC (rev 6817)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/PortletManagementHandler.java 2007-03-24 23:13:11 UTC (rev 6818)
@@ -25,7 +25,7 @@
import org.jboss.logging.Logger;
import org.jboss.portal.common.util.LocaleInfo;
-import org.jboss.portal.common.util.LocalizedString;
+import org.jboss.portal.common.i18n.LocalizedString;
import org.jboss.portal.common.util.Tools;
import org.jboss.portal.common.value.StringValue;
import org.jboss.portal.common.value.Value;
17 years, 3 months
JBoss Portal SVN: r6817 - in trunk: common/src/main/org/jboss/portal/common/i18n and 6 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-03-24 18:32:21 -0400 (Sat, 24 Mar 2007)
New Revision: 6817
Added:
trunk/common/src/main/org/jboss/portal/common/i18n/
trunk/common/src/main/org/jboss/portal/common/i18n/ResourceBundleFactory.java
trunk/common/src/main/org/jboss/portal/common/i18n/ResourceBundleManager.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletResourceBundleFactory.java
Removed:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/PortletResourceBundleManager.java
Modified:
trunk/common/src/main/org/jboss/portal/common/util/EmptyResourceBundle.java
trunk/core/src/main/org/jboss/portal/core/impl/model/content/portlet/InternalPortletContentProvider.java
trunk/core/src/main/org/jboss/portal/test/core/I18nELTestCase.java
trunk/core/src/main/org/jboss/portal/test/core/I18nOutELTestCase.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletContainerImpl.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletConfigImpl.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerCapabilities.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerMetaInfo.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerPortletInfo.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerPreferencesInfo.java
Log:
extracted ResourceBundleManager in common package from portlet module
Added: trunk/common/src/main/org/jboss/portal/common/i18n/ResourceBundleFactory.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/i18n/ResourceBundleFactory.java (rev 0)
+++ trunk/common/src/main/org/jboss/portal/common/i18n/ResourceBundleFactory.java 2007-03-24 22:32:21 UTC (rev 6817)
@@ -0,0 +1,42 @@
+/******************************************************************************
+ * 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;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface ResourceBundleFactory
+{
+ /**
+ * Returns a resource bundle for the specified locale, it may be an expensive operation.
+ *
+ * @param locale the locale for the resource bundle
+ * @return a resource bundle for the locale or null if no such bundle can be obtained
+ * @throws IllegalArgumentException if the locale is null
+ */
+ ResourceBundle getBundle(Locale locale) throws IllegalArgumentException;
+}
Added: trunk/common/src/main/org/jboss/portal/common/i18n/ResourceBundleManager.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/i18n/ResourceBundleManager.java (rev 0)
+++ trunk/common/src/main/org/jboss/portal/common/i18n/ResourceBundleManager.java 2007-03-24 22:32:21 UTC (rev 6817)
@@ -0,0 +1,152 @@
+/******************************************************************************
+ * 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.apache.log4j.Logger;
+import org.jboss.portal.common.util.LocalizedString;
+
+import java.util.Map;
+import java.util.ResourceBundle;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.MissingResourceException;
+
+/**
+ * Manage a set of resource bundles.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision: 6697 $
+ */
+public class ResourceBundleManager
+{
+
+ /** */
+ private Logger log = Logger.getLogger(getClass());
+
+ /** */
+ private volatile Map localeBundles;
+
+ /** */
+ private ResourceBundle defaultBundle;
+
+ /** */
+ private ResourceBundleFactory resourceBundleFactory;
+
+ public ResourceBundleManager(ResourceBundle defaultBundle, ResourceBundleFactory resourceBundleFactory)
+ {
+ this.localeBundles = new HashMap();
+ this.defaultBundle = defaultBundle;
+ this.resourceBundleFactory = resourceBundleFactory;
+ }
+
+ /**
+ * Return a localized value constructed from the various resource bundles. The supported locales of the manager are
+ * used in combination with the specified key. The default value is used if no value is found for the
+ * <code>Locale.ENGLISH</code>.
+ *
+ * @param key the key to lookup in the bundles
+ * @param defaultValue the default value
+ * @return the localized string
+ * @throws IllegalArgumentException if the key of the default value is null
+ */
+ public LocalizedString getLocalizedValue(String key, String defaultValue) throws IllegalArgumentException
+ {
+ if (key == null)
+ {
+ throw new IllegalArgumentException("No null key accepted");
+ }
+ if (defaultValue == null)
+ {
+ throw new IllegalArgumentException("No null default value accepted");
+ }
+ Map m = new HashMap();
+ for (Iterator j = localeBundles.entrySet().iterator(); j.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry)j.next();
+ try
+ {
+ Locale locale = (Locale)entry.getKey();
+ ResourceBundle bundle = (ResourceBundle)entry.getValue();
+ String localizedDisplayName = bundle.getString(key);
+ m.put(locale, localizedDisplayName);
+ }
+ catch (MissingResourceException ignore)
+ {
+ }
+ }
+ if (!m.containsKey(Locale.ENGLISH))
+ {
+ m.put(Locale.ENGLISH, defaultValue);
+ }
+ return new LocalizedString(m, Locale.ENGLISH);
+ }
+
+ /**
+ * Return a bundle for the given locale. If the complete locale (language + country + variant) does not exist then it
+ * falls back to (language + country) or (language) or the default file.
+ * <p/>
+ * When the resource bundle object is found and was not in the global map, it put it in that map with a copy on
+ * write.
+ *
+ * @throws IllegalArgumentException if the locale is null
+ */
+ public ResourceBundle getResourceBundle(Locale locale) throws IllegalArgumentException
+ {
+ // Arg check
+ if (locale == null)
+ {
+ throw new IllegalArgumentException("Locale cannot be null");
+ }
+
+ // Try to get the bundle if the map
+ ResourceBundle bundle = (ResourceBundle)localeBundles.get(locale);
+ if (bundle != null)
+ {
+ return bundle;
+ }
+
+ //
+ log.debug("Want to load bundle for locale " + locale);
+ bundle = resourceBundleFactory.getBundle(locale);
+
+ //
+ if (bundle != null)
+ {
+ log.debug("Obtained bundle " + bundle + " for locale " + locale);
+ }
+ else
+ {
+ log.debug("No bundle obtained for locale " + locale + " will use default bundle " + defaultBundle + "instead");
+ }
+
+ // Cache the bundle
+ Map copy = new HashMap(localeBundles);
+ copy.put(locale, bundle);
+ localeBundles = copy;
+
+ //
+ return bundle;
+ }
+}
Modified: trunk/common/src/main/org/jboss/portal/common/util/EmptyResourceBundle.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/util/EmptyResourceBundle.java 2007-03-24 10:27:17 UTC (rev 6816)
+++ trunk/common/src/main/org/jboss/portal/common/util/EmptyResourceBundle.java 2007-03-24 22:32:21 UTC (rev 6817)
@@ -31,6 +31,10 @@
*/
public class EmptyResourceBundle extends ResourceBundle
{
+
+ /** . */
+ public static final EmptyResourceBundle INSTANCE = new EmptyResourceBundle();
+
protected Object handleGetObject(String key)
{
if (key == null)
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-24 10:27:17 UTC (rev 6816)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/content/portlet/InternalPortletContentProvider.java 2007-03-24 22:32:21 UTC (rev 6817)
@@ -39,6 +39,9 @@
import org.jboss.portal.Mode;
import org.jboss.portal.common.util.LocalizedString;
+import java.util.ResourceBundle;
+import java.util.Locale;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
@@ -52,6 +55,15 @@
/** . */
private CustomizationManager customizationManager;
+ /** . */
+ private ResourceBundle bundle;
+
+ /** . */
+ private LocalizedString displayName;
+
+ /** . */
+ private LocalizedString description;
+
public InstanceContainer getInstanceContainer()
{
return instanceContainer;
@@ -72,6 +84,25 @@
this.customizationManager = customizationManager;
}
+ public void start() throws Exception
+ {
+ bundle = ResourceBundle.getBundle("conf/bundles/PortletContent", Locale.ENGLISH, Thread.currentThread().getContextClassLoader());
+
+ // displayName = new LocalizedString();
+
+ //
+ super.start();
+ }
+
+
+ public void stop()
+ {
+ super.stop();
+
+ //
+ bundle = null;
+ }
+
protected ContentProvider createProvider()
{
return new ContentProvider()
Modified: trunk/core/src/main/org/jboss/portal/test/core/I18nELTestCase.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/test/core/I18nELTestCase.java 2007-03-24 10:27:17 UTC (rev 6816)
+++ trunk/core/src/main/org/jboss/portal/test/core/I18nELTestCase.java 2007-03-24 22:32:21 UTC (rev 6817)
@@ -25,7 +25,7 @@
import org.apache.cactus.JspTestCase;
import org.jboss.portal.core.servlet.jsp.PortalJsp;
import org.jboss.portal.core.servlet.jsp.taglib.PortalLib;
-import org.jboss.portal.portlet.impl.jsr168.info.PortletResourceBundleManager;
+import org.jboss.portal.portlet.impl.jsr168.PortletResourceBundleFactory;
import org.jboss.portal.portlet.impl.jsr168.api.PortletConfigImpl;
import org.jboss.portal.portlet.impl.jsr168.metadata.LanguagesMetaData;
@@ -69,10 +69,10 @@
languagesMD.setResourceBundle(RESOURCE_BUNDLE_NAME);
// Build the bundle
- PortletResourceBundleManager rbs = new PortletResourceBundleManager(loader, languagesMD);
+ PortletResourceBundleFactory rbs = new PortletResourceBundleFactory(loader, languagesMD);
- PortletConfig portletConfig = new PortletConfigImpl("testPortlet", null, null, rbs);
- request.setAttribute("javax.portlet.config", portletConfig);
+// PortletConfig portletConfig = new PortletConfigImpl("testPortlet", null, null, rbs);
+// request.setAttribute("javax.portlet.config", portletConfig);
HttpServletRequestWrapperImpl requestWrapper = new HttpServletRequestWrapperImpl(request);
requestWrapper.setLocale(Locale.FRENCH);
Modified: trunk/core/src/main/org/jboss/portal/test/core/I18nOutELTestCase.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/test/core/I18nOutELTestCase.java 2007-03-24 10:27:17 UTC (rev 6816)
+++ trunk/core/src/main/org/jboss/portal/test/core/I18nOutELTestCase.java 2007-03-24 22:32:21 UTC (rev 6817)
@@ -27,11 +27,9 @@
import org.jboss.portal.core.servlet.jsp.taglib.PortalLib;
import org.jboss.portal.core.servlet.jsp.taglib.context.Context;
import org.jboss.portal.core.servlet.jsp.taglib.context.DelegateContext;
-import org.jboss.portal.portlet.impl.jsr168.info.PortletResourceBundleManager;
-import org.jboss.portal.portlet.impl.jsr168.api.PortletConfigImpl;
+import org.jboss.portal.portlet.impl.jsr168.PortletResourceBundleFactory;
import org.jboss.portal.portlet.impl.jsr168.metadata.LanguagesMetaData;
-import javax.portlet.PortletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -71,10 +69,10 @@
languagesMD.setResourceBundle(RESOURCE_BUNDLE_NAME);
// Build the bundle
- PortletResourceBundleManager rbs = new PortletResourceBundleManager(loader, languagesMD);
+ PortletResourceBundleFactory rbs = new PortletResourceBundleFactory(loader, languagesMD);
- PortletConfig portletConfig = new PortletConfigImpl("testPortlet", null, null, rbs);
- request.setAttribute("javax.portlet.config", portletConfig);
+// PortletConfig portletConfig = new PortletConfigImpl("testPortlet", null, null, rbs);
+// request.setAttribute("javax.portlet.config", portletConfig);
HttpServletRequestWrapperImpl requestWrapper = new HttpServletRequestWrapperImpl(request);
requestWrapper.setLocale(Locale.FRENCH);
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletContainerImpl.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletContainerImpl.java 2007-03-24 10:27:17 UTC (rev 6816)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletContainerImpl.java 2007-03-24 22:32:21 UTC (rev 6817)
@@ -28,7 +28,7 @@
import org.jboss.portal.portlet.impl.jsr168.api.RenderResponseImpl;
import org.jboss.portal.portlet.impl.jsr168.api.RenderRequestImpl;
import org.jboss.portal.portlet.impl.jsr168.api.ActionRequestImpl;
-import org.jboss.portal.portlet.impl.jsr168.info.PortletResourceBundleManager;
+import org.jboss.portal.portlet.impl.jsr168.PortletResourceBundleFactory;
import org.jboss.portal.portlet.container.PortletInitializationException;
import org.jboss.portal.portlet.container.PortletApplication;
import org.jboss.portal.portlet.container.PortletContainer;
@@ -51,6 +51,7 @@
import org.jboss.portal.portlet.aspects.portlet.ContextDispatcherInterceptor;
import org.jboss.portal.common.concurrent.Valve;
import org.jboss.portal.common.invocation.InvocationException;
+import org.jboss.portal.common.i18n.ResourceBundleManager;
import javax.portlet.PortletConfig;
import javax.portlet.Portlet;
@@ -98,7 +99,7 @@
protected ContentTypes contentTypes;
/** . */
- protected PortletResourceBundleManager bundleMgr;
+ protected ResourceBundleManager bundleMgr;
/** The invocation valve. */
protected final Valve valve;
@@ -211,7 +212,7 @@
}
// Portlet config object
- PortletResourceBundleManager bundleMgr = new PortletResourceBundleManager(application.getContext().getClassLoader(), metaData.getLanguages());
+ ResourceBundleManager bundleMgr = PortletResourceBundleFactory.createResourceBundleManager(application.getContext().getClassLoader(), metaData.getLanguages());
//
PortletConfig config = new PortletConfigImpl(
Copied: trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletResourceBundleFactory.java (from rev 6805, trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/PortletResourceBundleManager.java)
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletResourceBundleFactory.java (rev 0)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletResourceBundleFactory.java 2007-03-24 22:32:21 UTC (rev 6817)
@@ -0,0 +1,145 @@
+/******************************************************************************
+ * 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.portlet.impl.jsr168;
+
+import org.jboss.portal.common.util.EmptyResourceBundle;
+import org.jboss.portal.common.util.ParentChildResourceBundle;
+import org.jboss.portal.common.i18n.ResourceBundleManager;
+import org.jboss.portal.common.i18n.ResourceBundleFactory;
+import org.jboss.portal.portlet.impl.jsr168.metadata.LanguagesMetaData;
+import org.jboss.portal.portlet.impl.jsr168.info.InfoBundle;
+
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ * Manage resource bundles for a portlet.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class PortletResourceBundleFactory implements ResourceBundleFactory
+{
+
+ public static ResourceBundleManager createResourceBundleManager(ClassLoader classLoader, LanguagesMetaData metaData)
+ {
+ if (classLoader == null)
+ {
+ throw new IllegalArgumentException("Need a non null classloader");
+ }
+ if (metaData == null)
+ {
+ throw new IllegalArgumentException("Need non null meta data");
+ }
+
+ // Create factory
+ PortletResourceBundleFactory factory = new PortletResourceBundleFactory(classLoader, metaData);
+
+ // Create manager
+ ResourceBundleManager manager = new ResourceBundleManager(EmptyResourceBundle.INSTANCE, factory);
+
+ // Preload declared locales
+ for (Iterator i = metaData.getSupportedLocales().iterator();i.hasNext();)
+ {
+ Locale locale = (Locale)i.next();
+ manager.getResourceBundle(locale);
+ }
+
+ //
+ return manager;
+ }
+
+ /** The class loader to load resource bundle from. */
+ private final ClassLoader classLoader;
+
+ /** The base name of the resource bundle. */
+ private final String baseName;
+
+ /** */
+ private ResourceBundle infoBundle;
+
+ public PortletResourceBundleFactory(ClassLoader classLoader, LanguagesMetaData metaData)
+ {
+ if (classLoader == null)
+ {
+ throw new IllegalArgumentException("Need a non null classloader");
+ }
+ if (metaData == null)
+ {
+ throw new IllegalArgumentException("Need non null meta data");
+ }
+ this.classLoader = classLoader;
+ this.baseName = metaData.getResourceBundle();
+
+ // Get the resource bundle containing the portlet info
+ LanguagesMetaData.InfoMetaData infoMD = metaData.getInfo();
+ if (infoMD != null)
+ {
+ infoBundle = new InfoBundle(infoMD);
+ }
+ else
+ {
+ infoBundle = EmptyResourceBundle.INSTANCE;
+ }
+ }
+
+ public ResourceBundle getBundle(Locale locale)
+ {
+ if (locale == null)
+ {
+ throw new IllegalArgumentException("Locale cannot be null");
+ }
+
+ //
+ ResourceBundle bundle;
+
+ //
+ if (baseName == null)
+ {
+ bundle = infoBundle;
+ }
+ else
+ {
+ try
+ {
+ bundle = ResourceBundle.getBundle(baseName, locale, classLoader);
+ if (infoBundle != null)
+ {
+ bundle = new ParentChildResourceBundle(infoBundle, bundle);
+ }
+ // log.debug("Created bundle " + baseName + " for locale " + locale);
+ }
+ catch (MissingResourceException e)
+ {
+ // log.warn("Bundle " + baseName + " for locale " + locale + " not found");
+ bundle = infoBundle;
+ }
+ }
+
+ //
+ return bundle;
+ }
+}
Property changes on: trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletResourceBundleFactory.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletConfigImpl.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletConfigImpl.java 2007-03-24 10:27:17 UTC (rev 6816)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletConfigImpl.java 2007-03-24 22:32:21 UTC (rev 6817)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.portal.portlet.impl.jsr168.api;
-import org.jboss.portal.portlet.impl.jsr168.info.PortletResourceBundleManager;
+import org.jboss.portal.common.i18n.ResourceBundleManager;
import javax.portlet.PortletConfig;
import javax.portlet.PortletContext;
@@ -42,12 +42,12 @@
private String portletName;
private PortletContext portletContext;
private Map initParameters;
- private PortletResourceBundleManager bundleMgr;
+ private ResourceBundleManager bundleMgr;
public PortletConfigImpl(String portletName,
PortletContext portletContext,
Map initParameters,
- PortletResourceBundleManager bundleMgr)
+ ResourceBundleManager bundleMgr)
{
this.portletName = portletName;
this.portletContext = portletContext;
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerCapabilities.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerCapabilities.java 2007-03-24 10:27:17 UTC (rev 6816)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerCapabilities.java 2007-03-24 22:32:21 UTC (rev 6817)
@@ -24,6 +24,7 @@
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
+import org.jboss.portal.common.i18n.ResourceBundleManager;
import org.jboss.portal.portlet.info.CapabilitiesInfo;
import java.util.Collections;
@@ -50,9 +51,9 @@
private Set supportedLocales;
private ContentTypes contentTypes;
- private PortletResourceBundleManager bundleMgr;
+ private ResourceBundleManager bundleMgr;
- public ContainerCapabilities(Set supportedLocales, PortletResourceBundleManager bundleMgr, ContentTypes contentTypes)
+ public ContainerCapabilities(Set supportedLocales, ResourceBundleManager bundleMgr, ContentTypes contentTypes)
{
this.supportedLocales = supportedLocales;
this.contentTypes = contentTypes;
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerMetaInfo.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerMetaInfo.java 2007-03-24 10:27:17 UTC (rev 6816)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerMetaInfo.java 2007-03-24 22:32:21 UTC (rev 6817)
@@ -23,6 +23,7 @@
package org.jboss.portal.portlet.impl.jsr168.info;
import org.jboss.portal.common.util.LocalizedString;
+import org.jboss.portal.common.i18n.ResourceBundleManager;
import org.jboss.portal.portlet.impl.jsr168.metadata.PortletMetaData;
import org.jboss.portal.portlet.info.MetaInfo;
@@ -47,7 +48,7 @@
private static final String[] KEYS = {TITLE, SHORT_TITLE, KEYWORDS};
private static final String[] BUNDLE_KEYS = {JAVAX_PORTLET + TITLE, JAVAX_PORTLET + SHORT_TITLE, JAVAX_PORTLET + KEYWORDS};
- public ContainerMetaInfo(PortletMetaData metadata, PortletResourceBundleManager rb)
+ public ContainerMetaInfo(PortletMetaData metadata, ResourceBundleManager rb)
{
this.values = new HashMap();
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerPortletInfo.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerPortletInfo.java 2007-03-24 10:27:17 UTC (rev 6816)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerPortletInfo.java 2007-03-24 22:32:21 UTC (rev 6817)
@@ -35,6 +35,7 @@
import org.jboss.portal.portlet.info.SessionInfo;
import org.jboss.portal.portlet.metadata.JBossApplicationMetaData;
import org.jboss.portal.portlet.metadata.JBossPortletMetaData;
+import org.jboss.portal.common.i18n.ResourceBundleManager;
import java.util.HashSet;
import java.util.Locale;
@@ -60,7 +61,7 @@
public ContainerPortletInfo(
PortletContainerImpl container,
- PortletResourceBundleManager bundleMgr,
+ ResourceBundleManager bundleMgr,
ContentTypes contentTypes)
{
PortletMetaData portletMD = container.getMetaData();
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerPreferencesInfo.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerPreferencesInfo.java 2007-03-24 10:27:17 UTC (rev 6816)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerPreferencesInfo.java 2007-03-24 22:32:21 UTC (rev 6817)
@@ -25,6 +25,7 @@
import org.jboss.portal.common.util.LocalizedString;
import org.jboss.portal.common.value.StringValue;
import org.jboss.portal.common.value.Value;
+import org.jboss.portal.common.i18n.ResourceBundleManager;
import org.jboss.portal.portlet.impl.jsr168.metadata.PortletMetaData;
import org.jboss.portal.portlet.impl.jsr168.metadata.PreferenceMetaData;
import org.jboss.portal.portlet.info.PreferenceInfo;
@@ -52,7 +53,7 @@
content = new HashMap();
}
- public ContainerPreferencesInfo(PortletMetaData portletMD, PortletResourceBundleManager bundleMgr)
+ public ContainerPreferencesInfo(PortletMetaData portletMD, ResourceBundleManager bundleMgr)
{
content = new HashMap();
Deleted: trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/PortletResourceBundleManager.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/PortletResourceBundleManager.java 2007-03-24 10:27:17 UTC (rev 6816)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/PortletResourceBundleManager.java 2007-03-24 22:32:21 UTC (rev 6817)
@@ -1,194 +0,0 @@
-/******************************************************************************
- * 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.portlet.impl.jsr168.info;
-
-import org.apache.log4j.Logger;
-import org.jboss.portal.common.util.EmptyResourceBundle;
-import org.jboss.portal.common.util.LocalizedString;
-import org.jboss.portal.common.util.ParentChildResourceBundle;
-import org.jboss.portal.portlet.impl.jsr168.metadata.LanguagesMetaData;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Locale;
-import java.util.Map;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-/**
- * Manage resource bundles for a portlet.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
- * @version $Revision$
- */
-public class PortletResourceBundleManager
-{
-
- private Logger log = Logger.getLogger(PortletResourceBundleManager.class);
-
- /** */
- private Map localeBundles;
-
- /** */
- private String baseName;
-
- /** */
- private ClassLoader classLoader;
-
- /** */
- private ResourceBundle infoBundle;
-
- /** */
- private Collection supportedLocales;
-
- public PortletResourceBundleManager(ClassLoader classLoader, LanguagesMetaData metaData)
- {
- if (classLoader == null)
- {
- throw new IllegalArgumentException("Need a non null classloader");
- }
- if (metaData == null)
- {
- throw new IllegalArgumentException("Need non null meta data");
- }
- this.classLoader = classLoader;
- this.baseName = metaData.getResourceBundle();
- this.localeBundles = new HashMap();
- this.supportedLocales = metaData.getSupportedLocales();
-
- // Get the resource bundle containing the portlet info
- LanguagesMetaData.InfoMetaData infoMD = metaData.getInfo();
- if (infoMD != null)
- {
- infoBundle = new InfoBundle(infoMD);
- }
- else
- {
- infoBundle = new EmptyResourceBundle();
- }
- }
-
- /**
- * Return a localized value constructed from the various resource bundles. The supported locales of the manager are
- * used in combination with the specified key. The default value is used if no value is found for the
- * <code>Locale.ENGLISH</code>.
- *
- * @param key the key to lookup in the bundles
- * @param defaultValue
- * @return the localized string
- * @throws IllegalArgumentException if the key of the default value is null
- */
- public LocalizedString getLocalizedValue(String key, String defaultValue) throws IllegalArgumentException
- {
- if (key == null)
- {
- throw new IllegalArgumentException("No null key accepted");
- }
- if (defaultValue == null)
- {
- throw new IllegalArgumentException("No null default value accepted");
- }
- Map m = new HashMap();
- for (Iterator j = supportedLocales.iterator(); j.hasNext();)
- {
- try
- {
- Locale locale = (Locale)j.next();
- ResourceBundle bundle = getResourceBundle(locale);
- String localizedDisplayName = bundle.getString(key);
- m.put(locale, localizedDisplayName);
- }
- catch (MissingResourceException ignore)
- {
- }
- }
- if (!m.containsKey(Locale.ENGLISH))
- {
- m.put(Locale.ENGLISH, defaultValue);
- }
- return new LocalizedString(m, Locale.ENGLISH);
- }
-
- /**
- * Return a bundle for the given locale. If the complete locale (language + country + variant) does not exist then it
- * falls back to (language + country) or (language) or the default file.
- * <p/>
- * When the resource bundle object is found and was not in the global map, it put it in that map with a copy on
- * write.
- *
- * @throws IllegalArgumentException if the locale is null
- */
- public ResourceBundle getResourceBundle(Locale locale) throws IllegalArgumentException
- {
- // Arg check
- if (locale == null)
- {
- throw new IllegalArgumentException("Locale cannot be null");
- }
-
- // Try to get the bundle if the map
- ResourceBundle bundle = (ResourceBundle)localeBundles.get(locale);
- if (bundle != null)
- {
- return bundle;
- }
-
- //
- log.debug("Want to load bundle " + baseName + " for locale " + locale);
-
- if (baseName == null)
- {
- bundle = infoBundle;
- }
- else
- {
- try
- {
- bundle = ResourceBundle.getBundle(baseName, locale, classLoader);
- if (infoBundle != null)
- {
- bundle = new ParentChildResourceBundle(infoBundle, bundle);
- }
- log.debug("Created bundle " + baseName + " for locale " + locale);
- }
- catch (MissingResourceException e)
- {
- log.warn("Bundle " + baseName + " for locale " + locale + " not found");
- bundle = infoBundle;
- }
- }
-
- // Cache the bundle
- if (bundle != null)
- {
- Map copy = new HashMap(localeBundles);
- copy.put(locale, bundle);
- localeBundles = copy;
- }
-
- //
- return bundle;
- }
-}
17 years, 3 months
JBoss Portal SVN: r6816 - trunk/core/src/main/org/jboss/portal/test/core/model/content.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-03-24 06:27:17 -0400 (Sat, 24 Mar 2007)
New Revision: 6816
Added:
trunk/core/src/main/org/jboss/portal/test/core/model/content/NullContentProvider.java
Log:
added NullContentProvider
Added: trunk/core/src/main/org/jboss/portal/test/core/model/content/NullContentProvider.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/test/core/model/content/NullContentProvider.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/test/core/model/content/NullContentProvider.java 2007-03-24 10:27:17 UTC (rev 6816)
@@ -0,0 +1,74 @@
+/******************************************************************************
+ * 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.core.model.content;
+
+import org.jboss.portal.core.model.content.ContentProvider;
+import org.jboss.portal.core.model.content.ContentType;
+import org.jboss.portal.core.model.content.spi.handler.ContentHandler;
+import org.jboss.portal.core.model.content.spi.portlet.ContentPortlet;
+import org.jboss.portal.common.util.LocalizedString;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class NullContentProvider implements ContentProvider
+{
+
+ /** . */
+ private final ContentType contentType;
+
+ /** . */
+ private final NullContentHandler handler;
+
+ public NullContentProvider(ContentType contentType)
+ {
+ this.contentType = contentType;
+ this.handler = new NullContentHandler();
+ }
+
+ public ContentType getContentType()
+ {
+ return contentType;
+ }
+
+ public LocalizedString getDisplayName()
+ {
+ return null;
+ }
+
+ public LocalizedString getDescription()
+ {
+ return null;
+ }
+
+ public ContentHandler getHandler()
+ {
+ return handler;
+ }
+
+ public ContentPortlet getPortletInfo()
+ {
+ return null;
+ }
+}
17 years, 3 months