I have a requirement where i need to switch spring beans at runtime. I am thinking of using @ConditionalOnProperty to achieve that but i also need to create a rest endpoint which dynamically changes this property?
I am not sure how to create the rest endpoint. Can someone please recommend?
public interface myInterface {}
@Service
@ConditionalOnProperty(value = "is.new.service", havingValue="true")
public class serviceA implements myInterface{}
@Service
@ConditionalOnProperty(value = "is.new.service", havingValue="false")
public class serviceB implements myInterface{}
public class Myinitializer {
private myInterface myA;
public myinitializer(myInterface myA){
this.myA = myA;
}
}
application.properties
is.new.service = true
Now I also need to create a rest endpoint which can change the value is.new.service dynamically based on the value being passed in the request. Can someone please recommend how to achieve it?