Make LwM2mValueConverterImpl singleton
This commit is contained in:
parent
3a7101a8a3
commit
58e544c32e
@ -91,7 +91,7 @@ public class LwM2MTransportRequest {
|
|||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void init() {
|
public void init() {
|
||||||
this.converter = new LwM2mValueConverterImpl();
|
this.converter = LwM2mValueConverterImpl.getInstance();
|
||||||
executorResponse = Executors.newCachedThreadPool(
|
executorResponse = Executors.newCachedThreadPool(
|
||||||
new NamedThreadFactory(String.format("LwM2M %s channel response", RESPONSE_CHANNEL)));
|
new NamedThreadFactory(String.format("LwM2M %s channel response", RESPONSE_CHANNEL)));
|
||||||
executorResponseError = Executors.newCachedThreadPool(
|
executorResponseError = Executors.newCachedThreadPool(
|
||||||
|
|||||||
@ -73,7 +73,7 @@ public class LwM2MTransportServerConfiguration {
|
|||||||
builder.setEncoder(new DefaultLwM2mNodeEncoder());
|
builder.setEncoder(new DefaultLwM2mNodeEncoder());
|
||||||
LwM2mNodeDecoder decoder = new DefaultLwM2mNodeDecoder();
|
LwM2mNodeDecoder decoder = new DefaultLwM2mNodeDecoder();
|
||||||
builder.setDecoder(decoder);
|
builder.setDecoder(decoder);
|
||||||
builder.setEncoder(new DefaultLwM2mNodeEncoder(new LwM2mValueConverterImpl()));
|
builder.setEncoder(new DefaultLwM2mNodeEncoder(LwM2mValueConverterImpl.getInstance()));
|
||||||
|
|
||||||
/** Create CoAP Config */
|
/** Create CoAP Config */
|
||||||
builder.setCoapConfig(getCoapConfig());
|
builder.setCoapConfig(getCoapConfig());
|
||||||
@ -89,7 +89,7 @@ public class LwM2MTransportServerConfiguration {
|
|||||||
builder.setDtlsConfig(dtlsConfig);
|
builder.setDtlsConfig(dtlsConfig);
|
||||||
|
|
||||||
/** Use a magic converter to support bad type send by the UI. */
|
/** Use a magic converter to support bad type send by the UI. */
|
||||||
builder.setEncoder(new DefaultLwM2mNodeEncoder(new LwM2mValueConverterImpl()));
|
builder.setEncoder(new DefaultLwM2mNodeEncoder(LwM2mValueConverterImpl.getInstance()));
|
||||||
|
|
||||||
/** Create DTLS security mode
|
/** Create DTLS security mode
|
||||||
* There can be only one DTLS security mode
|
* There can be only one DTLS security mode
|
||||||
|
|||||||
@ -123,7 +123,7 @@ public class LwM2MTransportService {
|
|||||||
new NamedThreadFactory(String.format("LwM2M %s channel update registered", SERVICE_CHANNEL)));
|
new NamedThreadFactory(String.format("LwM2M %s channel update registered", SERVICE_CHANNEL)));
|
||||||
this.executorUnRegistered = Executors.newCachedThreadPool(
|
this.executorUnRegistered = Executors.newCachedThreadPool(
|
||||||
new NamedThreadFactory(String.format("LwM2M %s channel un registered", SERVICE_CHANNEL)));
|
new NamedThreadFactory(String.format("LwM2M %s channel un registered", SERVICE_CHANNEL)));
|
||||||
this.converter = new LwM2mValueConverterImpl();
|
this.converter = LwM2mValueConverterImpl.getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -78,7 +78,7 @@ public class LwM2MClient implements Cloneable {
|
|||||||
* Key <objectId>, response<Value -> instance -> resources: value...>
|
* Key <objectId>, response<Value -> instance -> resources: value...>
|
||||||
*/
|
*/
|
||||||
this.responses = new ConcurrentHashMap<>();
|
this.responses = new ConcurrentHashMap<>();
|
||||||
this.converter = new LwM2mValueConverterImpl();
|
this.converter = LwM2mValueConverterImpl.getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -33,6 +33,12 @@ import java.util.Date;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class LwM2mValueConverterImpl implements LwM2mValueConverter {
|
public class LwM2mValueConverterImpl implements LwM2mValueConverter {
|
||||||
|
|
||||||
|
private static final LwM2mValueConverterImpl INSTANCE = new LwM2mValueConverterImpl();
|
||||||
|
|
||||||
|
public static LwM2mValueConverterImpl getInstance() {
|
||||||
|
return INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object convertValue(Object value, Type currentType, Type expectedType, LwM2mPath resourcePath)
|
public Object convertValue(Object value, Type currentType, Type expectedType, LwM2mPath resourcePath)
|
||||||
throws CodecException {
|
throws CodecException {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user