forrest-svn mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From twilli...@apache.org
Subject svn commit: r331289 - in /forrest/trunk/main: java/org/apache/forrest/locationmap/LocationMapModule.java webapp/WEB-INF/xconf/forrest-core.xconf
Date Mon, 07 Nov 2005 16:01:41 GMT
Author: twilliams
Date: Mon Nov  7 08:01:23 2005
New Revision: 331289

URL: http://svn.apache.org/viewcvs?rev=331289&view=rev
Log:
First cut at FOR-711 


Modified:
    forrest/trunk/main/java/org/apache/forrest/locationmap/LocationMapModule.java
    forrest/trunk/main/webapp/WEB-INF/xconf/forrest-core.xconf

Modified: forrest/trunk/main/java/org/apache/forrest/locationmap/LocationMapModule.java
URL: http://svn.apache.org/viewcvs/forrest/trunk/main/java/org/apache/forrest/locationmap/LocationMapModule.java?rev=331289&r1=331288&r2=331289&view=diff
==============================================================================
--- forrest/trunk/main/java/org/apache/forrest/locationmap/LocationMapModule.java (original)
+++ forrest/trunk/main/java/org/apache/forrest/locationmap/LocationMapModule.java Mon Nov
 7 08:01:23 2005
@@ -20,6 +20,7 @@
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.Map;
+import java.util.HashMap;
 
 import org.apache.forrest.locationmap.lm.LocationMap;
 import org.apache.avalon.framework.activity.Disposable;
@@ -53,6 +54,8 @@
     private String m_src;
     private SourceValidity m_srcVal;
     private LocationMap m_lm;
+    private boolean m_cacheAll;
+    private Map m_locationsCache;
 
     // ---------------------------------------------------- lifecycle
 
@@ -66,10 +69,16 @@
 
     public void configure(Configuration configuration) throws ConfigurationException {
         m_src = configuration.getChild("file").getAttribute("src");
+        m_cacheAll = configuration.getChild("cacheable").getValueAsBoolean(true);
+        
+        if (m_cacheAll == true) {
+        	m_locationsCache = new HashMap();
+        }
     }
 
     public void dispose() {
         m_lm.dispose();
+        m_locationsCache = null;
     }
 
     private LocationMap getLocationMap() throws Exception {
@@ -153,9 +162,32 @@
         final Configuration modeConf,
         final Map objectModel)
         throws ConfigurationException {
-
+    	
+    	Object result = null;
+    	boolean hasBeenCached = false;
+    	
         try {
-            return getLocationMap().locate(name,objectModel);
+        	if (this.m_cacheAll == true) {
+        		hasBeenCached = m_locationsCache.containsKey(name);
+        		if (hasBeenCached == true) {
+        			result =  m_locationsCache.get(name);
+        			if (getLogger().isDebugEnabled()) {
+        				getLogger().debug("Locationmap cached location returned for hint: " + name);
+        			}
+        		}
+        	}
+        	
+        	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);
+        			}
+        		}
+        	}
+        	return result;
         }
         catch (ConfigurationException e) {
             throw e;

Modified: forrest/trunk/main/webapp/WEB-INF/xconf/forrest-core.xconf
URL: http://svn.apache.org/viewcvs/forrest/trunk/main/webapp/WEB-INF/xconf/forrest-core.xconf?rev=331289&r1=331288&r2=331289&view=diff
==============================================================================
--- forrest/trunk/main/webapp/WEB-INF/xconf/forrest-core.xconf (original)
+++ forrest/trunk/main/webapp/WEB-INF/xconf/forrest-core.xconf Mon Nov  7 08:01:23 2005
@@ -219,6 +219,7 @@
       class="org.apache.forrest.locationmap.LocationMapModule" 
       logger="core.modules.mapper.lm" name="lm">
       <file src="cocoon://locationmap.xml"/>
+      <cacheable>true</cacheable>
     </component-instance>
 
 </input-modules>



Mime
View raw message