struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nicolas De Loof" <nicolas.del...@cgey.com>
Subject Re: Struts Actions are Singletons?
Date Wed, 24 Apr 2002 13:23:36 GMT
Action classes are only a gateway to your business logic. You would just
have to create and use business objects for your request.

If you need synchronized blocks, it's looks like your Action has some
instance properties that cannot be shared with other requests.

I think this properties would have to be a business class or an value object
class that could be created by Action and passed to Action methods or
business methods, so beeing threadsafe.

If you realy need to synchronize access to some ressources, try to put this
into a dedicated class that will manage this ressources, so that the
synchronized mecanism will be in this manager class.


> And to make it thread safe I have use "synchronize" blocks of code which
can
> cause all the requests to get queued up. (Java has lock per object,
> therefore if my code had 2 synchronized blocks, then the 2nd block would
> lock up even when the first one is being executed.)
> Isn't this bad for performance?
>
> regards,
> Abhishek.
> ----- Original Message -----
> From: "Nelson, Laird" <Laird.Nelson@FMR.COM>
> To: "'Struts Users Mailing List'" <struts-user@jakarta.apache.org>
> Sent: Wednesday, April 24, 2002 6:27 PM
> Subject: RE: Struts Actions are Singletons?
>
>
> > > -----Original Message-----
> > > From: abhishek srivastava [mailto:abhishes@hotmail.com]
> > > Are the Action classes that we write for Struts Singletons?
> > > or are they
> > > created and destroyed per request.
> >
> >
>
http://jakarta.apache.org/struts/doc-1.0.2/userGuide/building_controller.htm
> > l#action_classes
> >
> > Excerpt:
> >   "The controller servlet creates only one instance of your Action
class,
> > and uses it for all requests. Thus, you need to code your Action class
so
> > that it operates correctly in a multi-threaded environment, just as you
> must
> > code a servlet's service() method safely."
> >
> > Cheers,
> > Laird
> >
> > --
> > 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>


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