From: <bri...@us...> - 2003-07-08 19:48:48
|
Update of /cvsroot/webmacro/webmacro/src/org/webmacro/servlet In directory sc8-pr-cvs1:/tmp/cvs-serv7814/src/org/webmacro/servlet Modified Files: TemplateTool.java WMServlet.java Log Message: Eliminate FastWriter from public interface; use Template.write(OutputStream) instead Index: TemplateTool.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/TemplateTool.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** TemplateTool.java 12 Jun 2003 00:47:47 -0000 1.6 --- TemplateTool.java 8 Jul 2003 19:48:44 -0000 1.7 *************** *** 99,103 **** * new context. * @param fileRef a reference to the template file ! * @throws ResourceException if the file cannot be found or parsed * @return a new MacroTemplate */ --- 99,103 ---- * new context. * @param fileRef a reference to the template file ! * @throws org.webmacro.ResourceException if the file cannot be found or parsed * @return a new MacroTemplate */ *************** *** 175,179 **** synchronized (_context) { ! return _template.evaluate(_context); } } --- 175,179 ---- synchronized (_context) { ! return _template.getString(_context); } } Index: WMServlet.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/WMServlet.java,v retrieving revision 1.55 retrieving revision 1.56 diff -C2 -d -r1.55 -r1.56 *** WMServlet.java 12 Jun 2003 00:47:47 -0000 1.55 --- WMServlet.java 8 Jul 2003 19:48:45 -0000 1.56 *************** *** 32,38 **** import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; ! import java.io.IOException; ! import java.io.OutputStream; ! import java.io.UnsupportedEncodingException; import java.lang.reflect.Method; import java.util.Locale; --- 32,36 ---- import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; ! import java.io.*; import java.lang.reflect.Method; import java.util.Locale; *************** *** 249,254 **** { resp.setContentType("text/html"); ! FastWriter out = getFastWriter(resp.getOutputStream(), ! resp.getCharacterEncoding()); out.write("<html><head><title>WebMacro Error</title></head>"); --- 247,251 ---- { resp.setContentType("text/html"); ! Writer out = resp.getWriter(); out.write("<html><head><title>WebMacro Error</title></head>"); *************** *** 539,545 **** Template tmpl = getTemplate(templateName); ! FastWriter fw = getFastWriter(out, encoding); ! tmpl.write(fw, context); ! fw.close(); } --- 536,540 ---- Template tmpl = getTemplate(templateName); ! tmpl.write(out, encoding, context); } *************** *** 583,596 **** _log.debug("Using output encoding " + encoding); ! // get a fastwriter with no output stream, forcing ! // fastwriter to buffer the output internally. // this is necessary to be compatible with JSDK 2.3 // where you can't call setContentType() after getOutputStream(), // which could be happening during the template evaluation ! fw = FastWriter.getInstance(_broker, encoding); ! tmpl.write(fw, c); // now write the FW buffer to the response output stream ! writeFastWriter(resp, fw); } finally --- 578,589 ---- _log.debug("Using output encoding " + encoding); ! // get the bytes before calling getOutputStream // this is necessary to be compatible with JSDK 2.3 // where you can't call setContentType() after getOutputStream(), // which could be happening during the template evaluation ! byte[] bytes = tmpl.getBytes(encoding, c); // now write the FW buffer to the response output stream ! writeResponseBytes(resp, bytes, encoding); } finally *************** *** 638,647 **** + "\n<pre>" + e + "</pre>\n"); ! if (fw == null) ! fw = FastWriter.getInstance(_broker); ! fw.reset(fw.getOutputStream()); ! errorTemplate.write(fw, c); ! // now write the FW buffer to the response output stream ! writeFastWriter(c.getResponse(), fw); } catch (Exception errExcept) --- 631,636 ---- + "\n<pre>" + e + "</pre>\n"); ! String err = errorTemplate.getString(c); ! c.getResponse().getWriter().write(err); } catch (Exception errExcept) *************** *** 674,680 **** * to its Writer. * @param response where to write fast writer to ! * @param fw FastWriter, that has response buffered */ ! private void writeFastWriter (HttpServletResponse response, FastWriter fw) throws IOException { --- 663,669 ---- * to its Writer. * @param response where to write fast writer to ! * @param bytes the bytes to write */ ! private void writeResponseBytes (HttpServletResponse response, byte[] bytes, String encoding) throws IOException { *************** *** 698,709 **** _log.debug("Using Writer instead of OutputStream"); } ! response.setContentLength(fw.size()); if (out != null) { ! fw.writeTo(out); } else { ! response.getWriter().write(fw.toString()); } } --- 687,698 ---- _log.debug("Using Writer instead of OutputStream"); } ! response.setContentLength(bytes.length); if (out != null) { ! out.write(bytes); } else { ! response.getWriter().write(new String(bytes, encoding)); } } *************** *** 833,836 **** --- 822,826 ---- * this will be your ServletOutputStream * @param enctype the Encoding type to use + * @deprecated */ public FastWriter getFastWriter (OutputStream out, String enctype) |