xiejun
2023-07-13 2871cb99e018f6bf9e2ef76a424a1429a7c818f0
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
package com.vci.ubcs.ddl.processor.ddl;
 
import com.alibaba.nacos.shaded.com.google.common.collect.Lists;
import com.vci.ubcs.ddl.mapper.DdlMSMapper;
import com.vci.ubcs.ddl.mapper.DdlMySqlMapper;
import com.vci.ubcs.ddl.mapper.DdlOracleMapper;
import com.vci.ubcs.starter.util.VciSpringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
import org.springframework.stereotype.Component;
 
import javax.annotation.Resource;
import java.util.List;
 
/**
 * Description:
 *
 * @author LiHang
 * @date 2023/4/24
 */
@Component
@DependsOn("vciSpringUtil")
public class DdlMapperProcessStrategy {
 
    @Value("${spring.datasource.driver-class-name}")
    private String DATABASE_DRIVER;
 
    private final static List<DdlMapperProcessor> PROCESSORS = Lists.newArrayList();
 
    static {
        PROCESSORS.add(VciSpringUtil.getBean(DdlOracleMapperProcessor.class));
        PROCESSORS.add(VciSpringUtil.getBean(DdlMySqlMapperProcessor.class));
        PROCESSORS.add(VciSpringUtil.getBean(DdlMsMapperProcessor.class));
        PROCESSORS.add(VciSpringUtil.getBean(DdlDmMapperProcessor.class));
    }
 
    @Bean("ddlMapper")
    public  DdlMapperProcessor getProcessor(){
        for (DdlMapperProcessor processor : PROCESSORS) {
            if (processor.support(DATABASE_DRIVER)){
                System.out.println("===========================================");
                System.out.println("获取DDL操作类成功:" + processor.getClass().getName());
                return processor;
            }
        }
        return VciSpringUtil.getBean(DdlOracleMapperProcessor.class);
    }
}