I have an application that can use two implementations of a service:
package test;
public interface MyService {
void doSomething();
}
package test;
public class MyServiceA implements MyService {
private final String whatever;
public MyServiceA(final String whatever) {
this.whatever = whatever;
}
@Override
public void doSomething() {
System.out.println("MyServiceA did "+whatever);
}
}
package test;
public class MyServiceB implements MyService {
private final String what;
public MyServiceB(final String what) {
this.what = what;
}
@Override
public void doSomething() {
System.out.println("MyServiceB did "+what);
}
}
with different configurations.
I want to select what implementation to use with a system property.
I want to have the configuration for each implementation in its own property file and also its own spring configuration. So I can remove all the non used configuration altogether when not in use.
How may I configure any of the two implementations without requiring the property file of the non configured implementation?
Other solutions to this problem welcome.