I would like to implement the interface at runtime based on variable.
Example :
Class A implements interface1 {
public getValue() {}
}
Class B implements interface1 {
public getValue() {}
}
So I would like to have variable sitting in configuration..., for example ClasstoImplement=A
So, if ClasstoImplement=A
, then I need to call Class A.getValue()
If ClasstoImplement=B
, then I need to call Class B.getValue()
at runtime. And I should be able to change value of ClasstoImplement
at runtime.
My application is Spring based and runs in Tomcat.
Can someone please help me to find out if there is any way??