package com.walker.store.task; import com.walker.connector.Address; import com.walker.store.support.DummyStore; import java.util.List; /** * 自定义采集任务定义,不适用Store对象。 * @author 时克英 * @date 2022-09-26 */ public abstract class GenericGatherTask extends DatabaseGatherTask{ public GenericGatherTask(String name, Address address){ super(new DummyStore(), name, address); } @Override public Object run(String srcName, String createTableSQL, Object parameter , Object[] params) throws Exception{ if(connector == null){ connector = getConnector(); } if(connector == null){ throw new IllegalArgumentException("GatherTask参数错误:connector必须存在!"); } List data = this.invokeRequest(connector, params); if(data == null){ logger.debug("GatherTask调用请求返回空数据"); return null; } return this.execute(srcName, createTableSQL, parameter, data); } /** * 由业务自由定义每次执行的具体反馈。 * @param srcName * @param createTableSQL * @param parameter * @param data 请求远程地址返回的业务数据,如:数据库查询结果 * @return */ protected abstract Object execute(String srcName, String createTableSQL, Object parameter, List data); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //~ 如果请求远程服务是http或其他方式,请重写以下方法。这里默认请求的数据库数据。2022-09-26 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // @Override // protected AbstractConnector getConnector() { // return null; // } // // @Override // protected List invokeRequest(AbstractConnector connector, Object[] params) throws Exception { // return null; // } }