抽象类中有属性需要自动注入
public abstract class FlowExecutor {
@Autowired
QsFlowMapper qsFlowMapper;
protected abstract void checkDependCondieiton(QsFlow qsFlow);
protected abstract void checkLimitCondition(QsFlow qsFlow);
}
@Service("commonFlowExecutor")
public class CommonFlowExecutor extends FlowExecutor {
@Override
public void checkDependCondieiton(QsFlow qsFlow) {
}
@Override
public void checkLimitCondition(QsFlow qsFlow) {
}
}
@Service
public class CompanyFlowExecutor extends FlowExecutor {
@Override
protected void checkDependCondieiton(QsFlow qsFlow) {
}
@Override
protected void checkLimitCondition(QsFlow qsFlow) {
}
}
@Service
public class FlowDispatchManager {
@Autowired
FlowExecutor commonFlowExecutor;
@Autowired
FlowExecutor companyFlowExecutor;
public void doFlow(int flowId, int operatorNo) {
char flowModel = getFlowModel();
if (flowModel == '1') {
commonFlowExecutor.doFlow(flowId, flowModel, operatorNo);
} else {
companyFlowExecutor.doFlow(flowId, flowModel, operatorNo);
}
}
}
FlowExecutor commonFlowExecutor; 自动注入CommonFlowExecutor类的实例。
FlowExecutor companyFlowExecutor;自动注入CompanyFlowExecutor类的实例。