We are upgrading our application from "xml based injection" to annotations and ran into the following problem. We want to replace the following injections with autowire.
The old controller:Code:<!-- implements Generator interface --> <bean id="aGenerator" class="AGenerator"> <bean id="bGenrator" class="BGenerator"> <bean id="firstController" class="CommonController"> <property name="generator"> <ref bean="aGenerator" /> </property> </bean> <bean id="secondController" class="CommonController"> <property name="generator"> <ref bean="bGenerator" /> </property> </bean>
With the following mapping we were able to define different genrator beans depending on the request urlCode:public class CommonController extends WebApplicationObjectSupport extends Controller { // DataTableGenerator implements Generator interface private DataTableGenerator generator; // Spring Injection: public void setGenerator(DataTableGenerator generator) { this.generator = generator; } // @Override public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { DataSourceHelper.executeDataSourceServletFlow(request, response, generator, false); return null; } }
We want to define the controller beans with the @Controller annotation and autoinject the generator beans respectivly depending on the request url. Is that possible or is it simply a limitiation with the autowire annotation?Code:<prop key="/firstController.htm">firstController</prop> <prop key="/secondController.htm">secondController</prop>


Reply With Quote