From: Eric B. R. <eb...@tc...> - 2005-12-08 14:11:01
|
On Dec 8, 2005, at 6:00 AM, Marc Palmer wrote: > No, I think you're right. However I have consistently seen in my > previous client's app where we used the JSP taglib, that every page > using the JSP taglib cause ned WebMacro "init" logging to come out. You see this on every page request, or only when you've changed a JSP? If the classloader dumps, WM will re-init(). Also note that (I think!) the broker instances are shared based on the constructor used for the new WM() instance. So if you're using the ctor that takes a Servlet (and every JSP *is* a Servlet), then you probably are getting a new WM instance per JSP page. > Well there is, because of race conditions initializing the shared > static instance, surely. public class GlobalWM { private static WebMacro _wm; public static synchronized WM getInstance() { if (_wm == null) _wm = new WM(); return _wm; } } that's about all you need to do. Just call that method once per JSP. Yeah, all requests will serialize around the "getInstance()" method, but the impact of that should be dwarfed by your actual page processing. > My concern was basically that we'd need to sync on every access to > the shared WM instance field. I know there are ways around this - > I'm canvassing for favourite solutions, be they in concurrent or > using "volatile" etc. Well, you do. But you only need to access it once per JSP. Once you've got the WM instance in your JSP WebMacro will make sure its innards are sync'd properly. eric > > Cheers > > > > ------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. Do you grep through > log files > for problems? Stop! Download the new AJAX search engine that makes > searching your log files as easy as surfing the web. DOWNLOAD > SPLUNK! > http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click > _______________________________________________ > Webmacro-devel mailing list > Web...@li... > https://lists.sourceforge.net/lists/listinfo/webmacro-devel |