public interface MonitorInterface{ void excute(List<LabelMonitor> monitorResponseDTOList) } @Service @Slf4j public class LabelMonitorImpl extends MonitorLabelHandler implements MonitorInterface {
@AllArgsConstructor @NoArgsConstructor public class MonitorContext { private MonitorInterface monitorInterface; /** * 非定时处理 * @param monitorResponseDTOList monitorResponseDTOList */ public void excute(List<LabelMonitor> monitorResponseDTOList){ monitorInterface.excute(monitorResponseDTOList); } /** * 定时处理 * @param monitor monitor */ public void excute(LabelMonitor monitor){ monitorInterface.excute(monitor); } public MonitorContext(String type) { monitor(type); } public void monitor(String type){ switch (type){ case MONITOR_TYPE_01: this.monitorInterface = BeanUtil.getBean(LabelMonitorImpl.class); break; case MONITOR_TYPE_02: this.monitorInterface = BeanUtil.getBean(GroupMonitorImpl.class); break; default: throw new YtException("不存在的监控类型"); } } }
标签:excute,java,monitor,创建,monitorResponseDTOList,factory,monitorInterface,type,publ From: https://www.cnblogs.com/bingrong/p/18558643