Do you think though that this would be a nice convenience or would just
encourage bad
practices too much to be worth it? Also assuming that the overhead was
acceptable (define acceptable)

-----Original Message-----
From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]
Sent: Thursday, July 17, 2003 12:12 PM
To: Struts Users Mailing List
Subject: Re: Question on making Action classes thread-safe




On Thu, 17 Jul 2003, Erik Price wrote:

> Date: Thu, 17 Jul 2003 08:39:00 -0400
> From: Erik Price <[EMAIL PROTECTED]>
> Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
> To: Struts Users Mailing List <[EMAIL PROTECTED]>
> Subject: Re: Question on making Action classes thread-safe
>
>
>
> Ajay Patil wrote:
> > Hello,
> >
> > I found out that it is possible to make the Action class thread-safe
> > by over-riding RequestProcessor (processActionCreate method) so that
> > it creates a new Action instance for each request.
> >
> > I would like to know the implications and possible problems ?
> > If anyone has tried this, please share your experiences.
>
> Is this similar to the "thread-safety" of SingleThreadedServlet?

Sort of.  Usually, the reason people might want this is so that they can
use instance variables in their Actions to store per-request state
information.  To me, this is normally a clue that you're trying to do too
much stuff in your Action in the first place -- you should really be
delegating business logic to business tier beans (and you can create
individual ones there if you need to).

And, just like with SingleThreadModel, you still have to worry about
simultaneous requests to the same session, whether or not there is a
single Action instance per request.

>  It
> sounds like it.  I would imagine that with a separate instance for each
> request, more memory would be consumed?
>

Yes.  And more GC because a new instance is created for every request, and
then thrown away.  Whether this actually has significant impact on the
performance of your app, though, is not something that you can give a
generalized answer to -- it depends on what the critical hotspots are in
your particular application.

>
>
> Erik
>

Craig

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



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

Reply via email to