On 2/22/07, Joe Germuska <[EMAIL PROTECTED]> wrote:
This page is the place to start on using the Spring plugin with Struts 2: http://struts.apache.org/2.x/docs/spring-plugin.html In short, Spring can instantiate any beans you want, either as singletons or as "prototypes" (that is, a new bean is instantiated each time it is called for from the Spring app context). In instantiating, it can also satisfy dependencies automagically. In the Struts2/Spring model, this is usually applied to action classes, which would be instantiated by Spring when requested by Struts. Spring would just give you an Action instance with a reference to your factory (although once you start digging in Spring, you might find that you can even hide the Factory and keep your Actions super simple and flexible.)
Oh, yes, I just remembered -- the page above has a Spring config file example using the Spring 1.x DTD. If you should instead use the Spring 2.xDTD (which you could, because Struts depends upon Spring 2), you must be aware that the default instantiation model for Spring 2 is "singleton", not "prototype", and that is at odds with the model behind WebWork, which assumes that each action is instantiated once per request. Thus, the example which is in the page referenced above: <bean id="bar" class="com.my.BarClass" singleton="false"/> would become <bean id="bar" class="com.my.BarClass" scope="prototype"/> Took me a little bit to realize that that was the source of a few quirks when I was first setting out with Struts2/Spring2. -- Joe Germuska [EMAIL PROTECTED] * http://blog.germuska.com "The truth is that we learned from João forever to be out of tune." -- Caetano Veloso