shikeying
2024-01-11 3b67e947e36133e2a40eb2737b15ea375e157ea0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package com.walker.store.task;
 
import com.walker.connector.Address;
import com.walker.store.support.DummyStore;
 
import java.util.List;
 
/**
 * 自定义采集任务定义,不适用<code>Store</code>对象。
 * @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<Object> 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<Object> data);
 
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    //~ 如果请求远程服务是http或其他方式,请重写以下方法。这里默认请求的数据库数据。2022-09-26
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
//    @Override
//    protected AbstractConnector getConnector() {
//        return null;
//    }
//
//    @Override
//    protected List<Object> invokeRequest(AbstractConnector connector, Object[] params) throws Exception {
//        return null;
//    }
}