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; /** * 装配单进程设备适配器运行时。 * *

注册表按存储形态持有全部可用实现;实例按 {@code t_device_adapter} 配置或代码装配注册。 * 同一进程内可并存多个来源实例,取数按通道身份里的适配器编码解析到各自实例。 * 某个类型是否真的有实例可用只由配置决定,因此这里不再按 profile 收窄可注册的类型。 * *

推式来源({@code PUSH_INGEST})读的是本项目的落地表,所以它的工厂拿业务 Mapper 而不是厂商连接。 */ @Configuration @EnableScheduling public class DeviceAdapterRuntimeConfig { /** 装配持有全部可用工厂的适配器注册表;推式来源工厂使用业务落地表 Mapper,实例由配置或代码另行注册。 */ @Bean(destroyMethod = "close") public DeviceAdapterRegistry deviceAdapterRegistry(TDeviceIngestRecordMapper ingestRecords) { return new DeviceAdapterRegistry(List.of(new NoopDeviceAdapterFactory(), new BtsDeviceAdapterFactory(), new NewareMysqlAdapterFactory(), new PushIngestAdapterFactory(ingestRecords))); } }