portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From woon...@apache.org
Subject svn commit: r1093950 - /portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/decoration/AbstractDecoratorActionsFactory.java
Date Sat, 16 Apr 2011 08:37:27 GMT
Author: woonsan
Date: Sat Apr 16 08:37:27 2011
New Revision: 1093950

URL: http://svn.apache.org/viewvc?rev=1093950&view=rev
Log:
JS2-1249: checking if the cached bundle in threadlocal is the same as the current requestContext
locale.

Modified:
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/decoration/AbstractDecoratorActionsFactory.java

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/decoration/AbstractDecoratorActionsFactory.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/decoration/AbstractDecoratorActionsFactory.java?rev=1093950&r1=1093949&r2=1093950&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/decoration/AbstractDecoratorActionsFactory.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/decoration/AbstractDecoratorActionsFactory.java
Sat Apr 16 08:37:27 2011
@@ -20,23 +20,25 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Locale;
+import java.util.Map;
 import java.util.ResourceBundle;
 
 import javax.portlet.PortletMode;
 import javax.portlet.WindowState;
 
 import org.apache.jetspeed.JetspeedActions;
+import org.apache.jetspeed.container.PortletWindow;
 import org.apache.jetspeed.container.url.PortalURL;
 import org.apache.jetspeed.om.page.ContentFragment;
 import org.apache.jetspeed.om.portlet.PortletApplication;
 import org.apache.jetspeed.om.portlet.PortletDefinition;
 import org.apache.jetspeed.request.RequestContext;
 import org.apache.jetspeed.security.SecurityAccessController;
-import org.apache.jetspeed.container.PortletWindow;
 
 public abstract class AbstractDecoratorActionsFactory implements DecoratorActionsFactory
 {
-    private static ThreadLocal actionResourcesMap = new ThreadLocal();
+    private static ThreadLocal<Map<String, Object>> actionResourcesMap = new
ThreadLocal<Map<String, Object>>();
     private boolean editMaximizesOption = false;
     private boolean configMaximizesOption = false;
     private boolean editDefaultsMaximizesOption = false;
@@ -166,13 +168,25 @@ public abstract class AbstractDecoratorA
                 || (template.getState() != null && !template.getState().equals(
                         template.getCustomState()));
 
-        HashMap resourcesMap = (HashMap)actionResourcesMap.get();
         ResourceBundle bundle = DecoratorAction.getResourceBundle(rc.getLocale());
+        Map<String, Object> resourcesMap = actionResourcesMap.get();
+        
+        // It seems better to not use threadLocal variable or to have an abstraction, but
+        // let's just check if the current cache in the thread has the same locale for now.
+        if (resourcesMap != null)
+        {
+            ResourceBundle cachedBundle = (ResourceBundle) resourcesMap.get(DecoratorAction.RESOURCE_BUNDLE);
+            if (!bundle.getLocale().equals(cachedBundle.getLocale())) 
+            {
+                resourcesMap = null;
+            }
+        }
+        
         String localizedName = null;
         
         if (resourcesMap == null)
         {
-            resourcesMap = new HashMap();
+            resourcesMap = new HashMap<String, Object>();
             actionResourcesMap.set(resourcesMap);
             resourcesMap.put(DecoratorAction.RESOURCE_BUNDLE, bundle);
             localizedName = DecoratorAction.getResourceString(bundle, actionName, actionName);



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message