struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jacob Hookom" <hooko...@uwec.edu>
Subject RE: why only one instance of Action class (Action class thread safety)
Date Mon, 05 May 2003 06:06:03 GMT
Actions follow the same constraints as the Servlet API such with thread
safety-- see HttpServlet (not to mention that I believe they are getting rid
of the single thread HttpServlet model all together with the API).


| -----Original Message-----
| From: Weigen Liang [mailto:weigen@etix.com]
| Sent: Monday, May 05, 2003 12:49 AM
| To: struts-dev@jakarta.apache.org
| Cc: weigen@etix.com
| Subject: why only one instance of Action class (Action class thread
| safety)
| 
| The current Struts framework creates only one instance for each Action
| class, and uses that instance to serve all the relevant requests. This
| makes the Action class thread safety a big issue for newer users of the
| Struts framework. The struts user mailing list has many, many such
| questions from Struts users. This is similar to servlet itself. The
| servlet spec has the SingleThreadModel to "try" to solve this problem,
| but as we know, this does not really work.
| 
| If one instance of Action object is created for EACH request, then we
| would not have this threading issue. This instance would be tied to a
| request object and a response object, and has life span of that
| particular request. The class would be like this:
| 
| public class Action {
|    public Action(ActionMapping mapping, ActionForm form,
|       ServletRequest request, ServletResponse response) {
|       ...
|    }
| 
|    public ActionForward execute() {
|       ...
|    }
| 
|    private ActionMapping mapping;
|    private ActionForm form;
|    private ServletRequest request;
|    private ServletResponse response;
| 
|    // plus other instance variable for this particular request
|    ...
| }
| 
| 
| Considering that a significant percentage of Struts users have limited
| understanding of thread safety, removal of such a concern from the
| framework would certainly help the users.
| 
| 
| Weigen
| 
| 
| 
| 
| 
| ---------------------------------------------------------------------
| To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
| For additional commands, e-mail: struts-dev-help@jakarta.apache.org
| 
| ---
| Incoming mail is certified Virus Free.
| Checked by AVG anti-virus system (http://www.grisoft.com).
| Version: 6.0.476 / Virus Database: 273 - Release Date: 4/24/2003
| 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.476 / Virus Database: 273 - Release Date: 4/24/2003
 


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org


Mime
View raw message