Multiple instances of annotated Controller with RequestMapping
Using Spring 3.1 with MVC Java Config, I'm attempting to deploy an application with multiple instances of the same Controller, mapped to different endpoints. My Controller methods are also annotated with RequestMapping, but I can't figure out how to have the same Controller used twice.
My controller code looks like this:
Code:
@Controller
public class SearchController {
private SearchService searchService;
public SearchController(earchService searchService) {
this.searchService = searchService;
}
@RequestMapping(value="/search")
public ResponseEntity<Response> handle(SearchCommand command) {
// Search code
searchService.search(...);
return new ResponseEntity<Response>(...);
}
}
So, what I'd like to do is be able to establish any number of different endpoints to search. The Controller code is the same, I just want to configure different instances of it wired with different instances of the SearchService depending on what type is being searched:
- /places/search
- /events/search
- /restaurants/search
Using the old xml config, I would have previously used the SimpleUrlHandlerMapping and configured several SearchController beans for each mapping. I know according to this (http://static.springsource.org/sprin...pping-31-vs-30) that this is no longer possible with the Spring MVC 3.1 way, so what's the alternative?