Browse Source

Fix circular reference for CoapClientContext and CoapTransportContext

pull/5058/head
Viacheslav Klimov 5 years ago
committed by Andrew Shvayka
parent
commit
b0c6ce9f98
  1. 12
      common/transport/coap/src/main/java/org/thingsboard/server/transport/coap/client/DefaultCoapClientContext.java

12
common/transport/coap/src/main/java/org/thingsboard/server/transport/coap/client/DefaultCoapClientContext.java

@ -22,6 +22,7 @@ import org.eclipse.californium.core.coap.Response;
import org.eclipse.californium.core.observe.ObserveRelation;
import org.eclipse.californium.core.server.resources.CoapExchange;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.thingsboard.server.coapserver.CoapServerContext;
import org.thingsboard.server.common.data.DataConstants;
@ -74,7 +75,6 @@ import static org.eclipse.californium.core.coap.Message.NONE;
@Slf4j
@Service
@RequiredArgsConstructor
@ConditionalOnExpression("'${service.type:null}'=='tb-transport' || ('${service.type:null}'=='monolith' && '${transport.api_enabled:true}'=='true' && '${transport.coap.enabled}'=='true')")
public class DefaultCoapClientContext implements CoapClientContext {
@ -86,6 +86,16 @@ public class DefaultCoapClientContext implements CoapClientContext {
private final ConcurrentMap<DeviceId, TbCoapClientState> clients = new ConcurrentHashMap<>();
private final ConcurrentMap<String, TbCoapClientState> clientsByToken = new ConcurrentHashMap<>();
public DefaultCoapClientContext(CoapServerContext config, @Lazy CoapTransportContext transportContext,
TransportService transportService, TransportDeviceProfileCache profileCache,
PartitionService partitionService) {
this.config = config;
this.transportContext = transportContext;
this.transportService = transportService;
this.profileCache = profileCache;
this.partitionService = partitionService;
}
@Override
public boolean registerAttributeObservation(TbCoapClientState clientState, String token, CoapExchange exchange) {
return registerFeatureObservation(clientState, token, exchange, FeatureType.ATTRIBUTES);

Loading…
Cancel
Save