From: <bri...@us...> - 2003-07-17 05:25:11
|
Update of /cvsroot/webmacro/webmacro/src/org/webmacro/servlet In directory sc8-pr-cvs1:/tmp/cvs-serv28783/src/org/webmacro/servlet Modified Files: WMServlet.java Log Message: Eliminate profiling and pooling Index: WMServlet.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/WMServlet.java,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** WMServlet.java 16 Jul 2003 06:45:00 -0000 1.58 --- WMServlet.java 17 Jul 2003 05:25:07 -0000 1.59 *************** *** 244,264 **** - boolean timing = false; context = newWebContext(req, resp); try { - timing = Flags.PROFILE && context.isTiming(); - if (timing) context.startTiming("WMServlet", req.getRequestURI()); - Template t; ! try ! { ! if (timing) context.startTiming("handle"); ! t = handle(context); ! } ! finally ! { ! if (timing) context.stopTiming(); ! } if (t != null) --- 244,252 ---- context = newWebContext(req, resp); try { Template t; ! t = handle(context); if (t != null) *************** *** 266,278 **** execute(t, context); } ! if (timing) context.startTiming("WMServlet.destroyContext()"); ! try ! { ! destroyContext(context); ! } ! finally ! { ! if (timing) context.stopTiming(); ! } } catch (HandlerException e) --- 254,258 ---- execute(t, context); } ! destroyContext(context); } catch (HandlerException e) *************** *** 295,302 **** execute(tmpl, context); } - finally - { - if (timing) context.stopTiming(); - } } --- 275,278 ---- *************** *** 518,561 **** throws IOException { - boolean timing = Flags.PROFILE && c.isTiming(); try { ! if (timing) c.startTiming("Template.write", tmpl); ! try ! { ! HttpServletResponse resp = c.getResponse(); ! ! Locale locale = (Locale) tmpl.getParam( ! WMConstants.TEMPLATE_LOCALE); ! if (_log.loggingDebug()) ! _log.debug("TemplateLocale=" + locale); ! if (locale != null) ! { ! setLocale(resp, locale); ! } ! ! String encoding = (String) tmpl.getParam( ! WMConstants.TEMPLATE_OUTPUT_ENCODING); ! if (encoding == null) ! { ! encoding = resp.getCharacterEncoding(); ! } ! if (_log.loggingDebug()) ! _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.evaluateAsBytes(encoding, c); ! ! // now write the FW buffer to the response output stream ! writeResponseBytes(resp, bytes, encoding); } ! finally { ! if (timing) c.stopTiming(); } } catch (UnsupportedEncodingException e) --- 494,528 ---- throws IOException { try { ! HttpServletResponse resp = c.getResponse(); ! Locale locale = (Locale) tmpl.getParam( ! WMConstants.TEMPLATE_LOCALE); ! if (_log.loggingDebug()) ! _log.debug("TemplateLocale=" + locale); ! if (locale != null) ! { ! setLocale(resp, locale); } ! ! String encoding = (String) tmpl.getParam( ! WMConstants.TEMPLATE_OUTPUT_ENCODING); ! if (encoding == null) { ! encoding = resp.getCharacterEncoding(); } + + if (_log.loggingDebug()) + _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.evaluateAsBytes(encoding, c); + + // now write the FW buffer to the response output stream + writeResponseBytes(resp, bytes, encoding); } catch (UnsupportedEncodingException e) *************** *** 759,763 **** /** ! * Retrieve a FastWriter from WebMacro's internal pool of FastWriters. * A FastWriter is used when writing templates to an output stream * --- 726,730 ---- /** ! * Get a new FastWriter. * A FastWriter is used when writing templates to an output stream * |