forrest-svn mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thors...@apache.org
Subject svn commit: r672757 - /forrest/trunk/main/java/org/apache/forrest/locationmap/LocationMapModule.java
Date Mon, 30 Jun 2008 13:09:41 GMT
Author: thorsten
Date: Mon Jun 30 06:09:41 2008
New Revision: 672757

URL: http://svn.apache.org/viewvc?rev=672757&view=rev
Log:
Enhancing lookup of locations. If cached result has null location we will try to resolve it
again.

Modified:
    forrest/trunk/main/java/org/apache/forrest/locationmap/LocationMapModule.java

Modified: forrest/trunk/main/java/org/apache/forrest/locationmap/LocationMapModule.java
URL: http://svn.apache.org/viewvc/forrest/trunk/main/java/org/apache/forrest/locationmap/LocationMapModule.java?rev=672757&r1=672756&r2=672757&view=diff
==============================================================================
--- forrest/trunk/main/java/org/apache/forrest/locationmap/LocationMapModule.java (original)
+++ forrest/trunk/main/java/org/apache/forrest/locationmap/LocationMapModule.java Mon Jun
30 06:09:41 2008
@@ -208,23 +208,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) {
@@ -243,6 +238,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.



Mime
View raw message