On Fri, 27 Sep 2002, Andrew Hill wrote:

> Date: Fri, 27 Sep 2002 15:51:06 +0800
> From: Andrew Hill <[EMAIL PROTECTED]>
> Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>,
>      [EMAIL PROTECTED]
> To: Struts Users Mailing List <[EMAIL PROTECTED]>
> Subject: Is it really worth the effort to have a single instance of the
>     Action?
>
> Given that for modern JVMs object creation and cleanup isnt the chore it
> used to be , I am wondering if it might not be more convienient to create a
> new Action instance for each request.
>

The WebWorks framework (by Rickard Oberg) actually does things in the
manner you suggest, and goes one step further -- he combines what we think
of as the form bean and the Action into a single class, and calls all the
property setters for your request fields directly on the "Action" instance
before calling it's execute() method.  Therefore, no separate form bean
class is needed.

If I had thought of this design pattern in the first place, I'd have been
pretty tempted to use it.  However, changing the semantics of a
fundamental piece of Struts this radically doesn't seem like a good idea
at this point, because it would reduce performance (albeit by a small
amount) on existing Struts apps that are already programmed with thread
safe Actions.

The other concern I have is that this would encourage you to code your
business logic in the Action directly, instead of delegating it to some
logic bean.  I view the most appropriate role of an Action to be as an
adapter between the servlet-API-based web environment and the business
logic of your application, which should *not* depend on any presentation
layer APIs itself.


Craig


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to