Return-Path: Delivered-To: apmail-jakarta-struts-dev-archive@apache.org Received: (qmail 57387 invoked from network); 1 May 2003 11:18:06 -0000 Received: from exchange.sun.com (192.18.33.10) by daedalus.apache.org with SMTP; 1 May 2003 11:18:06 -0000 Received: (qmail 24526 invoked by uid 97); 1 May 2003 11:20:04 -0000 Delivered-To: qmlist-jakarta-archive-struts-dev@nagoya.betaversion.org Received: (qmail 24519 invoked from network); 1 May 2003 11:20:04 -0000 Received: from daedalus.apache.org (HELO apache.org) (208.185.179.12) by nagoya.betaversion.org with SMTP; 1 May 2003 11:20:04 -0000 Received: (qmail 56762 invoked by uid 500); 1 May 2003 11:18:00 -0000 Mailing-List: contact struts-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Struts Developers List" Reply-To: "Struts Developers List" Delivered-To: mailing list struts-dev@jakarta.apache.org Received: (qmail 56751 invoked from network); 1 May 2003 11:18:00 -0000 Received: from ms-smtp-02.nyroc.rr.com (24.92.226.49) by daedalus.apache.org with SMTP; 1 May 2003 11:18:00 -0000 Received: from apache.org (roc-24-93-14-71.rochester.rr.com [24.93.14.71]) by ms-smtp-02.nyroc.rr.com (8.12.5/8.12.2) with ESMTP id h41BHxpo022296 for ; Thu, 1 May 2003 07:18:00 -0400 (EDT) Message-ID: <3EB1026C.9060903@apache.org> Date: Thu, 01 May 2003 07:18:04 -0400 From: Ted Husted Organization: Apache Software Foundation - Jakarta Project User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.0.2) Gecko/20030208 Netscape/7.02 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Struts Developers List Subject: Re: Why only one instance of Action? References: <024101c30fd1$c97d9d20$0702a8c0@monza> Content-Type: text/plain; charset=ISO-2022-JP Content-Transfer-Encoding: 7bit X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N 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 --------------------------------------------------------------------- To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: struts-dev-help@jakarta.apache.org