\r
package mir.misc;\r
\r
+import java.io.PrintWriter;\r
+import java.net.URLEncoder;\r
+import java.util.*;\r
+\r
+import javax.servlet.http.HttpServletResponse;\r
+\r
+import org.apache.struts.util.MessageResources;\r
+\r
import freemarker.template.*;\r
+\r
+import mir.log.LoggerWrapper;\r
import mir.util.*;\r
import mir.generator.*;\r
import mir.config.MirPropertiesConfiguration;\r
import mir.entity.Entity;\r
import mir.entity.EntityList;\r
import mir.storage.StorageObjectFailure;\r
-import org.apache.struts.util.MessageResources;\r
-\r
-import javax.servlet.http.HttpServletResponse;\r
-import java.io.PrintWriter;\r
-import java.net.URLEncoder;\r
-import java.util.*;\r
-\r
\r
/**\r
* Hilfsklasse zum Mergen von Template und Daten\r
public static String templateDir;\r
private static MirPropertiesConfiguration configuration;\r
private static FileTemplateCache templateCache;\r
- private static Logfile theLog;\r
private static String docRoot;\r
private static String actionRoot;\r
+ private static LoggerWrapper logger;\r
\r
static {\r
+ // ML: configuration is not thread safe: it's risky to use it like this\r
+ // actually I don't see why HTMLTemplateProcessor needs to be a\r
+ // class with static methods. This causes more problems than it solves.\r
try {\r
configuration = MirPropertiesConfiguration.instance();\r
- } catch (PropertiesConfigExc e) {\r
+ }\r
+ catch (PropertiesConfigExc e) {\r
e.printStackTrace();\r
}\r
- theLog = Logfile.getInstance(\r
- configuration.getStringWithHome("HTMLTemplateProcessor.Logfile"));\r
- templateDir = \r
- configuration.getStringWithHome("HTMLTemplateProcessor.Dir");\r
- theLog.printDebugInfo("templateDir: " + templateDir);\r
+\r
+ logger = new LoggerWrapper("TemplateEngine");\r
+\r
+ templateDir =\r
+ configuration.getStringWithHome("HTMLTemplateProcessor.Dir");\r
templateCache = new FileTemplateCache(templateDir);\r
templateCache.setLoadingPolicy(FileTemplateCache.LOAD_ON_DEMAND);\r
// gone in freemarker 1.7.1: templateCache.startAutoUpdate();\r
public static void process(HttpServletResponse res, String templateFilename,\r
TemplateModelRoot tmr, TemplateModelRoot extra,\r
PrintWriter out, Locale locale, String bundles,\r
- String bundles2) throws\r
- HTMLParseException {\r
+ String bundles2) throws HTMLParseException {\r
if (out == null)\r
throw new HTMLParseException("no outputstream");\r
Template tmpl = getTemplateFor(templateFilename);\r
while (it.hasNext()) {\r
key = (String) it.next();\r
configHash.put(key, new SimpleScalar(\r
- configuration.getString(key))\r
+ configuration.getString(key))\r
);\r
}\r
\r
\r
if (extra != null) {\r
outPutHash.put("extra", extra);\r
- try {\r
- while ( ( (SimpleList) extra).hasNext()) {\r
- theLog.printDebugInfo( ( (SimpleList) extra).next().toString());\r
- }\r
- }\r
- catch (Exception e) {\r
- }\r
}\r
outPutHash.put("data", tmr);\r
outPutHash.put("config", configHash);\r
*\r
* @deprecated EntityLists comply with TemplateListModel now.\r
*/\r
- public static SimpleList makeSimpleList(EntityList aList) throws\r
- StorageObjectFailure {\r
- theLog.printWarning(\r
- "## using deprecated makeSimpleList(entityList) - a waste of resources");\r
+ public static SimpleList makeSimpleList(EntityList aList) throws StorageObjectFailure {\r
+ logger.warn("using deprecated makeSimpleList(entityList) - a waste of resources");\r
SimpleList simpleList = new SimpleList();\r
if (aList != null) {\r
for (int i = 0; i < aList.size(); i++) {\r
"template");\r
\r
if (returnTemplate == null) {\r
- theLog.printError("CACHE (ERR): Unknown template: " + templateFilename);\r
- throw new HTMLParseException("Templatefile: " + templateFilename +\r
- " not found.");\r
+ logger.error("CACHE (ERR): Unknown template: " + templateFilename);\r
+ throw new HTMLParseException("Templatefile: " + templateFilename + " not found.");\r
}\r
\r
return returnTemplate;\r