struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <craig...@apache.org>
Subject RE: Struts Actions are Singletons?
Date Wed, 24 Apr 2002 20:29:33 GMT


On Wed, 24 Apr 2002, Galbreath, Mark wrote:

> Date: Wed, 24 Apr 2002 16:05:31 -0400
> From: "Galbreath, Mark" <Galbreath@tessco.com>
> Reply-To: Struts Users Mailing List <struts-user@jakarta.apache.org>
> To: 'Struts Users Mailing List' <struts-user@jakarta.apache.org>
> Subject: RE: Struts Actions are Singletons?
>
> On both the accessors and mutators?
>

Yes.

Take a simple form bean with only string and boolean properties (i.e. no
references to nested beans).  Put that form bean in request scope.  You
are now guaranteed that only your thread can access that form bean, and
you therefore don't have to synchronize anything.  (See the form beans in
the Struts example app for an illustration of this.)

If you have nested references to other beans, you have to go consider
whether *those* beans are referenced from anywhere else -- if they aren't,
then you are still thread safe.  If they are, you *may* have to
synchronize, depending on whether it can be mutated from multiple threads
or not.

> Mark
>

Craig


> -----Original Message-----
> From: Craig R. McClanahan [mailto:craigmcc@apache.org]
> Sent: Wednesday, April 24, 2002 3:56 PM
>
> >From a programming point of view, you can think of form beans in request
> scope just like you think of local variables -- there is a copy per
> thread, so you don't have to worry about synchronizing anything inside
> them (although you would if the form bean was saved in session scope).
>
> Craig
>
> --
> To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>


Mime
View raw message