struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Riyad Kalla <...@email.arizona.edu>
Subject Is MappingDispatchAction (Struts?) multithreaded? (Do I need to worry about it?)
Date Sun, 25 Apr 2004 17:46:00 GMT
I'm asking because I am now getting into MappingDispatchActions (MDA), 
and almost all of my actions do some form of DB validation and error out 
if something goes wrong. So I have stamped all over the place 4 lines of 
code that look like:

ActionMessages actionMessages = new ActionMessages();
actionMessages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("product.error.cannotMove"));
saveErrors(request, actionMessages);
return mapping.findForward("failure");


And I was thinking how nice, performance and organization if I could 
move a protected instance or even utility method into a base 
AbstractMappingDispatchAction class that did those 4 steps for me and I 
just passed in the message key....

So the method would do something like:

actionMessages.clear();
actionMessages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(messageKey));
saveErrors(request, actionMessages);
return mapping.findForward(forwardName);


but then I realized that this could be a huge problem if I had (a) a lot 
of users using the system and (b) struts/servlet container was 
multithreaded and called 2 methods at the same time that BOTH had 
errors... I could run into a situation where one method cleared the 
errors that the other method was trying to return to the user because 
the actionMessages instance is shared per-class.

Can anyone let me know if my worry IS correct and I should keep 
everything the way it is, or if I'm safe and can go ahead with it, and 
"why", if you know.

Thanks!
Riyad

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


Mime
View raw message