Similar to this question, but I have this situation. Suppose I have one AccountService
interface and two implementations: DefaultAccountServiceImpl
and SpecializedAccountServiceImpl
, (the classes just like in the previous question). The implementation is in one class, but has different bean implementation for different method. Say:
@RestController
@RequestMapping("/account")
public class AccountManagerRestController {
@Autowired
private AccountService service;
@RequestMapping(value = "/register", method = RequestMethod.POST)
HttpEntity<?> registerAccount(@RequestBody AccountRegisterRequestBody input) {
// here the `service` is DefaultAccountServiceImpl
...
}
@RequestMapping(value = "/register/specialized", method = RequestMethod.POST)
HttpEntity<?> registerSpecializedAccount(@RequestBody AccountRegisterRequestBody input) {
// here the `service` is SpecializedAccountServiceImpl
...
}
}