Author: thorsten
Date: Tue Jul  1 00:15:07 2008
New Revision: 673012

URL: http://svn.apache.org/viewvc?rev=673012&view=rev
Log:
FIXME: FOR-1082 we added synchronized because of problems with Concurrency. 
Adding note and applying fix to the cocoon-2.2 block as well.

Modified:
    
forrest/trunk/whiteboard/cocoon-2.2-blocks/locationmap/src/main/java/org/apache/forrest/locationmap/LocationMapModule.java

Modified: 
forrest/trunk/whiteboard/cocoon-2.2-blocks/locationmap/src/main/java/org/apache/forrest/locationmap/LocationMapModule.java
URL: 
http://svn.apache.org/viewvc/forrest/trunk/whiteboard/cocoon-2.2-blocks/locationmap/src/main/java/org/apache/forrest/locationmap/LocationMapModule.java?rev=673012&r1=673011&r2=673012&view=diff
==============================================================================
--- 
forrest/trunk/whiteboard/cocoon-2.2-blocks/locationmap/src/main/java/org/apache/forrest/locationmap/LocationMapModule.java
 (original)
+++ 
forrest/trunk/whiteboard/cocoon-2.2-blocks/locationmap/src/main/java/org/apache/forrest/locationmap/LocationMapModule.java
 Tue Jul  1 00:15:07 2008
@@ -44,6 +44,23 @@
 
 /**
  * Resolves a request against a LocationMap.
+ * <p>
+ * The locationmap module works as any other [EMAIL PROTECTED] InputModule}.
+ * It acts as a location resolver where you can configure a series
+ * of fallbacks.
+ * <p>
+ * It can be seen as a reduced sitemap with the only concern of 
+ * resolving locations strings to the final location.
+ * <p> 
+ * This module is configured via a sitemap similar DSL which looks
+ * something like:
+ * &lt;locationmap&gt;<br>
+ *  &lt;components/&gt;<br>
+ *  &lt;locator/&gt;<br>
+ *  &lt;/locationmap&gt;<br>
+ *  <p>
+ *  You can use the same actions and selectors like you can use 
+ *  in any othe sitemap.
  */
 public class LocationMapModule extends AbstractLogEnabled
     implements InputModule, Serviceable, Configurable, Disposable, ThreadSafe {
@@ -167,7 +184,10 @@
      * Execute the current request against the locationmap returning the
      * resulting string.
      */
-    public Object getAttribute(
+    /* FIXME: FOR-1082 we added synchronized because of problems
+     * with Concurrency.
+     */
+    public synchronized Object getAttribute(
         final String name,
         final Configuration modeConf,
         final Map objectModel)
@@ -191,23 +211,18 @@
                 }
                   
                        hasBeenCached = m_locationsCache.containsKey(name);
-                       if (hasBeenCached == true) {
+                       if (hasBeenCached == true && 
m_locationsCache.get(name)!=null) {
                                result =  m_locationsCache.get(name);
                                if (getLogger().isDebugEnabled()) {
                                        getLogger().debug("Locationmap cached 
location returned for hint: " + name + " value: " + result);
                                }
-                       }
+                       }else{
+                    result = getFreshResult(name, objectModel);
+                  }
                }
                
                if (hasBeenCached == false) {
-                       result = getLocationMap().locate(name,objectModel);
-                       
-                       if (m_cacheAll == true) {
-                               m_locationsCache.put(name,result);
-                               if (getLogger().isDebugEnabled()) {
-                                       getLogger().debug("Locationmap caching 
hint: " + name + " value: " + result);
-                               }
-                       }
+                       result = getFreshResult(name, objectModel);
                }
           
           if (result == null) {
@@ -226,6 +241,20 @@
         return null;
     }
 
+    private Object getFreshResult(final String name, final Map objectModel)
+        throws Exception {
+      Object result;
+      result = getLocationMap().locate(name,objectModel);
+      
+      if (m_cacheAll == true) {
+       m_locationsCache.put(name,result);
+       if (getLogger().isDebugEnabled()) {
+               getLogger().debug("Locationmap caching hint: " + name + " 
value: " + result);
+       }
+      }
+      return result;
+    }
+
     /**
      * The possibilities are endless. No way to enumerate them all.
      * Therefore returns null.