Class TestDeviceSupplier
java.lang.Object
io.github.lunasaw.gbproxy.test.config.TestDeviceSupplier
- All Implemented Interfaces:
ClientDeviceSupplier
,DeviceSupplier
,ServerDeviceSupplier
@Component
@Primary
@EnableConfigurationProperties(TestDeviceProperties.class)
public class TestDeviceSupplier
extends Object
implements DeviceSupplier, ClientDeviceSupplier, ServerDeviceSupplier
测试设备提供器实现
专门用于测试环境,提供预配置的设备
设计原则:
1. 业务方通过userId获取设备数据,项目本身不关心设备类型
2. 统一存储Device对象,避免数据覆盖问题
3. 提供转换方法,在使用时根据场景转换为FromDevice或ToDevice
4. 支持动态设备管理和更新
- Author:
- luna
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addOrUpdateDevice
(Device device) createFromDevice
(Device device) 根据Device创建FromDevicecreateToDevice
(Device device) 根据Device创建ToDevice获取客户端From设备 用于客户端主动发送请求的场景获取客户端To设备 用于客户端接收响应的场景根据用户ID获取指定设备 这是设备获取的核心方法,业务方通过userId获取设备数据int
获取所有FromDevice类型的设备getName()
获取设备提供器的名称标识获取服务端From设备 用于服务端主动发送请求的场景获取服务端To设备 用于服务端接收响应的场景获取所有ToDevice类型的设备void
void
removeDevice
(String userId) void
setClientFromDevice
(FromDevice fromDevice) 设置客户端发送方设备信息 用于配置客户端的发送方设备标识void
setServerFromDevice
(FromDevice fromDevice) 设置服务端发送方设备信息 用于配置服务端的发送方设备标识Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.github.lunasaw.sip.common.service.DeviceSupplier
getToDevice, getToDevice
Methods inherited from interface io.github.lunasaw.sip.common.service.ServerDeviceSupplier
checkDevice
-
Constructor Details
-
TestDeviceSupplier
public TestDeviceSupplier()
-
-
Method Details
-
initializeDevices
@PostConstruct public void initializeDevices() -
getDevices
-
getDevice
Description copied from interface:DeviceSupplier
根据用户ID获取指定设备 这是设备获取的核心方法,业务方通过userId获取设备数据- Specified by:
getDevice
in interfaceDeviceSupplier
- Parameters:
userId
- 用户ID- Returns:
- 设备信息,如果不存在则返回null
-
addOrUpdateDevice
-
removeDevice
-
getDeviceCount
public int getDeviceCount() -
getName
Description copied from interface:DeviceSupplier
获取设备提供器的名称标识- Specified by:
getName
in interfaceDeviceSupplier
- Returns:
- 提供器名称
-
getClientFromDevice
获取客户端From设备 用于客户端主动发送请求的场景- Specified by:
getClientFromDevice
in interfaceClientDeviceSupplier
- Returns:
- 客户端发送方设备信息,如果不存在则返回null
-
setClientFromDevice
Description copied from interface:ClientDeviceSupplier
设置客户端发送方设备信息 用于配置客户端的发送方设备标识- Specified by:
setClientFromDevice
in interfaceClientDeviceSupplier
- Parameters:
fromDevice
- 客户端发送方设备信息
-
getClientToDevice
获取客户端To设备 用于客户端接收响应的场景 -
getServerFromDevice
获取服务端From设备 用于服务端主动发送请求的场景- Specified by:
getServerFromDevice
in interfaceServerDeviceSupplier
- Returns:
- 服务端发送方设备信息,如果不存在则返回null
-
setServerFromDevice
Description copied from interface:ServerDeviceSupplier
设置服务端发送方设备信息 用于配置服务端的发送方设备标识- Specified by:
setServerFromDevice
in interfaceServerDeviceSupplier
- Parameters:
fromDevice
- 服务端发送方设备信息
-
getServerToDevice
获取服务端To设备 用于服务端接收响应的场景 -
createFromDevice
根据Device创建FromDevice -
createToDevice
根据Device创建ToDevice -
getFromDevices
获取所有FromDevice类型的设备 -
getToDevices
获取所有ToDevice类型的设备
-