Added ability to configure strong level 1 cache for Freemarker

WW-2189


git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@628283 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Donald J. Brown
2008-02-16 12:32:12 +00:00
parent bb263e0081
commit 5270291101
3 changed files with 19 additions and 3 deletions
@@ -83,7 +83,10 @@ public final class StrutsConstants {
/** 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 @@ public final class StrutsConstants {
/** The {@link com.opensymphony.xwork2.util.ValueStackFactory} implementation class */
public static final String STRUTS_VALUESTACKFACTORY = "struts.valueStackFactory";
/** The {@link com.opensymphony.xwork2.reflection.ReflectionProvider} implementation class */
/** The {@link com.opensymphony.xwork2.util.reflection.ReflectionProvider} implementation class */
public static final String STRUTS_REFLECTIONPROVIDER = "struts.reflectionProvider";
/** The {@link com.opensymphony.xwork2.reflection.ReflectionContextFactory} implementation class */
/** The {@link com.opensymphony.xwork2.util.reflection.ReflectionContextFactory} implementation class */
public static final String STRUTS_REFLECTIONCONTEXTFACTORY = "struts.reflectionContextFactory";
/** The {@link com.opensymphony.xwork2.util.PatternMatcher} implementation class */
@@ -121,6 +121,7 @@ public class FreemarkerManager {
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 @@ public class FreemarkerManager {
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 @@ public class FreemarkerManager {
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);
@@ -178,6 +178,9 @@ struts.freemarker.beanwrapperCache=false
### 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