I need to dynamically get a service bean in a controller from a factory method. I have a service interface
public interface Service{
public String doSomething();
}
and some implementation of this interface.
public class ServiceImpl1{
public String doSomething(){
...
}
}
public class ServiceImpl2{
public String doSomething(){
...
}
}
There are 20 such implementations.
Now, in my controller I want to get one of these service impl instance, with dependency injected, based on user request. I am thinking of using a factory method to give me the instance, but to get dependency injected bean I need to load the context and get the bean. Is there any better way of doing it in Spring.