users
[Top] [All Lists]

Struts action - thread-safe code

To: users@xxxxxxxxxx
Subject: Struts action - thread-safe code
From: Alexander V <mzuknn@xxxxxxxxx>
Date: Wed, 11 May 2005 18:33:17 -0700 (PDT)
Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
Delivered-to: mailing list users@cinjug.org
Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; b=ItnP+eQdnjCatjcpwVTyOt47Q3BtJKxxBWZNCCJpggMkv5xXnNtocctrDwkZjnSNin8m7l7PZwF4/zLh9rSnQwWI2NeLPyAwO1wKGK5ogJtoaoR28Wme0eO0bm8OELam7IaVdEtyLSs1aL71e83dZYuN9qtjmgg1mYRNxqISVB8= ;
Mailing-list: contact users-help@cinjug.org; run by ezmlm
Hi,
I?ve a question about Struts action class.
Struts documentation tells:
Actions must be programmed in a thread-safe manner,
because the controller will share the same instance
for multiple simultaneous requests. This means you
should design with the following items in mind: 
?       Instance and static variables MUST NOT be used to
store information related to the state of a particular
request. They MAY be used to share global resources
across requests for the same action.
?       Access to other resources (JavaBeans, session
variables, etc.) MUST be synchronized if those
resources require protection. (Generally, however,
resource classes should be designed to provide their
own protection where necessary.
So my question: Is this action?s class a thread-safe?:

class SomeAction extends Action {
 private Object someObject;
 public ActionForward execute(request, form){
   someObject = new Object();
   someObject.toString(); // is it OK?
 }
}

Thanks


                
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - Find what you need with new enhanced search. 
http://info.mail.yahoo.com/mail_250

<Prev in Thread] Current Thread [Next in Thread>