Author: mrdon
Date: Sat Feb 16 04:32:12 2008
New Revision: 628283

URL: http://svn.apache.org/viewvc?rev=628283&view=rev
Log:
Added ability to configure strong level 1 cache for Freemarker
WW-2189

Modified:
    
struts/struts2/trunk/core/src/main/java/org/apache/struts2/StrutsConstants.java
    
struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerManager.java
    
struts/struts2/trunk/core/src/main/resources/org/apache/struts2/default.properties

Modified: 
struts/struts2/trunk/core/src/main/java/org/apache/struts2/StrutsConstants.java
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/StrutsConstants.java?rev=628283&r1=628282&r2=628283&view=diff
==============================================================================
--- 
struts/struts2/trunk/core/src/main/java/org/apache/struts2/StrutsConstants.java 
(original)
+++ 
struts/struts2/trunk/core/src/main/java/org/apache/struts2/StrutsConstants.java 
Sat Feb 16 04:32:12 2008
@@ -83,7 +83,10 @@
     
     /** Cache model instances at BeanWrapper level */
     public static final String STRUTS_FREEMARKER_BEANWRAPPER_CACHE = 
"struts.freemarker.beanwrapperCache";
-
+    
+    /** Maximum strong sizing for MruCacheStorage for freemarker */
+    public static final String STRUTS_FREEMARKER_MRU_MAX_STRONG_SIZE = 
"struts.freemarker.mru.max.strong.size";
+    
     /** org.apache.struts2.views.velocity.VelocityManager implementation class 
*/
     public static final String STRUTS_VELOCITY_MANAGER_CLASSNAME = 
"struts.velocity.manager.classname";
 
@@ -171,10 +174,10 @@
     /** The [EMAIL PROTECTED] com.opensymphony.xwork2.util.ValueStackFactory} 
implementation class */
     public static final String STRUTS_VALUESTACKFACTORY = 
"struts.valueStackFactory";
 
-    /** The [EMAIL PROTECTED] 
com.opensymphony.xwork2.reflection.ReflectionProvider} implementation class */
+    /** The [EMAIL PROTECTED] 
com.opensymphony.xwork2.util.reflection.ReflectionProvider} implementation 
class */
     public static final String STRUTS_REFLECTIONPROVIDER = 
"struts.reflectionProvider";
 
-    /** The [EMAIL PROTECTED] 
com.opensymphony.xwork2.reflection.ReflectionContextFactory} implementation 
class */
+    /** The [EMAIL PROTECTED] 
com.opensymphony.xwork2.util.reflection.ReflectionContextFactory} 
implementation class */
     public static final String STRUTS_REFLECTIONCONTEXTFACTORY = 
"struts.reflectionContextFactory";
     
     /** The [EMAIL PROTECTED] com.opensymphony.xwork2.util.PatternMatcher} 
implementation class */

Modified: 
struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerManager.java
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerManager.java?rev=628283&r1=628282&r2=628283&view=diff
==============================================================================
--- 
struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerManager.java
 (original)
+++ 
struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerManager.java
 Sat Feb 16 04:32:12 2008
@@ -121,6 +121,7 @@
     private String encoding;
     private boolean altMapWrapper;
     private boolean cacheBeanWrapper;
+    private int mruMaxStrongSize;
     private Map<String,TagLibrary> tagLibraries;
     
     @Inject(StrutsConstants.STRUTS_I18N_ENCODING)
@@ -138,6 +139,11 @@
         cacheBeanWrapper = "true".equals(val);
     }
     
+    @Inject(StrutsConstants.STRUTS_FREEMARKER_MRU_MAX_STRONG_SIZE)
+    public void setMruMaxStrongSize(String size) {
+        mruMaxStrongSize = Integer.parseInt(size);
+    }
+    
     @Inject
     public void setContainer(Container container) {
         Map<String,TagLibrary> map = new HashMap<String,TagLibrary>();
@@ -305,6 +311,10 @@
         
configuration.setTemplateExceptionHandler(TemplateExceptionHandler.HTML_DEBUG_HANDLER);
 
         configuration.setObjectWrapper(getObjectWrapper());
+        
+        if( mruMaxStrongSize > 0 ) {
+            
configuration.setSetting(freemarker.template.Configuration.CACHE_STORAGE_KEY, 
"strong:" + mruMaxStrongSize);
+        }
 
         if (encoding != null) {
             configuration.setDefaultEncoding(encoding);

Modified: 
struts/struts2/trunk/core/src/main/resources/org/apache/struts2/default.properties
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/default.properties?rev=628283&r1=628282&r2=628283&view=diff
==============================================================================
--- 
struts/struts2/trunk/core/src/main/resources/org/apache/struts2/default.properties
 (original)
+++ 
struts/struts2/trunk/core/src/main/resources/org/apache/struts2/default.properties
 Sat Feb 16 04:32:12 2008
@@ -178,6 +178,9 @@
 ### See the StrutsBeanWrapper javadocs for more information
 struts.freemarker.wrapper.altMap=true
 
+### maxStrongSize for MruCacheStorage for freemarker
+struts.freemarker.mru.max.strong.size=100
+
 ### configure the XSLTResult class to use stylesheet caching.
 ### Set to true for developers and false for production.
 struts.xslt.nocache=false


Reply via email to