yeg
2026-09-28 ccf7fa9210887633944bd4d78f90463b82807e6e
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
package com.battery.business.runtime;
 
import java.util.List;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import com.battery.device.api.NoopDeviceAdapterFactory;
import com.battery.device.bts.BtsDeviceAdapterFactory;
import com.battery.device.api.registry.DeviceAdapterRegistry;
import com.battery.device.neware.NewareMysqlAdapterFactory;
import com.battery.business.mapper.TDeviceIngestRecordMapper;
import com.battery.business.service.impl.PushIngestAdapterFactory;
 
/**
 * 装配单进程设备适配器运行时。
 *
 * <p>注册表按存储形态持有全部可用实现;实例按 {@code t_device_adapter} 配置或代码装配注册。
 * 同一进程内可并存多个来源实例,取数按通道身份里的适配器编码解析到各自实例。
 * 某个类型是否真的有实例可用只由配置决定,因此这里不再按 profile 收窄可注册的类型。
 *
 * <p>推式来源({@code PUSH_INGEST})读的是本项目的落地表,所以它的工厂拿业务 Mapper 而不是厂商连接。
 */
@Configuration
@EnableScheduling
public class DeviceAdapterRuntimeConfig
{
    @Bean(destroyMethod = "close")
    public DeviceAdapterRegistry deviceAdapterRegistry(TDeviceIngestRecordMapper ingestRecords)
    {
        return new DeviceAdapterRegistry(List.of(new NoopDeviceAdapterFactory(), new BtsDeviceAdapterFactory(),
                new NewareMysqlAdapterFactory(), new PushIngestAdapterFactory(ingestRecords)));
    }
}