refactor: require mqtt identity resolver

This commit is contained in:
lingniu
2026-07-01 08:45:29 +08:00
parent dcd5f2a1a2
commit 2ab1eeb1f8
5 changed files with 47 additions and 20 deletions

View File

@@ -3,7 +3,6 @@ package com.lingniu.ingest.inbound.mqtt.client;
import com.lingniu.ingest.api.ProtocolId;
import com.lingniu.ingest.api.pipeline.RawFrame;
import com.lingniu.ingest.core.dispatcher.Dispatcher;
import com.lingniu.ingest.identity.StatelessVehicleIdentityResolver;
import com.lingniu.ingest.identity.VehicleIdentity;
import com.lingniu.ingest.identity.VehicleIdentityLookup;
import com.lingniu.ingest.identity.VehicleIdentityResolver;
@@ -50,19 +49,16 @@ public final class MqttEndpointManager implements AutoCloseable {
private final List<MqttAsyncClient> clients = new ArrayList<>();
private boolean started;
public MqttEndpointManager(MqttInboundProperties props,
MqttProfileRegistry profileRegistry,
Dispatcher dispatcher) {
this(props, profileRegistry, new StatelessVehicleIdentityResolver(), dispatcher);
}
public MqttEndpointManager(MqttInboundProperties props,
MqttProfileRegistry profileRegistry,
VehicleIdentityResolver identityResolver,
Dispatcher dispatcher) {
this.props = props;
this.profileRegistry = profileRegistry;
this.identityResolver = identityResolver == null ? new StatelessVehicleIdentityResolver() : identityResolver;
if (identityResolver == null) {
throw new IllegalArgumentException("identityResolver must not be null");
}
this.identityResolver = identityResolver;
this.dispatcher = dispatcher;
}

View File

@@ -6,7 +6,6 @@ import com.lingniu.ingest.api.event.LocationPayload;
import com.lingniu.ingest.api.event.RealtimePayload;
import com.lingniu.ingest.api.event.VehicleEvent;
import com.lingniu.ingest.api.spi.EventMapper;
import com.lingniu.ingest.identity.StatelessVehicleIdentityResolver;
import com.lingniu.ingest.identity.VehicleIdentity;
import com.lingniu.ingest.identity.VehicleIdentityLookup;
import com.lingniu.ingest.identity.VehicleIdentityResolver;
@@ -30,12 +29,11 @@ public final class YutongEventMapper implements EventMapper<MqttPayload> {
private final VehicleIdentityResolver identityResolver;
public YutongEventMapper() {
this(new StatelessVehicleIdentityResolver());
}
public YutongEventMapper(VehicleIdentityResolver identityResolver) {
this.identityResolver = identityResolver == null ? new StatelessVehicleIdentityResolver() : identityResolver;
if (identityResolver == null) {
throw new IllegalArgumentException("identityResolver must not be null");
}
this.identityResolver = identityResolver;
}
@Override