2006/unicorn/src/org/w3c/unicorn/output SimpleOutputFormater.java,1.1.2.3,1.1.2.4

Update of /sources/public/2006/unicorn/src/org/w3c/unicorn/output
In directory hutz:/tmp/cvs-serv20608/src/org/w3c/unicorn/output

Modified Files:
      Tag: dev2
	SimpleOutputFormater.java 
Log Message:
initializes velocity context at each request

Index: SimpleOutputFormater.java
===================================================================
RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/output/Attic/SimpleOutputFormater.java,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -d -r1.1.2.3 -r1.1.2.4
--- SimpleOutputFormater.java	25 Aug 2009 08:49:49 -0000	1.1.2.3
+++ SimpleOutputFormater.java	27 Aug 2009 13:31:00 -0000	1.1.2.4
@@ -29,6 +29,8 @@
 	private static VelocityContext aVelocityContext;
 	
 	private String sOutputFormat;
+	
+	private String sLang;
 
 	public SimpleOutputFormater(final String sOutputFormat, final String sLang)
 		throws ResourceNotFoundException, ParseErrorException, Exception {
@@ -37,12 +39,8 @@
 		SimpleOutputFormater.logger.debug("Output language : " + sLang + ".");
 		
 		this.sOutputFormat = sOutputFormat;
+		this.sLang = sLang;
 		
-		if (Framework.getLanguageContexts().get(sLang) != null) {
-			aVelocityContext = new VelocityContext(Framework.getLanguageContexts().get(sLang));
-		} else {
-			aVelocityContext = new VelocityContext(Framework.getLanguageContexts().get(Property.get("DEFAULT_LANGUAGE")));
-		}
 	}
 
 	/*
@@ -54,6 +52,13 @@
 	public void produceOutput(final Map<String, Object> mapOfStringObject,
 			final Writer aWriter) throws ResourceNotFoundException,
 			ParseErrorException, MethodInvocationException, Exception {
+		
+		if (Framework.getLanguageContexts().get(sLang) != null) {
+			aVelocityContext = new VelocityContext(Framework.getLanguageContexts().get(sLang));
+		} else {
+			aVelocityContext = new VelocityContext(Framework.getLanguageContexts().get(Property.get("DEFAULT_LANGUAGE")));
+		}
+		
 		SimpleOutputFormater.logger.trace("produceOutput");
 		SimpleOutputFormater.logger.debug("Map of String -> Object : "
 				+ mapOfStringObject + ".");
@@ -77,6 +82,13 @@
 	public void produceError(final Exception aException, final Writer aWriter)
 			throws ResourceNotFoundException, ParseErrorException,
 			MethodInvocationException, Exception {
+		
+		if (Framework.getLanguageContexts().get(sLang) != null) {
+			aVelocityContext = new VelocityContext(Framework.getLanguageContexts().get(sLang));
+		} else {
+			aVelocityContext = new VelocityContext(Framework.getLanguageContexts().get(Property.get("DEFAULT_LANGUAGE")));
+		}
+		
 		SimpleOutputFormater.logger.trace("produceError");
 		SimpleOutputFormater.logger.debug("Error : " + aException.getMessage()
 				+ ".");

Received on Thursday, 27 August 2009 13:31:15 UTC