You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by so...@apache.org on 2012/01/18 21:22:27 UTC
svn commit: r1233041 - in /myfaces/trinidad/branches/1.2.12.5.0-branch:
trinidad-api/src/main/java/org/apache/myfaces/trinidad/menu/MenuUtils.java
trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/menu/MenuUtils.java
Author: sobryan
Date: Wed Jan 18 20:22:27 2012
New Revision: 1233041
URL: http://svn.apache.org/viewvc?rev=1233041&view=rev
Log:
TRINIDAD-2196
Modified:
myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/menu/MenuUtils.java
myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/menu/MenuUtils.java
Modified: myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/menu/MenuUtils.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/menu/MenuUtils.java?rev=1233041&r1=1233040&r2=1233041&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/menu/MenuUtils.java (original)
+++ myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/menu/MenuUtils.java Wed Jan 18 20:22:27 2012
@@ -33,7 +33,6 @@ import javax.faces.context.FacesContext;
import org.apache.myfaces.trinidad.logging.TrinidadLogger;
import org.apache.myfaces.trinidad.util.ContainerUtils;
-import org.apache.myfaces.trinidad.util.ThreadLocalUtils;
/**
* Menu Utilities used by the Menu Model internal code.
@@ -203,18 +202,17 @@ public class MenuUtils
}
/**
- * Create a ResourceBundle and put it on the Session map.
- *
- * @param resBundle - String containing name of class containing the resource
- * bundle.
- * @param key - ThreadLocal key for the resource bundle being put on the
- * requestMap
+ * Create a ResourceBundle and put it in an EL-reachable scope.
+ *
+ * @param resBundleName - String containing name of class containing the
+ * resource bundle.
+ * @param resBundleKey - String key for the resource bundle
*/
@SuppressWarnings("unchecked")
- static void loadBundle(String resBundle, ThreadLocal<String> key)
+ static public void loadBundle(String resBundleName, String resBundleKey)
{
FacesContext facesContext = FacesContext.getCurrentInstance();
- Map<String, Object> applicationMap =
+ Map<String, Object> applicationMap =
facesContext.getExternalContext().getApplicationMap();
// Get the view root locale
@@ -225,22 +223,22 @@ public class MenuUtils
{
requestLocale = facesContext.getApplication().getDefaultLocale();
}
-
+
// Is there a bundle with this key already on the session map?
- _BundleMap bundleMap = (_BundleMap) applicationMap.get(key.get());
-
- // if so, get its locale. If the locale has not
+ _BundleMap bundleMap = (_BundleMap) applicationMap.get(resBundleKey);
+
+ // if so, get its locale. If the locale has not
// changed, just return, i.e. use the existing bundle
if (bundleMap != null)
{
Locale bundleLocale = bundleMap.getLocale();
-
+
if (bundleLocale == null)
{
ResourceBundle rb = bundleMap.getBundle();
bundleLocale = rb.getLocale();
}
-
+
if (requestLocale == bundleLocale)
{
// the bundle on the applicationMap is ok so just return
@@ -250,21 +248,21 @@ public class MenuUtils
String bundleName = null;
- if (resBundle != null)
+ if (resBundleName != null)
{
// if _bundleName is an EL, then get its value
- if (ContainerUtils.isValueReference(resBundle))
+ if (ContainerUtils.isValueReference(resBundleName))
{
- bundleName = MenuUtils.getBoundValue(resBundle, String.class);
- }
+ bundleName = MenuUtils.getBoundValue(resBundleName, String.class);
+ }
else
{
- bundleName = resBundle ;
+ bundleName = resBundleName ;
}
}
final ResourceBundle bundle;
-
+
try
{
bundle = ResourceBundle.getBundle(bundleName, requestLocale);
@@ -275,30 +273,11 @@ public class MenuUtils
_LOG.severe(e);
return;
}
-
- // Put the bundle in the map. At this point the key is
+
+ // Put the bundle in the map. At this point the key is
// unique because of the handler Id we inserted when loadBundle
// was called.
- applicationMap.put(key.get(), new _BundleMap(bundle, requestLocale));
- }
-
- /**
- * Create a ResourceBundle and put it on the Session map.
- * The key is made into a ThreadLocal to ensure that this the resource
- * bundle is threadsafe.
- *
- * @param resBundleName - String containing name of class containing the
- * resource bundle.
- * @param resBundleKey - String key for the resource bundle being put on the
- * requestMap
- */
- @SuppressWarnings("unchecked")
- static public void loadBundle(String resBundleName, String resBundleKey)
- {
- ThreadLocal<String> bundleKey = ThreadLocalUtils.newRequestThreadLocal();
-
- bundleKey.set(resBundleKey);
- loadBundle(resBundleName, bundleKey);
+ applicationMap.put(resBundleKey, new _BundleMap(bundle, requestLocale));
}
/**
Modified: myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/menu/MenuUtils.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/menu/MenuUtils.java?rev=1233041&r1=1233040&r2=1233041&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/menu/MenuUtils.java (original)
+++ myfaces/trinidad/branches/1.2.12.5.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/menu/MenuUtils.java Wed Jan 18 20:22:27 2012
@@ -201,20 +201,19 @@ class MenuUtils
}
return Integer.parseInt(propVal);
}
-
+
/**
- * Create a ResourceBundle and put it on the Session map.
- *
- * @param resBundle - String containing name of class containing the resource
- * bundle.
- * @param key - ThreadLocal key for the resource bundle being put on the
- * requestMap
+ * Create a ResourceBundle and put it an EL-reachable scope.
+ *
+ * @param resBundleName - String containing name of class containing the
+ * resource bundle.
+ * @param resBundleKey - String key for the resource bundle\
*/
@SuppressWarnings("unchecked")
- static void loadBundle(String resBundle, ThreadLocal<String> key)
+ static void loadBundle(String resBundleName, String resBundleKey)
{
FacesContext facesContext = FacesContext.getCurrentInstance();
- Map<String, Object> applicationMap =
+ Map<String, Object> applicationMap =
facesContext.getExternalContext().getApplicationMap();
// Get the view root locale
@@ -225,22 +224,22 @@ class MenuUtils
{
requestLocale = facesContext.getApplication().getDefaultLocale();
}
-
+
// Is there a bundle with this key already on the session map?
- _BundleMap bundleMap = (_BundleMap) applicationMap.get(key.get());
-
- // if so, get its locale. If the locale has not
+ _BundleMap bundleMap = (_BundleMap) applicationMap.get(resBundleKey);
+
+ // if so, get its locale. If the locale has not
// changed, just return, i.e. use the existing bundle
if (bundleMap != null)
{
Locale bundleLocale = bundleMap.getLocale();
-
+
if (bundleLocale == null)
{
ResourceBundle rb = bundleMap.getBundle();
bundleLocale = rb.getLocale();
}
-
+
if (requestLocale == bundleLocale)
{
// the bundle on the applicationMap is ok so just return
@@ -250,21 +249,21 @@ class MenuUtils
String bundleName = null;
- if (resBundle != null)
+ if (resBundleName != null)
{
// if _bundleName is an EL, then get its value
- if (ContainerUtils.isValueReference(resBundle))
+ if (ContainerUtils.isValueReference(resBundleName))
{
- bundleName = MenuUtils.getBoundValue(resBundle, String.class);
- }
+ bundleName = MenuUtils.getBoundValue(resBundleName, String.class);
+ }
else
{
- bundleName = resBundle ;
+ bundleName = resBundleName ;
}
}
final ResourceBundle bundle;
-
+
try
{
bundle = ResourceBundle.getBundle(bundleName, requestLocale);
@@ -275,30 +274,11 @@ class MenuUtils
_LOG.severe(e);
return;
}
-
- // Put the bundle in the map. At this point the key is
+
+ // Put the bundle in the map. At this point the key is
// unique because of the handler Id we inserted when loadBundle
// was called.
- applicationMap.put(key.get(), new _BundleMap(bundle, requestLocale));
- }
-
- /**
- * Create a ResourceBundle and put it on the Session map.
- * The key is made into a ThreadLocal to ensure that this the resource
- * bundle is threadsafe.
- *
- * @param resBundleName - String containing name of class containing the
- * resource bundle.
- * @param resBundleKey - String key for the resource bundle being put on the
- * requestMap
- */
- @SuppressWarnings("unchecked")
- static void loadBundle(String resBundleName, String resBundleKey)
- {
- ThreadLocal<String> bundleKey = ThreadLocalUtils.newRequestThreadLocal();
-
- bundleKey.set(resBundleKey);
- loadBundle(resBundleName, bundleKey);
+ applicationMap.put(resBundleKey, new _BundleMap(bundle, requestLocale));
}
/**