ConverterContext.java
1.2 KB
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
package com.diligrp.tax.central.context;
import com.diligrp.tax.central.converter.IConverter;
import com.diligrp.tax.central.converter.ISubConverter;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* @Author: zhangmeiyang
* @CreateTime: 2025-10-31 16:09
* @Version: todo
*/
@Component
public class ConverterContext implements InitializingBean, DisposableBean {
public static final Map<Class<?>, IConverter<?>> CONVERTER_MAP = new ConcurrentHashMap<>();
public static final Map<Class<?>, ISubConverter<?>> SUB_CONVERTER_MAP = new ConcurrentHashMap<>();
@Resource
private List<IConverter<?>> converters;
@Resource
private List<ISubConverter<?>> subConverters;
@Override
public void destroy() throws Exception {
}
@Override
public void afterPropertiesSet() throws Exception {
converters.forEach(c -> CONVERTER_MAP.put(c.getClass(), c));
subConverters.forEach(c -> SUB_CONVERTER_MAP.put(c.getClass(), c));
}
}