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 ----
|