@Service
abstract class A {
protected MyObj obj;
protected A(MyObj obj) {
this.obj = obj;
}
public abstract XYZ getTrade();
}
@Service
public class B extends A {
B(MyObj obj) {
super(obj);
}
public XYZ getTrade() {}
}
@Service
public class C extends A {
C(MyObj obj) {
super(obj);
}
public XYZ getTrade() {}
}
@Controller
public class MyController {
@GemMapping("/test")
public void test() {
MyObj obj = new MyObj();
if(condition 1) {
//call getTrade() method of class B
}
if(condition 2) {
//call getTrade() method of class C
}
}
}
MyObj
is a user-defined POJO that is not managed bean.
I have the above classes. now I have to call getTrade() method based on some condition in Controller. Could you please help/advise?