Your first point makes total sense. I will use member variables instead of picking parameters off the request map. I do not want to be tied to the servlet spec.
The second point also makes sense. I am currently injecting the service into the action via spring (using scope=prototype) so that I get new instances of the service. I may switch that to use singleton since my services don't hold any state. Thanks for the input.. I was looking for this very type of design advice.. > Date: Tue, 13 Jan 2009 15:31:54 -0500 > From: newton.d...@yahoo.com > To: user@struts.apache.org > Subject: Re: ServletRequestAware interface > > Andy wrote: > > Having my s2 action classes implement ServletRequestAware works great > > for getting request parameters. > > It's not necessary, though, as S2 will set request parameters into > action properties (a) without the overhead of getting the request > parameters manually, and (b) without tying your action to the servlet spec. > > > However it doesn't look like non-action classes can implement > > this interface to get the parameters. > > S2 doesn't know anything about your "non-action" classes, and has no > magic discovery path with which to identify them. > > > Since I offload my action class execute() processing to a service > > class (which is injected into the action via spring), I would like > > the service class to have access to the request parameters. Is > > the only way to accomplish this to pass the parameters reference > > from the action to the service class? I was hoping to have the > > parameters somehow injected into the service class. > > I'm not sure you're making use of S2 the way (or at least one major way) > it was intended to be used. In general the meme is to have the > parameters set into the action via action properties. The action then > calls the injected service, passing the properties in a service method call. > > That said, there's no reason the property setting can't be done in a > single call via something like commons-beanutils--assuming the service > is either synchronized or otherwise thread-safe. It's been my experience > that services are generally singletons (via Spring), making this a Bad Idea. > > YMMV. > > Dave > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > _________________________________________________________________ Windows Live⢠Hotmail®: Chat. Store. Share. Do more with mail. http://windowslive.com/howitworks?ocid=TXT_TAGLM_WL_t1_hm_justgotbetter_howitworks_012009