At 2:05 PM +0200 6/7/06, Julian Tillmann wrote:
Hello,

I've read that you can use Spring to make your Struts Actions thread safe. Is someone using this or has experience with it?

Wendy gave you the right pointer.

Note that the Spring custom RequestProcessor which is part of the strategy pointed out in the article Wendy referenced is not really good to use with Struts 1.3, because it doesn't use the chain of commands, and so some Struts 1.3 functionality would not be available.

However, also note that with Struts 1.3 you could also just change the behavior of the CreateAction class so that it doesn't cache actions, but instead instantiates them anew for each request. In fact, if there were much interest at all, it would be easy make this a configurable option in the Struts core.

(Alas, the way chain configs work, actually configuring it is a tiny bit more work than it should be, but not all that bad, and we could probably think of some other ways to express your intention without requiring a custom chain-config.xml -- perhaps a property on ActionMapping and/or a default setting?)

Are there other arguments for using Spring with Struts like, for example
an easy implemented Interceptor that might improve the application and is not as easily achieved with a filter?

Totally aside from managing the instantiation of Action classes, it's extremely valuable as a mechanism for externalizing business services so that your controller code can be as light as possible. We've simply found that it makes using best practices a lot easier. We used to use Struts PlugIns, which are a functional way to initialize business services for actions to call up, but Spring can provide the same sort of "model scaffolding" much more cleanly.

With a little study of Spring's advanced application configuration mechanisms (with layered application contexts and such), you can design your application so that you have a core of Spring config that is just as easily used by offline, non-webapp processes as it is used in the webapp; this was a real revelation to us for writing things like offline batch processes, where we used to struggle to maintain equivalent application configurations in the webapp and outside. I should try to write a HOWTO about this, but I don't really feel that expert about it.

Joe

--
Joe Germuska
[EMAIL PROTECTED] * http://blog.germuska.com
"You really can't burn anything out by trying something new, and
even if you can burn it out, it can be fixed.  Try something new."
        -- Robert Moog

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to