struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ted Husted <hus...@apache.org>
Subject Re: Why only one instance of Action?
Date Thu, 01 May 2003 11:18:04 GMT
Originally, it was because object creates were expensive and the
framework was being parsimonious.

The idea is that the ActionForm holds the data specific to the request,
and the Action is a thread-safe process that acts on that data. The
ActionForm, and other members in the process/execute signature,
encapsulate the Action STATE. What's left in the Action is code that
services that state.

In a future release of Struts, it seems like a valid idea to also have
Actions that are created for each request. So instead of simply looking
the Action up in a collection, there could be an intelligent factory
that would decide whether to create or reuse. But that seems like more
than a patch and may be the stuff of Struts 2.0.

Another good approach is to have the Action create your own business
object for each request. Worrying too much about state is a signal that
there may be too much business code in the Action, and it's time to
refactor some of that into another object.

-Ted.

Hajime Ohtoshi wrote:
> Hi, this is Hajime.
> 
> Simple question.
> 
> Struts seems to create only one instance of Action for each 
> request when I make first call to this request.
> 
> After first call, struts seems to re-use the instance of Action 
> made at the first time to perform the request.
> 
> It must be much more useful to create new instance of Action
> for each request, even if the request is same as before.
> Because, thus, Action could have STATE of its own..
> 
> How about holding Constructor or Class object to create new 
> Action instead of holding created instance of Action and re-using 
> them.
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-dev-help@jakarta.apache.org
> 
> 


-- 
Ted Husted,
Struts in Action <http://husted.com/struts/book.html>



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