VIVO-246 Re-implement the FreemarkerConfiguration

The Configuration must contain mutable information like the theme directory and the TemplateLoader. It must also be request-specific so it can have the correct Locale for language support. But we should only have one instance, so there is only one TemplateCache (alternatively, one TemplateCache per theme).

Previously, this was addressed by intercepting the Template processing and adding the request-based info to the Environment. However, this interception code needed to appear each time a Template was processed. This was sometimes overlooked, and at best introduced a bunch of duplicated code.

Instead, I extended the freemarker Configuration class to include a ThreadLocal that holds request-specific information.
This commit is contained in:
j2blake 2013-08-08 13:22:16 -04:00
parent 98bb7236d1
commit 3f061da006
15 changed files with 630 additions and 472 deletions

View file

@ -65,6 +65,7 @@ edu.cornell.mannlib.vitro.webapp.i18n.selection.LocaleSelectionSetup
edu.cornell.mannlib.vitro.webapp.search.solr.SolrSetup
edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerSetup
edu.cornell.mannlib.vitro.webapp.freemarker.config.FreemarkerConfiguration$Setup
# On shutdown, this will kill the background thread started by Apache Commons File Upload
org.apache.commons.fileupload.servlet.FileCleanerCleanup