On Tuesday 17 February 2009 15:03:20 Dale Newfield wrote: > Wes Wannemacher wrote: > > There is a Spring autowiring interceptor that will autowire services into > > your actions for you, even if you don't use Spring to instantiate the > > actions. > > OK, now I'm confused. What's the interaction between the "autowiring" > interceptor and the spring plugin? If we're using the spring plugin > should we avoid that interceptor, or do we need it? > > -Dale >
http://struts.apache.org/2.1.6/struts2- core/apidocs/com/opensymphony/xwork2/spring/interceptor/ActionAutowiringInterceptor.html It's a bit confusing, but it really depends on how you want autowiring to happen. As you can see, the javadoc is littered with TODOs :) This interceptor is not necessary if you are using Spring to instantiate your actions... Meaning, if your actions are Spring beans configured in applicationContext.xml (or whatever Spring configuration method you choose). If Spring instantiates the action, then Spring will do the dependency wiring, via whatever method is configured within Spring (and only Spring). This interceptor comes into play when you are using Struts' non-Spring object factories. For instance, in my case, I use convention which instantiates actions by scanning my classpath and looking for classes marked with @Action or that match the naming convention (PersonManagerAction). At first, I thought by using convention, I would have to lookup dependencies in a Spring context, but it turns out that this interceptor will autowire spring beans by name/type/etc. depending on how it's configured. The interceptor depends on the SpringObjectFactory, so it is necessary to have the Spring plugin installed. -Wes -- Wes Wannemacher Author - Struts 2 In Practice Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more http://www.manning.com/wannemacher --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org