I have multiple provider classes (Provider1
and Provider2
), how do I decide what bean I use depending on the input parameter in the Processor
class?
public class Processor{
private Provider provider;
public void process(String providerName) throws Exception {
// What should I do here to invoke either provider1 or provider2 depending on the providerName?
provider.doOperation();
}
}
public class Provider1 {
public void doOperation(Exchange exchange) throws Exception {
//Code
}
}
public class Provider2 {
public void doOperation(Exchange exchange) throws Exception {
//Code
}
}