You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(11) |
Nov
(97) |
Dec
(35) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(12) |
Feb
(55) |
Mar
(21) |
Apr
(3) |
May
(7) |
Jun
(25) |
Jul
(108) |
Aug
(23) |
Sep
|
Oct
|
Nov
|
Dec
(4) |
2006 |
Jan
|
Feb
|
Mar
(6) |
Apr
(3) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2008 |
Jan
(13) |
Feb
|
Mar
(257) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(38) |
Dec
|
2009 |
Jan
|
Feb
(1) |
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2010 |
Jan
|
Feb
(63) |
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
(1) |
2011 |
Jan
|
Feb
(1) |
Mar
|
Apr
(1) |
May
(1) |
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2012 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <wan...@us...> - 2003-07-17 15:18:33
|
Update of /cvsroot/webmacro/webmacro/test/unit/org/webmacro/template In directory sc8-pr-cvs1:/tmp/cvs-serv23382 Modified Files: TestDirectiveParser.java Log Message: Recant! Parser bug was a false alarm, but added new tests to ensure correct behaviour - although these are probably duplicated elsewhere under whitespace handling. Index: TestDirectiveParser.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/test/unit/org/webmacro/template/TestDirectiveParser.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TestDirectiveParser.java 17 Jul 2003 12:52:58 -0000 1.7 --- TestDirectiveParser.java 17 Jul 2003 15:18:29 -0000 1.8 *************** *** 71,78 **** } ! public void testQuotedDirective () throws Exception { assertStringTemplateEquals( "#if (true) ok #end", "ok"); ! assertStringTemplateEquals( "x#if (true) ok #end", "xok" ); } --- 71,81 ---- } ! public void testSmashedTogetherDirective () throws Exception { assertStringTemplateEquals( "#if (true) ok #end", "ok"); ! assertStringTemplateEquals( "x#if (true) ok #end", "x#if (true) ok #end" ); ! assertStringTemplateEquals( " #if (true) ok #end", "ok" ); ! assertStringTemplateEquals( "\"#if (true) ok #end", "\"#if (true) ok #end" ); ! assertStringTemplateEquals( "\" #if (true) ok #end", "\"ok" ); } |
From: <wan...@us...> - 2003-07-17 12:53:02
|
Update of /cvsroot/webmacro/webmacro/test/unit/org/webmacro/template In directory sc8-pr-cvs1:/tmp/cvs-serv30347 Modified Files: TemplateTestCase.java TestDirectiveParser.java TestGetSet.java Log Message: New tests, specifically to catch the new directive parsing bug. Index: TemplateTestCase.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/test/unit/org/webmacro/template/TemplateTestCase.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** TemplateTestCase.java 16 Jul 2003 06:45:00 -0000 1.17 --- TemplateTestCase.java 17 Jul 2003 12:52:58 -0000 1.18 *************** *** 167,173 **** /** Asserts that the given template text evalutes to the given result text * when evaluated against the current context */ ! ! public void assertStringTemplateEquals (String templateText, ! String resultText) { String result = null; --- 167,172 ---- /** Asserts that the given template text evalutes to the given result text * when evaluated against the current context */ ! private void assertStringTemplate(String templateText, ! String resultText, boolean equals) { String result = null; *************** *** 190,200 **** return; ! if (!result.equals(resultText)) { System.err.println("Execution of /" + templateText + "/" ! + " yielded /" + result + "/, expecting /" ! + resultText + "/"); assertTrue(false); } } --- 189,218 ---- return; ! if (result.equals(resultText) != equals) { System.err.println("Execution of /" + templateText + "/" ! + " yielded /" + result + "/, " + (equals ? "" : " not ")+ ! "expecting /" + resultText + "/"); assertTrue(false); } + } + + + /** Asserts that the given template text evalutes to the given result text + * when evaluated against the current context */ + + public void assertStringTemplateEquals (String templateText, + String resultText) + { + assertStringTemplate( templateText, resultText, true); + } + + /** Asserts that the given template text evalutes to the given result text + * when evaluated against the current context */ + + public void assertStringTemplateNotEquals (String templateText, + String resultText) + { + assertStringTemplate( templateText, resultText, false); } Index: TestDirectiveParser.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/test/unit/org/webmacro/template/TestDirectiveParser.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** TestDirectiveParser.java 12 Jun 2003 00:47:50 -0000 1.6 --- TestDirectiveParser.java 17 Jul 2003 12:52:58 -0000 1.7 *************** *** 71,74 **** --- 71,80 ---- } + public void testQuotedDirective () throws Exception + { + assertStringTemplateEquals( "#if (true) ok #end", "ok"); + assertStringTemplateEquals( "x#if (true) ok #end", "xok" ); + } + public static class DirectiveOne extends BaseDirective Index: TestGetSet.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/test/unit/org/webmacro/template/TestGetSet.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** TestGetSet.java 12 Jun 2003 00:47:50 -0000 1.5 --- TestGetSet.java 17 Jul 2003 12:52:58 -0000 1.6 *************** *** 2,5 **** --- 2,6 ---- import org.webmacro.Context; + import org.webmacro.PropertyException; import org.webmacro.engine.DefaultEvaluationExceptionHandler; *************** *** 200,203 **** --- 201,211 ---- String tmpl = "$TestObject.getArray().length"; assertStringTemplateEquals(tmpl, "2"); + } + + /** Make sure we are not evaluating stuff that doesn't exist */ + public void testNonExistentProperties () throws Exception + { + String tmpl = "$TestObject.Int.Int.Int.Int"; + assertStringTemplateThrows( tmpl, PropertyException.class ); } } |
Update of /cvsroot/webmacro/webmacro/src/org/webmacro/util In directory sc8-pr-cvs1:/tmp/cvs-serv29972/src/org/webmacro/util Removed Files: IntMap.java QueueWriter.java SimpleStack.java SparseArrayIterator.java SparseProperties.java Log Message: Eliminate misc unused classes --- IntMap.java DELETED --- --- QueueWriter.java DELETED --- --- SimpleStack.java DELETED --- --- SparseArrayIterator.java DELETED --- --- SparseProperties.java DELETED --- |
From: <bri...@us...> - 2003-07-17 05:34:02
|
Update of /cvsroot/webmacro/webmacro/src/org/webmacro/profile In directory sc8-pr-cvs1:/tmp/cvs-serv29972/src/org/webmacro/profile Removed Files: ProfileEvent.java Log Message: Eliminate misc unused classes --- ProfileEvent.java DELETED --- |
From: <bri...@us...> - 2003-07-17 05:25:12
|
Update of /cvsroot/webmacro/webmacro/src/org/webmacro/profile In directory sc8-pr-cvs1:/tmp/cvs-serv28783/src/org/webmacro/profile Removed Files: CallGraph.java Profile.java ProfileCategory.java ProfileSystem.java Log Message: Eliminate profiling and pooling --- CallGraph.java DELETED --- --- Profile.java DELETED --- --- ProfileCategory.java DELETED --- --- ProfileSystem.java DELETED --- |
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 * |
From: <bri...@us...> - 2003-07-17 05:25:11
|
Update of /cvsroot/webmacro/webmacro/src/org/webmacro/directive In directory sc8-pr-cvs1:/tmp/cvs-serv28783/src/org/webmacro/directive Removed Files: ProfileDirective.java Log Message: Eliminate profiling and pooling --- ProfileDirective.java DELETED --- |
From: <bri...@us...> - 2003-07-17 05:25:11
|
Update of /cvsroot/webmacro/webmacro/src/org/webmacro/util In directory sc8-pr-cvs1:/tmp/cvs-serv28783/src/org/webmacro/util Removed Files: Pool.java ScalablePool.java Log Message: Eliminate profiling and pooling --- Pool.java DELETED --- --- ScalablePool.java DELETED --- |
From: <bri...@us...> - 2003-07-17 05:25:10
|
Update of /cvsroot/webmacro/webmacro/src/org/webmacro In directory sc8-pr-cvs1:/tmp/cvs-serv28783/src/org/webmacro Modified Files: Broker.java Context.java WM.java WebMacro.java Log Message: Eliminate profiling and pooling Index: Broker.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/Broker.java,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** Broker.java 16 Jul 2003 10:50:40 -0000 1.38 --- Broker.java 17 Jul 2003 05:25:06 -0000 1.39 *************** *** 20,29 **** package org.webmacro; - import org.webmacro.engine.*; - import org.webmacro.profile.Profile; - import org.webmacro.profile.ProfileCategory; - import org.webmacro.profile.ProfileSystem; - import org.webmacro.util.*; - import java.io.*; import java.lang.ref.WeakReference; --- 20,23 ---- *************** *** 33,36 **** --- 27,42 ---- import java.util.*; + import org.webmacro.engine.DefaultEvaluationExceptionHandler; + import org.webmacro.engine.EvaluationExceptionHandler; + import org.webmacro.engine.IntrospectionUtils; + import org.webmacro.engine.MethodWrapper; + import org.webmacro.engine.PropertyOperatorCache; + import org.webmacro.util.LogFile; + import org.webmacro.util.LogSystem; + import org.webmacro.util.LogTarget; + import org.webmacro.util.LogTargetFactory; + import org.webmacro.util.Settings; + import org.webmacro.util.SubSettings; + /** * The Broker is responsible for loading and initializing almost everything *************** *** 74,78 **** protected Log _log; - protected ProfileCategory _prof; private EvaluationExceptionHandler _eeHandler; --- 80,83 ---- *************** *** 286,314 **** } - // set up profiling - ProfileSystem ps = ProfileSystem.getInstance(); - int pRate = _config.getIntegerSetting("Profile.rate", 0); - int pTime = _config.getIntegerSetting("Profile.time", 60000); - - _log.debug("Profiling rate=" + pRate + " time=" + pTime); - - if ((pRate != 0) && (pTime != 0)) - { - _prof = ps.newProfileCategory(_name, pRate, pTime); - _log.debug("ProfileSystem.newProfileCategory: " + _prof); - } - else - { - _prof = null; - } - if (_prof != null) - { - _log.notice("Profiling started: " + _prof); - } - else - { - _log.info("Profiling not started."); - } - // set up providers _config.processListSetting("Providers", new ProviderSettingHandler()); --- 291,294 ---- *************** *** 691,695 **** /** ! * Retrieve a FastWriter from WebMacro's internal pool of FastWriters. * A FastWriter is used when writing templates to an output stream * --- 671,675 ---- /** ! * Get a new FastWriter * A FastWriter is used when writing templates to an output stream * *************** *** 797,810 **** { return Class.forName(name); - } - - /** - * Get a profile instance that can be used to instrument code. - * This instance must not be shared between threads. If profiling - * is currently disabled this method will return null. - */ - public Profile newProfile () - { - return (_prof == null) ? null : _prof.newProfile(); } --- 777,780 ---- Index: Context.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/Context.java,v retrieving revision 1.62 retrieving revision 1.63 diff -C2 -d -r1.62 -r1.63 *** Context.java 16 Jul 2003 06:44:59 -0000 1.62 --- Context.java 17 Jul 2003 05:25:06 -0000 1.63 *************** *** 69,74 **** = org.webmacro.engine.UndefinedMacro.getInstance(); - private org.webmacro.profile.Profile _prof = null; - /** * Create a new Context relative to the default WM instance --- 69,72 ---- *************** *** 83,101 **** public Context (Broker broker) { - _prof = broker.newProfile(); - if (_prof != null) - { - startTiming("Context life"); - } - if (_prof != null) - { - startTiming("Context init"); - } _broker = broker; _log = broker.getLog("context", "property and evaluation errors"); - if (_prof != null) - { - stopTiming(); - } } --- 81,86 ---- *************** *** 124,131 **** public Context cloneContext () { - if (_prof != null) - { - startTiming("cloneContext"); - } Context c; try --- 109,112 ---- *************** *** 138,143 **** return null; // never going to happen } - c._prof = _broker.newProfile(); - c.startTiming("Context life"); // stops in clear() c._teContext = new TemplateEvaluationContext(); if (_variables instanceof HashMap) --- 119,122 ---- *************** *** 149,156 **** c._variables = new HashMap(_variables); } - if (_prof != null) - { - stopTiming(); - } return c; } --- 128,131 ---- *************** *** 166,174 **** _variables.clear(); _eeHandler = null; - if (_prof != null) - { - stopTiming(); - _prof.destroy(); - } } --- 141,144 ---- *************** *** 583,678 **** ////////////////////////////////////////////////////////////// - - /** - * Return true if the Context contains an active profiler, and - * calls to startTiming/stopTiming will be counted. - */ - public final boolean isTiming () - { - return (_prof != null); - } - - /** - * Mark the start of an event for profiling. Note that you MUST - * call stop() or the results of profiling will be invalid. - */ - public final void startTiming (String name) - { - if (_prof == null) - { - return; - } - _prof.startEvent(name); - } - - /** - * Same as startTiming(name1 + "(" + arg + ")") but the concatenation - * of strings and the call to arg.toString() occurs only if profiling - * is enabled. - */ - public final void startTiming (String name1, Object arg) - { - if (_prof == null) - { - return; - } - _prof.startEvent(name1 + "(" + arg + ")"); - } - - /** - * Same as startTiming(name1 + "(" + arg1 + "," + arg2 + ")") but the - * concatenation of strings and the call to arg.toString() occurs only - * if profiling * is enabled. - */ - public final void startTiming (String name1, Object arg1, Object arg2) - { - if (_prof == null) - { - return; - } - _prof.startEvent(name1 + "(" + arg1 + ", " + arg2 + ")"); - } - - /** - * Same as startTiming(name1 + "(" + arg + ")") but the - * concatenation of strings and the call to toString() occurs only - * if profiling is enabled. - */ - public final void startTiming (String name, int arg) - { - if (_prof == null) - { - return; - } - _prof.startEvent(name + "(" + arg + ")"); - } - - /** - * Same as startTiming(name1 + "(" + arg + ")") but the - * concatenation of strings and the call to toString() occurs only - * if profiling is enabled. - */ - public final void startTiming (String name, boolean arg) - { - if (_prof == null) - { - return; - } - _prof.startEvent(name + "(" + arg + ")"); - } - - /** - * Mark the end of an event for profiling. Note that you MUST - * HAVE CALLED start() first or the results of profiling will - * be invalid. - */ - public final void stopTiming () - { - if (_prof == null) - { - return; - } - _prof.stopEvent(); - } /** --- 553,556 ---- Index: WM.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/WM.java,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** WM.java 16 Jul 2003 06:44:59 -0000 1.43 --- WM.java 17 Jul 2003 05:25:06 -0000 1.44 *************** *** 164,168 **** /** ! * Retrieve a FastWriter from WebMacro's internal pool of FastWriters. * A FastWriter is used when writing templates to an output stream * --- 164,168 ---- /** ! * Get a new FastWriter. * A FastWriter is used when writing templates to an output stream * Index: WebMacro.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/WebMacro.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** WebMacro.java 16 Jul 2003 06:44:59 -0000 1.16 --- WebMacro.java 17 Jul 2003 05:25:06 -0000 1.17 *************** *** 61,70 **** /** ! * Retrieve a FastWriter from WebMacro's internal pool of FastWriters. * A FastWriter is used when writing templates to an output stream.<p> * * If using a FastWriter directly, <b>always</b> make sure to <code>flush()</code> ! * and <code>close()</code> it when you're finished. Closing it ! * automatically returns back to the pool for later reuse. * * @param out The output stream the FastWriter should write to. Typically --- 61,69 ---- /** ! * Get a new FastWriter * A FastWriter is used when writing templates to an output stream.<p> * * If using a FastWriter directly, <b>always</b> make sure to <code>flush()</code> ! * and <code>close()</code> it when you're finished. * * @param out The output stream the FastWriter should write to. Typically |
From: <bri...@us...> - 2003-07-17 05:25:10
|
Update of /cvsroot/webmacro/webmacro/examples In directory sc8-pr-cvs1:/tmp/cvs-serv28783/examples Modified Files: WebMacro.properties Removed Files: Profile.java Log Message: Eliminate profiling and pooling Index: WebMacro.properties =================================================================== RCS file: /cvsroot/webmacro/webmacro/examples/WebMacro.properties,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** WebMacro.properties 17 Jul 2002 07:18:22 -0000 1.31 --- WebMacro.properties 17 Jul 2003 05:25:06 -0000 1.32 *************** *** 110,136 **** - # Set Profile.rate to control the impact of the profiler on your CPU. - # Set it to 0 to turn profiling off. Setting it to 1 incurs profiling - # overhead on every event. Setting it to a number reater than 1 - # incurs profiling overhead on 1:N events. Setting it to a prime - # number is a good idea. The higher you set it, the less impact - # profiling will have on your system and the longer it will take - # to get reasonable results from the profiler. - # - # The default is 0, disabling the profiler. - - Profile.rate: 0 - - # Set Profile.time to control the impact of the profiler on memory. - # Setting # it to 0 turns the profiler off. Profile.time represents - # the number of milliseconds that the profiler stores an event for. - # In other words, the current statistics represent all the events - # over the last Profile.time milliseconds. Setting it to a large - # value will cause the profiler to remember a larger number of - # events and consume more memory. - # - # The default is 20 seconds - - Profile.time: 20000 - - Directives.profile: org.webmacro.directive.ProfileDirective --- 110,111 ---- --- Profile.java DELETED --- |
From: <bri...@us...> - 2003-07-17 05:25:10
|
Update of /cvsroot/webmacro/webmacro In directory sc8-pr-cvs1:/tmp/cvs-serv28783 Modified Files: WebMacro.defaults Log Message: Eliminate profiling and pooling Index: WebMacro.defaults =================================================================== RCS file: /cvsroot/webmacro/webmacro/WebMacro.defaults,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** WebMacro.defaults 3 Jun 2003 05:22:37 -0000 1.38 --- WebMacro.defaults 17 Jul 2003 05:25:06 -0000 1.39 *************** *** 118,158 **** - # - # Profiling - # - - # To enable the #profile directive, uncomment the line below - # You *must* do this if you plan to use the #profile example - - # Directives.profile: org.webmacro.directive.ProfileDirective - - - # Set Profile.rate to control the impact of the profiler on your CPU. - # Set it to 0 to turn profiling off. Setting it to 1 incurs profiling - # overhead on every event. Setting it to a number reater than 1 - # incurs profiling overhead on 1:N events. Setting it to a prime - # number is a good idea. The higher you set it, the less impact - # profiling will have on your system and the longer it will take - # to get reasonable results from the profiler. - # - # The default is 0, disabling the profiler. - - Profile.rate: 0 - - # Set Profile.time to control the impact of the profiler on memory. - # Setting # it to 0 turns the profiler off. Profile.time represents - # the number of milliseconds that the profiler stores an event for. - # In other words, the current statistics represent all the events - # over the last Profile.time milliseconds. Setting it to a large - # value will cause the profiler to remember a larger number of - # events and consume more memory. - # - # The default is 2 minutes (120000 milliseconds) - - Profile.time: 120000 - - - - ########################################################### # --- 118,121 ---- *************** *** 319,323 **** # and resource penalties - FastWriter.MaxPoolSize = 10 FastWriter.DefaultBufferSize = 4096 --- 282,285 ---- |
From: <wan...@us...> - 2003-07-16 14:25:34
|
Update of /cvsroot/webmacro/webmacro/src/org/webmacro/engine In directory sc8-pr-cvs1:/tmp/cvs-serv5350 Modified Files: PropertyOperatorCache.java Log Message: Attempted fix for "binary set" method not found bug. May have implications but works for now. Index: PropertyOperatorCache.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/engine/PropertyOperatorCache.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** PropertyOperatorCache.java 12 Jun 2003 00:47:45 -0000 1.18 --- PropertyOperatorCache.java 16 Jul 2003 14:25:31 -0000 1.19 *************** *** 247,250 **** --- 247,310 ---- } + public static class Wrapper + { + + private Map params = new Hashtable(); + + public String getParameters( String key ) + { + return (String) params.get( key ); + } + + public void setParameters( String key, Object value ) + { + params.put( key, value ); + } + } + + public static class Wrapper2 + { + + private Map params = new Hashtable(); + + public Wrapper2() + { + this.params.put( "Parameters", new Hashtable() ); + } + + public Object get( Object key ) + { + return params.get( key ); + } + + public void put( Object key, Object value ) + { + params.put( key, value ); + } + } + + public static void main( String[] args ) + { + final String templateText = + "#set $test.Parameters.Name = 'marc'\n" + + "#set $test2.Parameters.Name = 'eric'\n" + + "Current value is: $test.Parameters.Name\n"+ + "Current value2 is: $test2.Parameters.Name\n"; + try + { + WebMacro wm = new WM( "testconfig.properties" ); + Template t = new StringTemplate( wm.getBroker(), templateText ); + Context context = wm.getContext(); + context.put( "test", new Wrapper() ); + context.put( "test2", new Wrapper2() ); + t.write( System.out, context ); + } + catch ( Exception e ) + { + e.printStackTrace(); //To change body of catch statement use Options | File Templates. + } + + } + } *************** *** 693,713 **** throws PropertyException { ! String prop; ! Object nextProp = null; Accessor acc = null; if (names[start] instanceof String) { ! prop = (String) names[start]; } else if (names[start] instanceof PropertyMethod) { PropertyMethod pm = (PropertyMethod) names[start]; ! prop = pm.getName(); ! acc = (Accessor) _directAccessors.get(prop); Object[] args = pm.getArguments(context); if (acc == null) { ! if (isMethodRestricted(instance.getClass(), prop)) throw new PropertyException.RestrictedMethodException( pm.toString(), --- 753,773 ---- throws PropertyException { ! String propName; ! Object nextPropValue = null; Accessor acc = null; if (names[start] instanceof String) { ! propName = (String) names[start]; } else if (names[start] instanceof PropertyMethod) { PropertyMethod pm = (PropertyMethod) names[start]; ! propName = pm.getName(); ! acc = (Accessor) _directAccessors.get(propName); Object[] args = pm.getArguments(context); if (acc == null) { ! if (isMethodRestricted(instance.getClass(), propName)) throw new PropertyException.RestrictedMethodException( pm.toString(), *************** *** 721,725 **** try { ! nextProp = acc.get(instance, args); start++; } --- 781,785 ---- try { ! nextPropValue = acc.get(instance, args); start++; } *************** *** 735,739 **** else { ! prop = names[start].toString(); } --- 795,799 ---- else { ! propName = names[start].toString(); } *************** *** 741,750 **** if (acc == null) { ! acc = (Accessor) _unaryAccessors.get(prop); if (acc != null) { try { ! nextProp = acc.get(instance); start++; } --- 801,810 ---- if (acc == null) { ! acc = (Accessor) _unaryAccessors.get(propName); if (acc != null) { try { ! nextPropValue = acc.get(instance); start++; } *************** *** 759,768 **** if (acc == null) { ! acc = (Accessor) _binaryAccessors.get(prop); ! if ((acc != null) && ((start + 1) <= end)) { try { ! nextProp = acc.get(instance, (String) names[start + 1]); start += 2; } --- 819,829 ---- if (acc == null) { ! acc = (Accessor) _binaryAccessors.get(propName); ! // if ((acc != null) && ((start + 1) <= end)) ! if ((acc != null) && ((start + 1) <= names.length)) { try { ! nextPropValue = acc.get(instance, (String) names[start + 1]); start += 2; } *************** *** 793,797 **** if (acc != null) { ! nextProp = acc.get(instance, prop); start++; } --- 854,858 ---- if (acc != null) { ! nextPropValue = acc.get(instance, propName); start++; } *************** *** 809,828 **** // check if object is restricted ! if (isMethodRestricted(instance.getClass(), "get" + prop) ! || isMethodRestricted(instance.getClass(), "set" + prop)) throw new PropertyException.RestrictedPropertyException( ! prop, fillInName(names, start), instance.getClass().getName()); throw new PropertyException.NoSuchPropertyException( ! prop, fillInName(names, start), instance.getClass().getName()); } ! if (start <= end) { try { ! return _cache.getOperator(nextProp) ! .getProperty(context, nextProp, names, start, end); } catch (NullPointerException e) --- 870,889 ---- // check if object is restricted ! if (isMethodRestricted(instance.getClass(), "get" + propName) ! || isMethodRestricted(instance.getClass(), "set" + propName)) throw new PropertyException.RestrictedPropertyException( ! propName, fillInName(names, start), instance.getClass().getName()); throw new PropertyException.NoSuchPropertyException( ! propName, fillInName(names, start), instance.getClass().getName()); } ! if ( start <= end) { try { ! return _cache.getOperator(nextPropValue) ! .getProperty(context, nextPropValue, names, start, end); } catch (NullPointerException e) *************** *** 834,838 **** else { ! return nextProp; } } --- 895,899 ---- else { ! return nextPropValue; } } *************** *** 878,883 **** // names[pos] is what we could set from here ! int parentPos = names.length - 1; ! int binPos = parentPos - 1; // if we're not yet at the binary-settable parent, go there --- 939,943 ---- // names[pos] is what we could set from here ! int binPos = names.length - 2; // if we're not yet at the binary-settable parent, go there *************** *** 931,934 **** --- 991,995 ---- } } + return false; } *************** *** 1048,1051 **** --- 1109,1113 ---- } } + } |
From: <wan...@us...> - 2003-07-16 14:24:45
|
Update of /cvsroot/webmacro/webmacro/test/unit/org/webmacro/template In directory sc8-pr-cvs1:/tmp/cvs-serv5198 Modified Files: TestBinaryAccessor.java Log Message: Added another test of double-binary dereferencing. Index: TestBinaryAccessor.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/test/unit/org/webmacro/template/TestBinaryAccessor.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TestBinaryAccessor.java 11 Jul 2003 16:24:55 -0000 1.2 --- TestBinaryAccessor.java 16 Jul 2003 14:24:42 -0000 1.3 *************** *** 1,60 **** ! ! package org.webmacro.template; ! ! import org.webmacro.Context; ! ! import java.util.Hashtable; ! import java.util.Map; ! ! /** ! * @author Marc Palmer (<a href="mailto:wj...@wa...">wj...@wa...</a>) ! */ ! public class TestBinaryAccessor extends TemplateTestCase ! { ! ! public TestBinaryAccessor( String name ) ! { ! super( name ); ! } ! ! public static class Wrapper ! { ! ! private Map params = new Hashtable(); ! ! public String getParameters( String key ) ! { ! return (String) params.get( key ); ! } ! ! public void setParameters( String key, Object value ) ! { ! params.put( key, value ); ! } ! } ! ! public void testBinaryGet() ! { ! assertStringTemplateEquals("$obj.Parameters.Name", "Marc"); ! } ! ! public void testBinarySet() ! { ! assertStringTemplateEquals("#set $obj.Parameters.Name = 'Eric'", ""); ! } ! ! public void testBinarySetGet() ! { ! assertStringTemplateEquals( ! "#set $obj.Parameters.Name = 'Eric'\n" + ! "$obj.Parameters.Name", "Eric"); ! } ! ! protected void stuffContext( Context context ) throws Exception ! { ! final Wrapper value = new Wrapper(); ! value.setParameters( "Name", "Marc"); ! ! context.put( "obj", value ); ! } ! } --- 1,83 ---- ! ! package org.webmacro.template; ! ! import org.webmacro.Context; ! ! import java.util.Hashtable; ! import java.util.Map; ! ! /** ! * @author Marc Palmer (<a href="mailto:wj...@wa...">wj...@wa...</a>) ! */ ! public class TestBinaryAccessor extends TemplateTestCase ! { ! ! public TestBinaryAccessor( String name ) ! { ! super( name ); ! } ! ! public static class Wrapper ! { ! ! private Map params = new Hashtable(); ! ! public Object getParameters( String key ) ! { ! return params.get( key ); ! } ! ! public void setParameters( String key, Object value ) ! { ! params.put( key, value ); ! } ! } ! ! public void testBinaryGet() ! { ! assertStringTemplateEquals("$obj1.Parameters.Name", "Marc"); ! } ! ! public void testBinarySet() ! { ! assertStringTemplateEquals("#set $obj1.Parameters.Name = 'Eric'", ""); ! } ! ! public void testBinarySetGet() ! { ! assertStringTemplateEquals( ! "#set $obj1.Parameters.Name = 'Eric'\n" + ! "$obj1.Parameters.Name", "Eric"); ! } ! ! public void testBinaryMultiLevelGet() ! { ! assertStringTemplateEquals("$obj2.Parameters.BinaryLevelTwo.Parameters.Name", "Brian"); ! } ! ! public void testBinaryMultiLevelSet() ! { ! assertStringTemplateEquals("#set $obj2.Parameters.BinaryLevelTwo.Parameters.Name = 'Keats'", ""); ! } ! ! public void testBinaryMultiLevelSetGet() ! { ! assertStringTemplateEquals( ! "#set $obj2.Parameters.BinaryLevelTwo.Parameters.Name = 'Lane'\n"+ ! "$obj2.Parameters.BinaryLevelTwo.Parameters.Name", "Lane"); ! } ! ! protected void stuffContext( Context context ) throws Exception ! { ! final Wrapper value1 = new Wrapper(); ! value1.setParameters( "Name", "Marc"); ! ! context.put( "obj1", value1 ); ! ! final Wrapper value2 = new Wrapper(); ! final Wrapper subWrapper = new Wrapper(); ! subWrapper.setParameters( "Name", "Brian"); ! value2.setParameters( "BinaryLevelTwo", subWrapper); ! context.put( "obj2", value2 ); ! } ! } |
From: <wan...@us...> - 2003-07-16 10:50:43
|
Update of /cvsroot/webmacro/webmacro/src/org/webmacro In directory sc8-pr-cvs1:/tmp/cvs-serv5550 Modified Files: Broker.java Log Message: Bug fix - was not loading "ContextTools" section of settings, was erroneously reading "Tools" section. Index: Broker.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/Broker.java,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** Broker.java 16 Jul 2003 06:44:59 -0000 1.37 --- Broker.java 16 Jul 2003 10:50:40 -0000 1.38 *************** *** 320,324 **** // load tools ! loadTools("Tools"); loadTools("WebContextTools"); --- 320,324 ---- // load tools ! loadTools("ContextTools"); loadTools("WebContextTools"); |
From: <wan...@us...> - 2003-07-16 10:49:57
|
Update of /cvsroot/webmacro/webmacro/test/unit/org/webmacro/template In directory sc8-pr-cvs1:/tmp/cvs-serv5423 Modified Files: TestContextToolAccess.java Log Message: Ooops, bug in the test. Index: TestContextToolAccess.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/test/unit/org/webmacro/template/TestContextToolAccess.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TestContextToolAccess.java 16 Jul 2003 10:33:22 -0000 1.1 --- TestContextToolAccess.java 16 Jul 2003 10:49:54 -0000 1.2 *************** *** 20,24 **** public void testContextToolMethodCall() { ! assertStringTemplateEquals("$Text.HTMLEncode('&')", "&"); } --- 20,24 ---- public void testContextToolMethodCall() { ! assertStringTemplateEquals("$Text.HTMLEncode('&')", "&"); } |
From: <wan...@us...> - 2003-07-16 10:33:25
|
Update of /cvsroot/webmacro/webmacro/test/unit/org/webmacro/template In directory sc8-pr-cvs1:/tmp/cvs-serv2936 Added Files: TestContextToolAccess.java Log Message: Test to ensure context tool calls work. --- NEW FILE: TestContextToolAccess.java --- package org.webmacro.template; import org.webmacro.Context; import java.util.Hashtable; import java.util.Map; /** * @author Marc Palmer (<a href="mailto:wj...@wa...">wj...@wa...</a>) */ public class TestContextToolAccess extends TemplateTestCase { public TestContextToolAccess( String name ) { super( name ); } public void testContextToolMethodCall() { assertStringTemplateEquals("$Text.HTMLEncode('&')", "&"); } protected void stuffContext( Context context ) throws Exception { } } |
From: <bri...@us...> - 2003-07-16 07:04:24
|
Update of /cvsroot/webmacro/webmacro/src/org/webmacro/directive In directory sc8-pr-cvs1:/tmp/cvs-serv2879/src/org/webmacro/directive Modified Files: IncludeDirective.java Log Message: Fix problem where #include as macro includes the template name in the output instead of interpolating the template at build time against the build context Index: IncludeDirective.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/directive/IncludeDirective.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** IncludeDirective.java 16 Jul 2003 06:44:59 -0000 1.23 --- IncludeDirective.java 16 Jul 2003 07:04:20 -0000 1.24 *************** *** 318,322 **** throw makeBuildException("Unable to include as macro", e); } ! return t; } else if (_type == TYPE_DYNAMIC) --- 318,327 ---- throw makeBuildException("Unable to include as macro", e); } ! try { ! return t.evaluateAsString(bc); ! } ! catch (PropertyException e) { ! return ""; ! } } else if (_type == TYPE_DYNAMIC) |
From: <bri...@us...> - 2003-07-16 06:45:04
|
Update of /cvsroot/webmacro/webmacro/test/unit/org/webmacro/template In directory sc8-pr-cvs1:/tmp/cvs-serv32064/test/unit/org/webmacro/template Modified Files: EncodingTestCase.java TemplateTestCase.java Log Message: More ripping out -- eliminate reference counting of Brokers, pooling of context and fastwriter; streamline Context; eliminate Clock thread hack; eliminate ascii fastwriter hack Index: EncodingTestCase.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/test/unit/org/webmacro/template/EncodingTestCase.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** EncodingTestCase.java 8 Jul 2003 19:48:45 -0000 1.5 --- EncodingTestCase.java 16 Jul 2003 06:45:00 -0000 1.6 *************** *** 146,150 **** wm.getConfig("TemplateEncoding"), encoding); Template t = wm.getTemplate(TEMPLATE_FILENAME); ! String evaluated = t.getString(getContext(wm)); assertEquals("Template evaluated to \"" + evaluated + "\" instead of \"" + expected + "\"", evaluated, expected); --- 146,150 ---- wm.getConfig("TemplateEncoding"), encoding); Template t = wm.getTemplate(TEMPLATE_FILENAME); ! String evaluated = t.evaluateAsString(getContext(wm)); assertEquals("Template evaluated to \"" + evaluated + "\" instead of \"" + expected + "\"", evaluated, expected); *************** *** 179,183 **** wmUTF8.getConfig("TemplateEncoding"), "UTF8"); Template t = wmUTF8.getTemplate(TEMPLATE_FILENAME_UTF8); ! String evaluated = t.getString(getContext(wmUTF8)); assertEquals("Template evaluated to \"" + evaluated + "\" instead of \"" + expected + "\"", expected, evaluated); --- 179,183 ---- wmUTF8.getConfig("TemplateEncoding"), "UTF8"); Template t = wmUTF8.getTemplate(TEMPLATE_FILENAME_UTF8); ! String evaluated = t.evaluateAsString(getContext(wmUTF8)); assertEquals("Template evaluated to \"" + evaluated + "\" instead of \"" + expected + "\"", expected, evaluated); Index: TemplateTestCase.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/test/unit/org/webmacro/template/TemplateTestCase.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** TemplateTestCase.java 8 Jul 2003 19:48:45 -0000 1.16 --- TemplateTestCase.java 16 Jul 2003 06:45:00 -0000 1.17 *************** *** 94,98 **** public String executeTemplate (Template template) throws Exception { ! return template.getString(_context); } --- 94,98 ---- public String executeTemplate (Template template) throws Exception { ! return template.evaluateAsString(_context); } *************** *** 113,117 **** Template template = new StringTemplate(_wm.getBroker(), templateText); template.parse(); ! String output = template.getString(_context); return output; } --- 113,117 ---- Template template = new StringTemplate(_wm.getBroker(), templateText); template.parse(); ! String output = template.evaluateAsString(_context); return output; } |
Update of /cvsroot/webmacro/webmacro/src/org/webmacro/servlet In directory sc8-pr-cvs1:/tmp/cvs-serv32064/src/org/webmacro/servlet Modified Files: CGITool.java CookieTool.java FormListTool.java FormTool.java ListTool.java LocaleTool.java MathTool.java RequestTool.java ResponseTool.java ServletBroker.java SessionTool.java TemplateTool.java TextTool.java TypeTool.java URLTool.java VariableTool.java WMServlet.java WebContext.java Log Message: More ripping out -- eliminate reference counting of Brokers, pooling of context and fastwriter; streamline Context; eliminate Clock thread hack; eliminate ascii fastwriter hack Index: CGITool.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/CGITool.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** CGITool.java 12 Jun 2003 00:47:47 -0000 1.10 --- CGITool.java 16 Jul 2003 06:45:00 -0000 1.11 *************** *** 51,56 **** } - public void destroy (Object o) - { - } } --- 51,53 ---- Index: CookieTool.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/CookieTool.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** CookieTool.java 12 Jun 2003 00:47:47 -0000 1.9 --- CookieTool.java 16 Jul 2003 06:45:00 -0000 1.10 *************** *** 51,56 **** } - public void destroy (Object o) - { - } } --- 51,53 ---- Index: FormListTool.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/FormListTool.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** FormListTool.java 12 Jun 2003 00:47:47 -0000 1.9 --- FormListTool.java 16 Jul 2003 06:45:00 -0000 1.10 *************** *** 50,55 **** } - public void destroy (Object o) - { - } } --- 50,52 ---- Index: FormTool.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/FormTool.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** FormTool.java 12 Jun 2003 00:47:47 -0000 1.9 --- FormTool.java 16 Jul 2003 06:45:00 -0000 1.10 *************** *** 50,55 **** } - public void destroy (Object o) - { - } } --- 50,52 ---- Index: ListTool.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/ListTool.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ListTool.java 12 Jun 2003 00:47:47 -0000 1.5 --- ListTool.java 16 Jul 2003 06:45:00 -0000 1.6 *************** *** 42,47 **** } - public void destroy (Object o) - { - } } --- 42,44 ---- Index: LocaleTool.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/LocaleTool.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** LocaleTool.java 12 Jun 2003 00:47:47 -0000 1.8 --- LocaleTool.java 16 Jul 2003 06:45:00 -0000 1.9 *************** *** 166,171 **** } - public void destroy (Object o) - { - } } --- 166,168 ---- Index: MathTool.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/MathTool.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** MathTool.java 12 Jun 2003 00:47:47 -0000 1.7 --- MathTool.java 16 Jul 2003 06:45:00 -0000 1.8 *************** *** 205,215 **** } - /** - * Perform necessary cleanup work - */ - public void destroy (Object o) - { - } - public static void main (String[] args) { --- 205,208 ---- Index: RequestTool.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/RequestTool.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** RequestTool.java 12 Jun 2003 00:47:47 -0000 1.8 --- RequestTool.java 16 Jul 2003 06:45:00 -0000 1.9 *************** *** 49,54 **** } - public void destroy (Object o) - { - } } --- 49,51 ---- Index: ResponseTool.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/ResponseTool.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ResponseTool.java 12 Jun 2003 00:47:47 -0000 1.8 --- ResponseTool.java 16 Jul 2003 06:45:00 -0000 1.9 *************** *** 49,54 **** } - public void destroy (Object o) - { - } } --- 49,51 ---- Index: ServletBroker.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/ServletBroker.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** ServletBroker.java 12 Jun 2003 00:47:47 -0000 1.9 --- ServletBroker.java 16 Jul 2003 06:45:00 -0000 1.10 *************** *** 105,109 **** else b = Servlet20Broker.getBroker(s, additionalProperties); - b.startClient(); return b; } --- 105,108 ---- Index: SessionTool.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/SessionTool.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** SessionTool.java 12 Jun 2003 00:47:47 -0000 1.10 --- SessionTool.java 16 Jul 2003 06:45:00 -0000 1.11 *************** *** 53,58 **** } - public void destroy (Object o) - { - } } --- 53,55 ---- Index: TemplateTool.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/TemplateTool.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TemplateTool.java 8 Jul 2003 19:48:44 -0000 1.7 --- TemplateTool.java 16 Jul 2003 06:45:00 -0000 1.8 *************** *** 41,60 **** } - /** Invoked when the context is freed after its request/response - * has been completed. Used here to free the contexts created - * for MacroTemplates in this request. - * @param o the MacroTemplateFactory that is ready to be destroyed. - */ - synchronized public void destroy (Object o) - { - if (_destroyed) return; - _destroyed = true; - if (o != null) - { - ((MacroTemplateFactory) o).destroy(); - _context = null; - } - } - /** Create a factory object that can be accessed from WMScript as * $Template for creating MacroTemplate objects. --- 41,44 ---- *************** *** 112,125 **** } - void destroy () - { - java.util.Iterator iter = _macros.iterator(); - while (iter.hasNext()) - { - MacroTemplate mt = (MacroTemplate) iter.next(); - mt.destroy(); - } - _macros = null; // to encourage gc - } } --- 96,99 ---- *************** *** 141,148 **** _template = t; _origContext = c; ! org.webmacro.util.Pool pool = c.getPool(); ! _context = (pool == null) ? c.cloneContext() ! : (Context) c.getPool().get(); ! if (_context == null) _context = c.cloneContext(); } --- 115,120 ---- _template = t; _origContext = c; ! // @@@ Just get a new one? ! _context = c.cloneContext(); } *************** *** 175,179 **** synchronized (_context) { ! return _template.getString(_context); } } --- 147,151 ---- synchronized (_context) { ! return _template.evaluateAsString(_context); } } *************** *** 222,231 **** } - void destroy () - { - _context.recycle(); - _context = null; - _origContext = null; - } } } --- 194,197 ---- Index: TextTool.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/TextTool.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** TextTool.java 12 Jun 2003 00:47:47 -0000 1.11 --- TextTool.java 16 Jul 2003 06:45:00 -0000 1.12 *************** *** 400,410 **** } - /** - * Perform necessary cleanup work - */ - public void destroy (Object o) - { - } - // --- 400,403 ---- Index: TypeTool.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/TypeTool.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TypeTool.java 12 Jun 2003 00:47:47 -0000 1.4 --- TypeTool.java 16 Jul 2003 06:45:00 -0000 1.5 *************** *** 42,48 **** } - public void destroy (Object o) - { - } } --- 42,45 ---- Index: URLTool.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/URLTool.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** URLTool.java 12 Jun 2003 00:47:47 -0000 1.4 --- URLTool.java 16 Jul 2003 06:45:00 -0000 1.5 *************** *** 99,104 **** } - public void destroy (Object o) - { - } } --- 99,101 ---- Index: VariableTool.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/VariableTool.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** VariableTool.java 12 Jun 2003 00:47:47 -0000 1.9 --- VariableTool.java 16 Jul 2003 06:45:00 -0000 1.10 *************** *** 54,61 **** } - public void destroy (Object o) - { - } - /** * Is the specified object <code>name</code> defined in the active --- 54,57 ---- Index: WMServlet.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/WMServlet.java,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** WMServlet.java 11 Jul 2003 12:25:43 -0000 1.57 --- WMServlet.java 16 Jul 2003 06:45:00 -0000 1.58 *************** *** 53,57 **** private WebMacro _wm = null; private Broker _broker = null; - private WebContext _wcPrototype; private boolean _started = false; /** --- 53,56 ---- *************** *** 132,148 **** _log = _broker.getLog("servlet", "WMServlet lifecycle information"); - // set up WebContext - try - { - _wcPrototype = initWebContext(); - } - catch (InitException e) - { - _log.error("Failed to initialize a WebContext, the initWebContext\n" - + "method returned an exception", e); - _problem = e.getMessage(); - return; - } - try { --- 131,134 ---- *************** *** 180,184 **** stop(); _log.notice("stopped: " + this); - _wm.destroy(); _wm = null; _started = false; --- 166,169 ---- *************** *** 186,198 **** } ! /** ! * Check whether or not the broker we are using has been shut down ! */ ! public boolean isDestroyed () ! { ! return _wm.isDestroyed(); ! } ! ! // SERVLET API METHODS --- 171,175 ---- } ! // SERVLET API METHODS *************** *** 268,274 **** boolean timing = false; try { - context = newContext(req, resp); timing = Flags.PROFILE && context.isTiming(); if (timing) context.startTiming("WMServlet", req.getRequestURI()); --- 245,251 ---- boolean timing = false; + context = newWebContext(req, resp); try { timing = Flags.PROFILE && context.isTiming(); if (timing) context.startTiming("WMServlet", req.getRequestURI()); *************** *** 301,308 **** catch (HandlerException e) { - if (context == null) - { - context = _wcPrototype.newInstance(req, resp); - } _log.error("Your handler failed to handle the request:" + this, e); Template tmpl = error(context, --- 278,281 ---- *************** *** 314,321 **** catch (Exception e) { - if (context == null) - { - context = _wcPrototype.newInstance(req, resp); - } _log.error("Your handler failed to handle the request:" + this, e); Template tmpl = error(context, --- 287,290 ---- *************** *** 329,333 **** { if (timing) context.stopTiming(); - context.recycle(); } } --- 298,301 ---- *************** *** 472,476 **** /** ! * Create a new WebContext object */ public WebContext getWebContext (HttpServletRequest req, HttpServletResponse res) --- 440,444 ---- /** ! * Create a new WebContext object; can be overridden */ public WebContext getWebContext (HttpServletRequest req, HttpServletResponse res) *************** *** 581,585 **** // 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 --- 549,553 ---- // 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 *************** *** 620,624 **** + "\n<pre>" + e + "</pre>\n"); ! String err = errorTemplate.getString(c); c.getResponse().getWriter().write(err); } --- 588,592 ---- + "\n<pre>" + e + "</pre>\n"); ! String err = errorTemplate.evaluateAsString(c); c.getResponse().getWriter().write(err); } *************** *** 752,764 **** /** ! * This method must return a cloneable WebContext which can be ! * cloned for use in responding to individual requests. Each ! * incoming request will receive a clone of the returned object ! * as its context. The default implementation is to return ! * a new WebContext(getBroker()); */ ! public WebContext initWebContext () throws InitException { ! return new WebContext(_broker); } --- 720,735 ---- /** ! * NO LONGER USED ! * Exists only to catch implementations that use it. ! * Use newWebContext instead. ! * @deprecated */ ! public final WebContext initWebContext () throws InitException { ! return null; ! } ! ! public WebContext newWebContext(HttpServletRequest req, HttpServletResponse resp) { ! return new WebContext(_broker, req, resp); } Index: WebContext.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/WebContext.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** WebContext.java 12 Jun 2003 00:47:47 -0000 1.23 --- WebContext.java 16 Jul 2003 06:45:00 -0000 1.24 *************** *** 65,79 **** * Log configuration errors, context errors, etc. */ ! private Log _log; /** * The request for this http connect */ ! HttpServletRequest _request = null; /** * The response for this http connect */ ! HttpServletResponse _response = null; // property interface fields that are lazily set, non-final, and private --- 65,79 ---- * Log configuration errors, context errors, etc. */ ! private final Log _log; /** * The request for this http connect */ ! private HttpServletRequest _request = null; /** * The response for this http connect */ ! private HttpServletResponse _response = null; // property interface fields that are lazily set, non-final, and private *************** *** 83,121 **** * in addition to the ordinary ContextTools loaded from config. */ ! public WebContext (final Broker broker) { super(broker); _log = broker.getLog("WebContext"); - loadTools("WebContextTools"); } /** - * Create a new WebContext like this one, only with new values - * for request and response - */ - final public WebContext newInstance ( - final HttpServletRequest req, - final HttpServletResponse resp) - { - try - { - - // want: new local vars, both existing tools tables, no bean, - // plus store req and resp somewhere, plus existing broker - - WebContext wc = (WebContext) clone(); - wc._request = req; - wc._response = resp; - return wc; - } - catch (Exception e) - { - _log.error("Clone not supported on WebContext!"); - return null; - } - } - - /** * Clear a WebContext of it's non-shared data */ --- 83,96 ---- * in addition to the ordinary ContextTools loaded from config. */ ! public WebContext (Broker broker, HttpServletRequest req, HttpServletResponse resp) { super(broker); + _request = req; + _response = resp; _log = broker.getLog("WebContext"); } /** * Clear a WebContext of it's non-shared data */ *************** *** 125,138 **** _response = null; super.clear(); - } - - /** - * Reinitalized a WebContext for a new request - */ - public void reinitialize (HttpServletRequest req, HttpServletResponse resp) - { - clear(); - _request = req; - _response = resp; } --- 100,103 ---- |
From: <bri...@us...> - 2003-07-16 06:45:04
|
Update of /cvsroot/webmacro/webmacro/src/org/webmacro/util In directory sc8-pr-cvs1:/tmp/cvs-serv32064/src/org/webmacro/util Modified Files: Clock.java LogSystem.java WMEval.java Removed Files: ComponentMap.java IntStack.java SharedObject.java SharedReference.java ThreadScheduler.java UPool.java Log Message: More ripping out -- eliminate reference counting of Brokers, pooling of context and fastwriter; streamline Context; eliminate Clock thread hack; eliminate ascii fastwriter hack Index: Clock.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/util/Clock.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Clock.java 12 Jun 2003 00:47:48 -0000 1.5 --- Clock.java 16 Jul 2003 06:45:00 -0000 1.6 *************** *** 29,36 **** * This is an optimization. "System.currentTimeMillis()" is a relatively * slow method, and "new Date()" is an incredibly expensive operation. ! * This clock performs these operations at regular intervals and makes ! * the result of the calculations available. You can therefore use this ! * class to gain rapid access to the current time in situations where ! * it is good enough to have "close" to the current time. */ final public class Clock --- 29,34 ---- * This is an optimization. "System.currentTimeMillis()" is a relatively * slow method, and "new Date()" is an incredibly expensive operation. ! * Update: System.ctm is no longer all that slow; replaced with a version ! * that caches the Date but not the time. */ final public class Clock *************** *** 40,161 **** * Every tick interval the following variable is updated with the current system time */ ! static public volatile long TIME; /** * Date information */ - private static long dateTime = System.currentTimeMillis(); private static Date date = new Date(); - private static Object _lock = new Object(); - - /** - * The current date. This object is updated on the tick interval, - * but not faster than once per second. - */ - public static Date getDate () - { - synchronized (_lock) - { - if (_clock != null) - { - if ((TIME - dateTime) > 1000) - { - date = new Date(TIME); - } - } - else - { - // clock is not started yet - date = new Date(); - } - return date; - } - } - - /** - * The tick interval, how fast the clock updates the time. The default - * is once every 10 seconds. - */ - static private int tickInterval = 10000; - - /** - * The clock will tick at least this often. It may tick more often. - * Setting it to zero stops the clock. The actual tick interval used - * will be the smallest tick interval ever set. The tickInterval - * starts out as 10000 (ten seconds). - */ - static public void setTickInterval (int interval) - { - if (interval < 0) interval = 0; - - if ((tickInterval == 0) || (interval < tickInterval)) - { - tickInterval = interval; - synchronized (_clock) - { - _clock.notify(); - _clock.setName("clock:" + tickInterval); - } - } - } - /** ! * Set up the clock */ ! static private Thread _clock; ! ! static class ClockThread extends Thread ! { ! ! synchronized public void run () ! { ! while (!Thread.currentThread().interrupted()) ! { ! TIME = System.currentTimeMillis(); ! try ! { ! if (tickInterval == 0) ! wait(); ! else ! wait(tickInterval); ! } ! catch (InterruptedException e) ! { ! break; // terminate ! } ! } ! } ! } ! ! static private int _count; ! ! public static synchronized void startClient () ! { ! if (_count++ == 0) ! { ! _clock = new ClockThread(); ! _clock.setDaemon(true); ! _clock.setName("clock:" + tickInterval); ! _clock.start(); ! } ! } ! ! public static synchronized void stopClient () ! { ! if (--_count == 0) ! { ! _clock.interrupt(); ! _clock = null; ! } ! } ! ! public static void main (String arg[]) { ! setTickInterval(1000); ! while (true) ! { ! System.out.println(TIME); } } --- 38,59 ---- * Every tick interval the following variable is updated with the current system time */ ! static public long TIME = System.currentTimeMillis(); /** * Date information */ private static Date date = new Date(); /** ! * The current date. This object is updated not faster than once per second. */ ! public synchronized static Date getDate () { ! long time = System.currentTimeMillis(); ! if ((TIME - time) > 1000) { ! TIME = time; ! date = new Date(TIME); } + return date; } Index: LogSystem.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/util/LogSystem.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** LogSystem.java 12 Jun 2003 00:47:48 -0000 1.6 --- LogSystem.java 16 Jul 2003 06:45:00 -0000 1.7 *************** *** 79,83 **** } - private final static Map _instances = new HashMap(); private final static LogSystem _singleton; private final static Log _log; --- 79,82 ---- *************** *** 98,102 **** public static LogSystem getInstance () { ! return getInstance(null); } --- 97,101 ---- public static LogSystem getInstance () { ! return _singleton; } *************** *** 117,160 **** } - /** - * Return the log-system with the specified category - */ - public static LogSystem getInstance (String category) - { - synchronized (_instances) - { - if (category == null) return _singleton; - LogSystem ls = (LogSystem) _instances.get(category); - if (ls == null) - { - ls = new LogSystem(category); - _instances.put(category, ls); - } - return ls; - } - } - - /** - * Remove the specified LogSystem instance from the internal - * cache of LogSystems. - */ - public static void removeInstance (LogSystem instance) - { - synchronized (_instances) - { - if (_instances.containsValue(instance)) - { - for (Iterator itr = _instances.entrySet().iterator(); itr.hasNext();) - { - Map.Entry e = (Map.Entry) itr.next(); - if (e.getValue() == instance) - { - itr.remove(); - } - } - } - } - } - ///////////////////////////////////////////// --- 116,119 ---- *************** *** 165,169 **** final private Set _targets = new HashSet(); ! private LogSystem (String category) { _category = category; --- 124,128 ---- final private Set _targets = new HashSet(); ! public LogSystem (String category) { _category = category; *************** *** 324,341 **** } - /** - * Flush all log systems - */ - static public void flushAll () - { - _singleton.flush(); - Iterator i = _instances.values().iterator(); - while (i.hasNext()) - { - LogSystem ls = (LogSystem) i.next(); - ls.flush(); - } - } - /** --- 283,286 ---- *************** *** 363,367 **** l.error("2:testing error"); ! LogSystem.flushAll(); --- 308,312 ---- l.error("2:testing error"); ! LogSystem.getInstance().flush(); Index: WMEval.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/util/WMEval.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** WMEval.java 8 Jul 2003 19:48:45 -0000 1.13 --- WMEval.java 16 Jul 2003 06:45:00 -0000 1.14 *************** *** 233,237 **** { Template t = wm.getTemplate(templateName); ! String val = t.getString(context); if (out != null) { --- 233,237 ---- { Template t = wm.getTemplate(templateName); ! String val = t.evaluateAsString(context); if (out != null) { *************** *** 292,296 **** public String eval (Context context, Template rule) throws Exception { ! return rule.getString(context); } --- 292,296 ---- public String eval (Context context, Template rule) throws Exception { ! return rule.evaluateAsString(context); } *************** *** 309,313 **** { Template rule = wm.getTemplate(templateResourceFile); ! String value = rule.getString(context); // output the file if (outputFileName == null) --- 309,313 ---- { Template rule = wm.getTemplate(templateResourceFile); ! String value = rule.evaluateAsString(context); // output the file if (outputFileName == null) *************** *** 328,332 **** public void destroy () { - wm.destroy(); wm = null; rule = null; --- 328,331 ---- --- ComponentMap.java DELETED --- --- IntStack.java DELETED --- --- SharedObject.java DELETED --- --- SharedReference.java DELETED --- --- ThreadScheduler.java DELETED --- --- UPool.java DELETED --- |
From: <bri...@us...> - 2003-07-16 06:45:03
|
Update of /cvsroot/webmacro/webmacro/test/unit/org/webmacro In directory sc8-pr-cvs1:/tmp/cvs-serv32064/test/unit/org/webmacro Modified Files: TestMultipleInstances.java Log Message: More ripping out -- eliminate reference counting of Brokers, pooling of context and fastwriter; streamline Context; eliminate Clock thread hack; eliminate ascii fastwriter hack Index: TestMultipleInstances.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/test/unit/org/webmacro/TestMultipleInstances.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TestMultipleInstances.java 8 Jul 2003 19:48:45 -0000 1.7 --- TestMultipleInstances.java 16 Jul 2003 06:45:00 -0000 1.8 *************** *** 116,120 **** Broker b = wm.getBroker(); Template template = new StringTemplate(b, templateText); ! String output = template.getString(context); return output; } --- 116,120 ---- Broker b = wm.getBroker(); Template template = new StringTemplate(b, templateText); ! String output = template.evaluateAsString(context); return output; } |
Update of /cvsroot/webmacro/webmacro/src/org/webmacro In directory sc8-pr-cvs1:/tmp/cvs-serv32064/src/org/webmacro Modified Files: Broker.java Context.java ContextTool.java FastWriter.java Template.java WM.java WebMacro.java Removed Files: FilterTool.java Log Message: More ripping out -- eliminate reference counting of Brokers, pooling of context and fastwriter; streamline Context; eliminate Clock thread hack; eliminate ascii fastwriter hack Index: Broker.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/Broker.java,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** Broker.java 8 Jul 2003 19:48:44 -0000 1.36 --- Broker.java 16 Jul 2003 06:44:59 -0000 1.37 *************** *** 28,31 **** --- 28,32 ---- import java.io.*; import java.lang.ref.WeakReference; + import java.lang.reflect.Constructor; import java.net.MalformedURLException; import java.net.URL; *************** *** 82,89 **** private Map _functionMap = Collections.synchronizedMap(new HashMap()); ! /** Reference _count to detect unused brokers */ ! private int _count; ! /** our _key in the cache of brokers */ ! private Object _key; /* --- 83,89 ---- private Map _functionMap = Collections.synchronizedMap(new HashMap()); ! /** a local map for context tools */ ! private Map _tools = Collections.synchronizedMap(new HashMap()); ! /* *************** *** 173,177 **** { _name = name; ! _ls = LogSystem.getInstance(_name); _log = _ls.getLog("broker", "general object loader and configuration"); } --- 173,177 ---- { _name = name; ! _ls = new LogSystem(_name); _log = _ls.getLog("broker", "general object loader and configuration"); } *************** *** 229,233 **** } ! private class SettingHandler extends Settings.ListSettingHandler { --- 229,233 ---- } ! private class ProviderSettingHandler extends Settings.ListSettingHandler { *************** *** 247,250 **** --- 247,266 ---- } + private class ToolsSettingHandler extends Settings.ListSettingHandler + { + public void processSetting (String settingKey, String settingValue) + { + try + { + addTool(settingKey, settingValue, "Tool"); + } + catch (Exception e) + { + _log.error("Tool (" + settingValue + ") failed to load", e); + } + } + } + + /** * Constructors should call this after they've set up the properties *************** *** 296,300 **** // set up providers ! _config.processListSetting("Providers", new SettingHandler()); if (_providers.size() == 0) { --- 312,316 ---- // set up providers ! _config.processListSetting("Providers", new ProviderSettingHandler()); if (_providers.size() == 0) { *************** *** 303,306 **** --- 319,326 ---- } + // load tools + loadTools("Tools"); + loadTools("WebContextTools"); + eehClass = _config.getSetting("ExceptionHandler"); if (eehClass != null && !eehClass.equals("")) *************** *** 366,370 **** try { ! tmpl.getString(argContext); } catch (Exception e) --- 386,390 ---- try { ! tmpl.evaluateAsString(argContext); } catch (Exception e) *************** *** 422,426 **** register(WEBMACRO_PROPERTIES, b); } - b.startClient(); return b; } --- 442,445 ---- *************** *** 443,447 **** register(p, b); } - b.startClient(); return b; } --- 462,465 ---- *************** *** 465,469 **** } - b.startClient(); return b; } --- 483,486 ---- *************** *** 549,553 **** { BROKERS.put(key, new WeakReference(broker)); - broker._key = key; } --- 566,569 ---- *************** *** 562,566 **** if (ref != null) { ! return (Broker) ref.get(); } else --- 578,585 ---- if (ref != null) { ! Broker broker = (Broker) ref.get(); ! if (broker == null) ! BROKERS.remove(key); ! return broker; } else *************** *** 660,664 **** public Log getLog (String type, String description) { ! return _ls.getLog(type); } --- 679,683 ---- public Log getLog (String type, String description) { ! return _ls.getLog(type, description); } *************** *** 837,890 **** /** ! * Backwards compatible, calls get(String,String) ! * @deprecated call get(String,String) instead */ ! public final Object getValue (String type, String query) ! throws ResourceException ! { ! return get(type, query); ! } ! ! public synchronized void startClient () ! { ! if (_count++ == 0) { ! _log.info("starting clock"); ! Clock.startClient(); // start clock } ! } ! ! public synchronized void stopClient () ! { ! if (--_count == 0) { ! shutdown(); ! // make sure to cleanup the logging system ! // if no more references to this Broker are around ! LogSystem.removeInstance(_ls); } } /** ! * Shut down the broker */ ! public synchronized void shutdown () { ! _log.notice("shutting down"); ! ! Enumeration e = _providers.elements(); ! while (e.hasMoreElements()) ! { ! Provider pr = (Provider) e.nextElement(); ! _log.info("stopping: " + pr); ! pr.destroy(); ! } ! _providers.clear(); ! _log.info("stopping clock"); ! Clock.stopClient(); ! _ls.flush(); ! BROKERS.remove(this._key); } --- 856,968 ---- /** ! * Attempts to instantiate the tool using two different constructors ! * until one succeeds, in the following order: ! * <ul> ! * <li>new MyTool(String key)</li> ! * <li>new MyTool()</li> ! * </ul> ! * The key is generally the unqualified class name of the tool minus the ! * "Tool" suffix, e.g., "My" in the example above ! * The settings are any configured settings for this tool, i.e, settings ! * prefixed with the tool's key. ! * <br> ! * NOTE: keats - 25 May 2002, no tools are known to use the settings mechanism. ! * We should create an example of this and test it, or abolish this capability! ! * Abolished -- BG */ ! private void addTool(String toolName, String className, String suffix) { ! Class c; ! try { ! c = classForName(className); } ! catch (ClassNotFoundException e) { ! _log.warning("Context: Could not locate class for context tool " ! + className); ! return; ! } ! if (toolName == null || toolName.equals("")) ! { ! toolName = className; ! int start = 0; ! int end = toolName.length(); ! int lastDot = toolName.lastIndexOf('.'); ! if (lastDot != -1) ! { ! start = lastDot + 1; ! } ! if (toolName.endsWith(suffix)) ! { ! end -= suffix.length(); ! } ! toolName = toolName.substring(start, end); ! } ! Constructor ctor = null; ! Constructor[] ctors = c.getConstructors(); ! Class[] parmTypes = null; ! Object instance = null; ! ! // check for 1 arg (String) constructor ! for (int i = 0; i < ctors.length; i++) ! { ! parmTypes = ctors[i].getParameterTypes(); ! if (parmTypes.length == 1 && parmTypes[0].equals(String.class)) ! { ! ctor = ctors[i]; ! Object[] args = {toolName}; ! try ! { ! instance = ctor.newInstance(args); ! } ! catch (Exception e) ! { ! _log.error("Failed to instantiate tool " ! + toolName + " of class " + className + " using constructor " ! + ctor.toString(), e); ! } ! } } + if (instance == null) + { + // try no-arg constructor + try + { + instance = c.newInstance(); + } + catch (Exception e) + { + _log.error("Unable to construct tool " + toolName + " of class " + className, e); + return; + } + } + _tools.put(toolName, instance); + _log.info("Registered ContextTool " + toolName); + } + + /** Fetch a tool */ + public ContextTool getTool(Object toolName) { + return (ContextTool) _tools.get(toolName); } /** ! * Load the context tools listed in the supplied string. See ! * the ComponentMap class for a description of the format of ! * this string. */ ! protected final void loadTools (String keyName) { ! getSettings().processListSetting(keyName, new ToolsSettingHandler()); ! } ! /** ! * Backwards compatible, calls get(String,String) ! * @deprecated call get(String,String) instead ! */ ! public final Object getValue (String type, String query) ! throws ResourceException ! { ! return get(type, query); } Index: Context.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/Context.java,v retrieving revision 1.61 retrieving revision 1.62 diff -C2 -d -r1.61 -r1.62 *** Context.java 12 Jun 2003 00:47:43 -0000 1.61 --- Context.java 16 Jul 2003 06:44:59 -0000 1.62 *************** *** 24,36 **** package org.webmacro; import org.webmacro.engine.EvaluationExceptionHandler; import org.webmacro.engine.FunctionCall; import org.webmacro.engine.MethodWrapper; - import org.webmacro.util.Pool; - import org.webmacro.util.Settings; - import org.webmacro.util.SubSettings; - - import java.lang.reflect.Constructor; - import java.util.*; /** --- 24,32 ---- package org.webmacro; + import java.util.*; + import org.webmacro.engine.EvaluationExceptionHandler; import org.webmacro.engine.FunctionCall; import org.webmacro.engine.MethodWrapper; /** *************** *** 59,72 **** public class Context implements Map, Cloneable { ! private Broker _broker; ! private HashMap _tools = new HashMap(); ! private HashMap _funcs = new HashMap(); ! private Log _log; - private HashMap _initializedTools = new HashMap(); private EvaluationExceptionHandler _eeHandler; private Map _variables = new HashMap(); - private Pool _contextPool = null; private TemplateEvaluationContext _teContext --- 55,65 ---- public class Context implements Map, Cloneable { ! private final Broker _broker; ! private final Log _log; ! private HashMap _funcs = null; // lazy initialization private EvaluationExceptionHandler _eeHandler; private Map _variables = new HashMap(); private TemplateEvaluationContext _teContext *************** *** 76,97 **** = org.webmacro.engine.UndefinedMacro.getInstance(); - // Adding new tools to the context - private static final Class[] _ctorArgs1 = { - java.lang.String.class, - org.webmacro.util.Settings.class - }; - private static final Class[] _ctorArgs2 = {java.lang.String.class}; - private org.webmacro.profile.Profile _prof = null; /** ! * Create a new Context relative to the supplied broker */ ! public Context (Broker broker) ! { ! this(broker, true); } ! protected Context (Broker broker, boolean loadTools) { _prof = broker.newProfile(); --- 69,85 ---- = org.webmacro.engine.UndefinedMacro.getInstance(); private org.webmacro.profile.Profile _prof = null; /** ! * Create a new Context relative to the default WM instance */ ! public Context() throws InitException { ! this(Broker.getBroker()); } ! /** ! * Create a new Context relative to the supplied broker ! */ ! public Context (Broker broker) { _prof = broker.newProfile(); *************** *** 106,111 **** _broker = broker; _log = broker.getLog("context", "property and evaluation errors"); - if (loadTools) - loadTools("ContextTools"); if (_prof != null) { --- 94,97 ---- *************** *** 123,151 **** } - private class SettingHandler extends Settings.ListSettingHandler - { - public void processSetting (String settingKey, String settingValue) - { - try - { - addTool(settingKey, settingValue, "Tool"); - } - catch (Exception e) - { - _log.error("Provider (" + settingValue + ") failed to load", e); - } - } - } - - /** - * Load the context tools listed in the supplied string. See - * the ComponentMap class for a description of the format of - * this string. - */ - protected final void loadTools (String keyName) - { - _broker.getSettings().processListSetting(keyName, new SettingHandler()); - } - /** * See cloneContext(). Subclasses should override cloneContext() --- 109,112 ---- *************** *** 179,183 **** c._prof = _broker.newProfile(); c.startTiming("Context life"); // stops in clear() - c._initializedTools = (HashMap) _initializedTools.clone(); c._teContext = new TemplateEvaluationContext(); if (_variables instanceof HashMap) --- 140,143 ---- *************** *** 198,205 **** /** * Clear the context so that it can be used for another request. - * This does not meant hat the context is completely empty: it - * may have been configured with some initial state, such as - * a collection of tools, that are to be re-used. But all local - * variables and other local structures will be cleared. * <p> * Subclasses may override the clear method and add functionality --- 158,161 ---- *************** *** 209,220 **** { _variables.clear(); - Iterator i = _initializedTools.entrySet().iterator(); - while (i.hasNext()) - { - Map.Entry m = (Map.Entry) i.next(); - ContextTool ct = (ContextTool) m.getKey(); - ct.destroy(m.getValue()); - } - _initializedTools.clear(); _eeHandler = null; if (_prof != null) --- 165,168 ---- *************** *** 303,307 **** if (ret == null && !_variables.containsKey(name)) { ! Object tool = _tools.get(name); if (tool != null) { --- 251,255 ---- if (ret == null && !_variables.containsKey(name)) { ! Object tool = _broker.getTool(name); if (tool != null) { *************** *** 311,315 **** ret = ct.init(this); put(name, ret); - _initializedTools.put(ct, ret); } catch (PropertyException e) --- 259,262 ---- *************** *** 322,326 **** FunctionCall fc = (FunctionCall) name; String fname = fc.getName(); ! MethodWrapper func = (MethodWrapper) _funcs.get(fname); if (func == null) { --- 269,276 ---- FunctionCall fc = (FunctionCall) name; String fname = fc.getName(); ! MethodWrapper func = null; ! if (_funcs != null) { ! func = (MethodWrapper) _funcs.get(fname); ! } if (func == null) { *************** *** 356,360 **** try { - //return internalGet(name); Object o = internalGet(name); if (o == UNDEF) --- 306,309 ---- *************** *** 395,398 **** --- 344,349 ---- { MethodWrapper func = wrapMethod(instance, methodName); + if (_funcs == null) + _funcs = new HashMap(); _funcs.put(name, func); } *************** *** 541,588 **** } - private static String makeName (Object[] names) - { - StringBuffer buf = new StringBuffer(); - buf.append("$("); - for (int i = 0; i < names.length; i++) - { - if (i != 0) - { - buf.append("."); - } - buf.append((names[i] != null) ? names[i] : "NULL"); - } - buf.append(")"); - return buf.toString(); - } - - /** - * Assign the object pool that this context should return to - * when its recycle() method is called. - */ - public final void setPool (Pool contextPool) - { - _contextPool = contextPool; - } - - public final Pool getPool () - { - return _contextPool; - } - - /** - * Return the context to the object pool assigned via setPool(), - * if any. This method implicitly calls clear(). - */ - public final void recycle () - { - clear(); - if (_contextPool != null) - { - _contextPool.put(this); - } - } - - /** * Set the underlying Map object. The supplied Map will subsequently --- 492,495 ---- *************** *** 674,791 **** } - /** - * Attempts to instantiate the tool using three different constructors - * until one succeeds, in the following order: - * <ul> - * <li>new MyContextTool(String key, Settings settings)</li> - * <li>new MyTool(String key)</li> - * <li>new MyTool()</li> - * </ul> - * The key is generally the unqualified class name of the tool minus the - * "Tool" suffix, e.g., "My" in the example above - * The settings are any configured settings for this tool, i.e, settings - * prefixed with the tool's key. - * <br> - * NOTE: keats - 25 May 2002, no tools are known to use the settings mechanism. - * We should create an example of this and test it, or abolish this capability! - */ - private void addTool (String key, String className, String suffix) - { - Class c; - try - { - c = _broker.classForName(className); - } - catch (ClassNotFoundException e) - { - _log.warning("Context: Could not locate class for context tool " - + className); - return; - } - if (key == null || key.equals("")) - { - key = className; - int start = 0; - int end = key.length(); - int lastDot = key.lastIndexOf('.'); - if (lastDot != -1) - { - start = lastDot + 1; - } - if (key.endsWith(suffix)) - { - end -= suffix.length(); - } - key = key.substring(start, end); - } - - Constructor ctor = null; - Constructor[] ctors = c.getConstructors(); - Class[] parmTypes = null; - Object instance = null; - - // check for 2 arg constructor - for (int i = 0; i < ctors.length; i++) - { - parmTypes = ctors[i].getParameterTypes(); - if (parmTypes.length == 2 - && parmTypes[0].equals(_ctorArgs1[0]) - && parmTypes[1].equals(_ctorArgs1[1])) - { - ctor = ctors[i]; - Object[] args = {key, new SubSettings(_broker.getSettings(), key)}; - try - { - instance = ctor.newInstance(args); - } - catch (Exception e) - { - _log.error("Failed to instantiate tool " - + key + " of class " + className + " using constructor " - + ctor.toString(), e); - } - } - } - if (instance == null) - { - // check for 1 arg constructor - for (int i = 0; i < ctors.length; i++) - { - parmTypes = ctors[i].getParameterTypes(); - if (parmTypes.length == 1 && parmTypes[0].equals(_ctorArgs1[0])) - { - ctor = ctors[i]; - Object[] args = {key}; - try - { - instance = ctor.newInstance(args); - } - catch (Exception e) - { - _log.error("Failed to instantiate tool " - + key + " of class " + className + " using constructor " - + ctor.toString(), e); - } - } - } - } - if (instance == null) - { - // try no-arg constructor - try - { - instance = c.newInstance(); - } - catch (Exception e) - { - _log.error("Unable to construct tool " + key + " of class " + className, e); - return; - } - } - _tools.put(key, instance); - _log.info("Registered ContextTool " + key); - } - ////////////////////////////////////////////////////////////// --- 581,585 ---- Index: ContextTool.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/ContextTool.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ContextTool.java 12 Jun 2003 00:47:44 -0000 1.8 --- ContextTool.java 16 Jul 2003 06:44:59 -0000 1.9 *************** *** 40,49 **** public Object init (Context c) throws PropertyException; - /** - * At the end of processing this method will be called to - * return the object generated by init(), in case it needs - * to be recycled or otherwise cleaned up. - */ - public void destroy (Object o); - } --- 40,42 ---- Index: FastWriter.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/FastWriter.java,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** FastWriter.java 8 Jul 2003 19:48:44 -0000 1.30 --- FastWriter.java 16 Jul 2003 06:44:59 -0000 1.31 *************** *** 24,36 **** package org.webmacro; import org.webmacro.util.ByteBufferOutputStream; import org.webmacro.util.Encoder; import org.webmacro.util.EncoderProvider; - import org.webmacro.util.Pool; - - import java.io.*; - import java.util.ArrayList; - import java.util.Hashtable; - import java.util.List; --- 24,32 ---- package org.webmacro; + import java.io.*; + import org.webmacro.util.ByteBufferOutputStream; import org.webmacro.util.Encoder; import org.webmacro.util.EncoderProvider; *************** *** 42,59 **** * call reset(). You can access the output by one of several * methods: toString(), toByteArray(), or writeTo(OutputStream) - * <li> you can turn off unicode conversion by calling setAsciiHack() * <li> you can use a unicode conversion cache by calling writeStatic() * <li> you can get the contents written to the FastWriter back * as an array of bytes INSTEAD of writing to the output stream * </ul> - * Note that if you turn on the asciiHack and then write non-ASCII - * data the output will be mangled. * <p> * <b>Note that the FastWriter requires an explicit flush</b> * <p> - * If you re-use a FastWriter you must re-use it in a context which - * uses the SAME unicode conversion. The caches and internal data - * structures which the FastWriter allocates are tied to the - * encoding it was created with. * * @author Marcel Huijkman --- 38,48 ---- *************** *** 89,93 **** private final int DEFAULT_BUFFER_SIZE; - private final int MAX_POOL_SIZE; private final String _encoding; // what encoding we use private final Writer _bwriter; --- 78,81 ---- *************** *** 97,114 **** private OutputStream _out; - /** _open is true iff the FW has been dispensed to a user and not - * returned to the pool. */ - private boolean _open = true; - - private byte[] _buf = new byte[512]; - private char[] _cbuf = new char[512]; - - private boolean _encodeProperly; // are we in fast mode? private boolean _buffered; - private static final Hashtable WRITERCACHE = new Hashtable(); - private Pool _myPool = null; - /** * Create a FastWriter to the target outputstream. You must specify --- 85,91 ---- *************** *** 119,123 **** throws UnsupportedEncodingException { - MAX_POOL_SIZE = broker.getSettings().getIntegerSetting("FastWriter.MaxPoolSize", 10); DEFAULT_BUFFER_SIZE = broker.getSettings().getIntegerSetting("FastWriter.DefaultBufferSize", 4096); _encoding = hackEncoding(encoding); --- 96,99 ---- *************** *** 135,139 **** } - _encodeProperly = true; _buffered = false; --- 111,114 ---- *************** *** 199,228 **** /** - * Ordinarily an expensive char-to-byte routine is used to convert - * strings and char[]'s to byte format. If you know that your data - * is going to be ASCII only for some number of writes, turn on - * this AsciiHack and then write the ASCII data. It's much faster. - * Remember to turn the AsciiHack off before writing true Unicode - * characters, otherwise they'll be mangled. - */ - public void setAsciiHack (boolean on) - { - if (_buffered) - { - bflush(); - } - _encodeProperly = !on; - } - - /** - * Returns true if we are mangling the unicode conversion in an - * attempt to eek out a bit of extra efficiency. - */ - public boolean getAsciiHack () - { - return !_encodeProperly; - } - - /** * Write characters to the output stream performing slow unicode * conversion unless AsciiHack is on. --- 174,177 ---- *************** *** 230,294 **** public void write (char[] cbuf) throws java.io.IOException { ! if (_encodeProperly) ! { ! _bwriter.write(cbuf, 0, cbuf.length); ! _buffered = true; ! } ! else ! { ! int len = cbuf.length; ! if (_buf.length < len) ! { ! _buf = new byte[len]; ! } ! for (int i = 0; i < len; i++) ! { ! _buf[i] = (byte) cbuf[i]; ! } ! _bstream.write(_buf, 0, len); ! } } /** * Write characters to to the output stream performing slow unicode ! * conversion unless the AsciiHack is on. */ public void write (char[] cbuf, int offset, int len) throws java.io.IOException { ! if (_encodeProperly) ! { ! _bwriter.write(cbuf, offset, len); ! _buffered = true; ! } ! else ! { ! if (_buf.length < len) ! { ! _buf = new byte[len]; ! } ! int end = offset + len; ! for (int i = offset; i < end; i++) ! { ! _buf[i] = (byte) cbuf[i]; ! } ! _bstream.write(_buf, 0, len); ! } } /** * Write a single character, performing slow unicode conversion - * unless AsciiHack is on. */ public void write (int c) throws java.io.IOException { ! if (_encodeProperly) ! { ! _bwriter.write(c); ! _buffered = true; ! } ! else ! { ! _bstream.write((byte) c); ! } } --- 179,203 ---- public void write (char[] cbuf) throws java.io.IOException { ! _bwriter.write(cbuf, 0, cbuf.length); ! _buffered = true; } /** * Write characters to to the output stream performing slow unicode ! * conversion. */ public void write (char[] cbuf, int offset, int len) throws java.io.IOException { ! _bwriter.write(cbuf, offset, len); ! _buffered = true; } /** * Write a single character, performing slow unicode conversion */ public void write (int c) throws java.io.IOException { ! _bwriter.write(c); ! _buffered = true; } *************** *** 310,330 **** } ! if (_encodeProperly) ! { ! _bwriter.write(_cbuf, 0, len); ! _buffered = true; ! } ! else ! { ! if (_buf.length < len) ! { ! _buf = new byte[len]; ! } ! for (int i = 0; i < len; i++) ! { ! _buf[i] = (byte) _cbuf[i]; ! } ! _bstream.write(_buf, 0, len); ! } } --- 219,224 ---- } ! _bwriter.write(_cbuf, 0, len); ! _buffered = true; } *************** *** 345,365 **** } ! if (_encodeProperly) ! { ! _bwriter.write(_cbuf, 0, len); ! _buffered = true; ! } ! else ! { ! if (_buf.length < len) ! { ! _buf = new byte[len]; ! } ! for (int i = 0; i < len; i++) ! { ! _buf[i] = (byte) _cbuf[i]; ! } ! _bstream.write(_buf, 0, len); ! } } --- 239,244 ---- } ! _bwriter.write(_cbuf, 0, len); ! _buffered = true; } *************** *** 520,524 **** _bstream.reset(); _out = out; - _open = true; } --- 399,402 ---- *************** *** 531,545 **** throws UnsupportedEncodingException { - FastWriter fw; - Pool p = (Pool) WRITERCACHE.get(encoding); - if (p != null) - { - fw = (FastWriter) p.get(); - if (fw != null) - { - fw.reset(out); - return fw; - } - } return new FastWriter(broker, out, encoding); } --- 409,412 ---- *************** *** 580,589 **** } - /** - * Return the FastWriter to the queue for later re-use. You must - * not use the FastWriter after this call. Calling close() - * returns the FastWriter to the pool. If you don't want to - * return it to the pool just discard it without a close(). - */ public void close () throws IOException { --- 447,450 ---- *************** *** 594,655 **** _out = null; } - if (_open) - { - _open = false; - if (_myPool == null) - { - // get/create the pool this FW should be using - _myPool = (Pool) WRITERCACHE.get(_encoding); - if (_myPool == null) - { - _myPool = new FWPool(MAX_POOL_SIZE); - WRITERCACHE.put(_encoding, _myPool); - } - } - _myPool.put(this); - } } } - /** - * A simple <b>synchronized</b> pool used only by FastWriter - */ - class FWPool implements Pool - { - - private final List _pool; - private final int _maxSize; - private volatile int _size = 0; - - FWPool (int maxSize) - { - _maxSize = maxSize; - _pool = new ArrayList(maxSize); - } - - public Object get () - { - Object obj = null; - synchronized (_pool) - { - if (_size > 0) - { - obj = _pool.remove(0); - _size--; - } - } - return obj; - } - - public void put (Object fw) - { - if (_size < _maxSize) - { // not rqrd to be t.s. perfect - synchronized (_pool) - { - _pool.add(fw); - _size++; - } - } - } - } --- 455,459 ---- Index: Template.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/Template.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Template.java 8 Jul 2003 19:48:44 -0000 1.15 --- Template.java 16 Jul 2003 06:44:59 -0000 1.16 *************** *** 99,106 **** throws PropertyException, IOException; ! public String getString(Context context) throws PropertyException; ! public byte[] getBytes(String encoding, Context context) throws PropertyException; } --- 99,106 ---- throws PropertyException, IOException; ! public String evaluateAsString(Context context) throws PropertyException; ! public byte[] evaluateAsBytes(String encoding, Context context) throws PropertyException; } Index: WM.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/WM.java,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** WM.java 8 Jul 2003 19:48:44 -0000 1.42 --- WM.java 16 Jul 2003 06:44:59 -0000 1.43 *************** *** 24,38 **** package org.webmacro; ! import org.webmacro.servlet.ServletBroker; ! import org.webmacro.servlet.WebContext; ! import org.webmacro.util.Pool; ! import org.webmacro.util.ScalablePool; ! import javax.servlet.Servlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; ! import java.io.OutputStream; ! import java.io.UnsupportedEncodingException; ! import java.util.Properties; --- 24,35 ---- package org.webmacro; ! import java.io.*; ! import java.util.*; import javax.servlet.Servlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; ! ! import org.webmacro.servlet.ServletBroker; ! import org.webmacro.servlet.WebContext; *************** *** 49,68 **** { - final private Context _context; - private WebContext _webContext = null; - // INIT METHODS--MANAGE ACCESS TO THE BROKER final private Broker _broker; // cache for rapid access - private boolean _alive = false; // so we don't unload twice - final private Provider _tmplProvider; final private Provider _urlProvider; final private Log _log; - final private ThreadLocal _contextCache; - final private ThreadLocal _webContextCache; - /** --- 46,57 ---- *************** *** 130,153 **** _broker = broker; - _alive = true; _log = _broker.getLog("wm", "WebMacro instance lifecycle"); ! _log.notice("new " + this ! + " v" + WebMacro.VERSION); ! _context = new Context(_broker); ! _contextCache = new ThreadLocal() ! { ! public Object initialValue () ! { ! return new ScalablePool(); ! } ! }; ! _webContext = new WebContext(_broker); ! _webContextCache = new ThreadLocal() ! { ! public Object initialValue () ! { ! return new ScalablePool(); ! } ! }; try --- 119,124 ---- _broker = broker; _log = _broker.getLog("wm", "WebMacro instance lifecycle"); ! _log.notice("new " + this + " v" + WebMacro.VERSION); try *************** *** 168,193 **** } - /** - * Call this method when you are finished with WebMacro. If you - * don't call this method, the Broker and all of WebMacro's caches - * may not be properly shut down, potentially resulting in loss of - * data, and wasted memory. This method is called in the - * finalizer, but it is best to call it as soon as you know you - * are done with WebMacro. - * <p> - * After a call to destroy() attempts to use this object may yield - * unpredicatble results. - */ - final public void destroy () - { - if (_alive) - { - _alive = false; - _webContext = null; - _log.info("shutdown " + this); - _broker.stopClient(); - } - } - public String toString () { --- 139,142 ---- *************** *** 195,226 **** } - /** - * This message returns false until you destroy() this object, - * subsequently it returns true. Do not attempt to use this object - * after it has been destroyed. */ - final public boolean isDestroyed () - { - return !_alive; - } - - - /** - * You should never call this method, on any object. Leave it up - * to the garbage collector. If you want to shut this object down, - * call destroy() instead. If you subclass this message, be sure - * to call super.finalize() since this is one of the cases where - * it matters. */ - protected void finalize () throws Throwable - { - try - { - destroy(); - } - finally - { - super.finalize(); - } - } - /** --- 144,147 ---- *************** *** 260,301 **** /** ! * Instantiate a new context from a pool. This method is more ! * efficient, in terms of object creation, than creating a ! * Context directly. The Context will return to the pool ! * when Context.recycle() is called. */ final public Context getContext () { ! Pool cpool = (Pool) _contextCache.get(); ! Context c = (Context) cpool.get(); ! if (c == null) ! { ! c = (Context) _context.clone(); ! c.setPool(cpool); ! } ! else ! c.clear(); ! return c; } /** ! * Instantiate a new webcontext from a pool. This method is more ! * efficient, in terms of object creation, than creating a ! * WebContext object directly. The WebContext will return to ! * the pool when WebContext.recycle() is called. */ final public WebContext getWebContext (HttpServletRequest req, HttpServletResponse resp) { ! Pool cpool = (Pool) _webContextCache.get(); ! WebContext c = (WebContext) cpool.get(); ! if (c == null) ! { ! c = _webContext.newInstance(req, resp); ! c.setPool(cpool); ! } ! else ! c.reinitialize(req, resp); ! return c; } --- 181,198 ---- /** ! * Instantiate a new context. */ final public Context getContext () { ! return new Context(_broker); } /** ! * Instantiate a new webcontext. */ final public WebContext getWebContext (HttpServletRequest req, HttpServletResponse resp) { ! return new WebContext(_broker, req, resp); } Index: WebMacro.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/WebMacro.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** WebMacro.java 12 Jun 2003 00:47:44 -0000 1.15 --- WebMacro.java 16 Jul 2003 06:44:59 -0000 1.16 *************** *** 50,71 **** /** - * Call this method when you are finished with WebMacro. If you don't - * call this method, the Broker and all of WebMacro's caches may not - * be properly shut down, potentially resulting in loss of data, and - * wasted memory. This method is called in the finalizer, but it is - * best to call it as soon as you know you are done with WebMacro. - * <p> After a call to destroy() attempts to use this object may yield - * unpredicatble results. - */ - public void destroy (); - - /** - * This message returns false until you destroy() this object, - * subsequently it returns true. Do not attempt to use this object - * after it has been destroyed. - */ - public boolean isDestroyed (); - - /** * This object is used to access components that have been plugged * into WebMacro; it is shared between all instances of this class and --- 50,53 ---- *************** *** 92,95 **** --- 74,78 ---- * @throws java.io.UnsupportedEncodingException if the encoding type * specified is not supported by your JVM. + * @deprecated */ public FastWriter getFastWriter (OutputStream out, String enctype) --- FilterTool.java DELETED --- |
From: <bri...@us...> - 2003-07-16 06:45:03
|
Update of /cvsroot/webmacro/webmacro/src/org/webmacro/parser In directory sc8-pr-cvs1:/tmp/cvs-serv32064/src/org/webmacro/parser Modified Files: WMParser.java Log Message: More ripping out -- eliminate reference counting of Brokers, pooling of context and fastwriter; streamline Context; eliminate Clock thread hack; eliminate ascii fastwriter hack Index: WMParser.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/parser/WMParser.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** WMParser.java 12 Jun 2003 00:47:46 -0000 1.9 --- WMParser.java 16 Jul 2003 06:45:00 -0000 1.10 *************** *** 27,37 **** package org.webmacro.parser; import org.webmacro.Broker; import org.webmacro.engine.BlockBuilder; import org.webmacro.engine.Parser; - import org.webmacro.util.ScalablePool; - - import java.io.IOException; - import java.io.Reader; public class WMParser implements Parser --- 27,35 ---- package org.webmacro.parser; + import java.io.*; + import org.webmacro.Broker; import org.webmacro.engine.BlockBuilder; import org.webmacro.engine.Parser; public class WMParser implements Parser *************** *** 39,43 **** private final Broker _broker; - private final ScalablePool _parserCache = new ScalablePool(); public WMParser (Broker b) --- 37,40 ---- *************** *** 47,51 **** } - // Parser Interface --- 44,47 ---- *************** *** 72,80 **** try { ! parser = (WMParser_impl) _parserCache.get(); ! if (parser != null) ! parser.ReInit(name, in); ! else ! parser = new WMParser_impl(_broker, name, in); try --- 68,72 ---- try { ! parser = new WMParser_impl(_broker, name, in); try *************** *** 94,102 **** { throw new org.webmacro.engine.ParseException("Parse Exception", e); - } - finally - { - if (parser != null) - _parserCache.put(parser); } --- 86,89 ---- |
From: <bri...@us...> - 2003-07-16 06:45:03
|
Update of /cvsroot/webmacro/webmacro/src/org/webmacro/engine In directory sc8-pr-cvs1:/tmp/cvs-serv32064/src/org/webmacro/engine Modified Files: BuildContext.java WMTemplate.java Log Message: More ripping out -- eliminate reference counting of Brokers, pooling of context and fastwriter; streamline Context; eliminate Clock thread hack; eliminate ascii fastwriter hack Index: BuildContext.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/engine/BuildContext.java,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** BuildContext.java 12 Jun 2003 00:47:45 -0000 1.26 --- BuildContext.java 16 Jul 2003 06:45:00 -0000 1.27 *************** *** 49,53 **** public BuildContext (Broker b) { ! super(b, false); } --- 49,53 ---- public BuildContext (Broker b) { ! super(b); } Index: WMTemplate.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/engine/WMTemplate.java,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** WMTemplate.java 8 Jul 2003 19:48:44 -0000 1.48 --- WMTemplate.java 16 Jul 2003 06:45:00 -0000 1.49 *************** *** 240,244 **** * then this method will return a null string. */ ! public final String getString (Context context) throws PropertyException { try --- 240,244 ---- * then this method will return a null string. */ ! public final String evaluateAsString (Context context) throws PropertyException { try *************** *** 263,267 **** * then this method will return a null string. */ ! public final byte[] getBytes (String encoding, Context context) throws PropertyException { try --- 263,267 ---- * then this method will return a null string. */ ! public final byte[] evaluateAsBytes (String encoding, Context context) throws PropertyException { try |
From: <bri...@us...> - 2003-07-16 06:45:02
|
Update of /cvsroot/webmacro/webmacro/examples In directory sc8-pr-cvs1:/tmp/cvs-serv32064/examples Modified Files: Standalone.java Log Message: More ripping out -- eliminate reference counting of Brokers, pooling of context and fastwriter; streamline Context; eliminate Clock thread hack; eliminate ascii fastwriter hack Index: Standalone.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/examples/Standalone.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Standalone.java 8 Jul 2003 19:48:44 -0000 1.7 --- Standalone.java 16 Jul 2003 06:44:59 -0000 1.8 *************** *** 83,90 **** */ public void destroy() { ! if (_wm != null) { ! _wm.destroy(); ! _wm = null; ! } } --- 83,87 ---- */ public void destroy() { ! _wm = null; } |