Skip to content

Commit

Permalink
Rename LwM2mNode(Encoder/Decoder) in LwM2m(Encoder/Decoder).
Browse files Browse the repository at this point in the history
Those classes :
 - LwM2mNodeEncoder
 - LwM2mNodeDecoder
 - DefaultLwM2mNodeEncoder
 - DefaultLwM2mNodeDecoder

 now handle more than LwM2mNode and so are rename in :
 - LwM2mEncoder
 - LwM2mDecoder
 - DefaultLwM2mEncoder
 - DefaultLwM2mDecoder
  • Loading branch information
sbernard31 committed Jun 30, 2021
1 parent e41d9af commit d5f3f1b
Show file tree
Hide file tree
Showing 44 changed files with 198 additions and 198 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@
import org.eclipse.leshan.core.model.LwM2mModel;
import org.eclipse.leshan.core.node.LwM2mNode;
import org.eclipse.leshan.core.node.LwM2mPath;
import org.eclipse.leshan.core.node.codec.LwM2mNodeDecoder;
import org.eclipse.leshan.core.node.codec.LwM2mNodeEncoder;
import org.eclipse.leshan.core.node.codec.LwM2mDecoder;
import org.eclipse.leshan.core.node.codec.LwM2mEncoder;
import org.eclipse.leshan.core.request.ContentFormat;
import org.eclipse.leshan.core.request.ReadCompositeRequest;
import org.eclipse.leshan.core.request.SendRequest;
Expand Down Expand Up @@ -85,15 +85,15 @@ public class LeshanClient implements LwM2mClient {
private LwM2mObjectTree objectTree;
private final BootstrapHandler bootstrapHandler;
private final LwM2mRootEnabler rootEnabler;
private final LwM2mNodeEncoder encoder;
private final LwM2mNodeDecoder decoder;
private final LwM2mEncoder encoder;
private final LwM2mDecoder decoder;
private final RegistrationEngine engine;
private final LwM2mClientObserverDispatcher observers;

public LeshanClient(String endpoint, InetSocketAddress localAddress,
List<? extends LwM2mObjectEnabler> objectEnablers, NetworkConfig coapConfig, Builder dtlsConfigBuilder,
EndpointFactory endpointFactory, RegistrationEngineFactory engineFactory,
Map<String, String> additionalAttributes, LwM2mNodeEncoder encoder, LwM2mNodeDecoder decoder,
Map<String, String> additionalAttributes, LwM2mEncoder encoder, LwM2mDecoder decoder,
ScheduledExecutorService sharedExecutor) {
this(endpoint, localAddress, objectEnablers, coapConfig, dtlsConfigBuilder, endpointFactory, engineFactory,
additionalAttributes, null, encoder, decoder, sharedExecutor);
Expand All @@ -104,7 +104,7 @@ public LeshanClient(String endpoint, InetSocketAddress localAddress,
List<? extends LwM2mObjectEnabler> objectEnablers, NetworkConfig coapConfig, Builder dtlsConfigBuilder,
EndpointFactory endpointFactory, RegistrationEngineFactory engineFactory,
Map<String, String> additionalAttributes, Map<String, String> bsAdditionalAttributes,
LwM2mNodeEncoder encoder, LwM2mNodeDecoder decoder, ScheduledExecutorService sharedExecutor) {
LwM2mEncoder encoder, LwM2mDecoder decoder, ScheduledExecutorService sharedExecutor) {
this(endpoint, localAddress, objectEnablers, coapConfig, dtlsConfigBuilder, null, endpointFactory,
engineFactory, new DefaultBootstrapConsistencyChecker(), additionalAttributes, bsAdditionalAttributes,
encoder, decoder, sharedExecutor);
Expand All @@ -115,7 +115,7 @@ public LeshanClient(String endpoint, InetSocketAddress localAddress,
List<? extends LwM2mObjectEnabler> objectEnablers, NetworkConfig coapConfig, Builder dtlsConfigBuilder,
List<Certificate> trustStore, EndpointFactory endpointFactory, RegistrationEngineFactory engineFactory,
BootstrapConsistencyChecker checker, Map<String, String> additionalAttributes,
Map<String, String> bsAdditionalAttributes, LwM2mNodeEncoder encoder, LwM2mNodeDecoder decoder,
Map<String, String> bsAdditionalAttributes, LwM2mEncoder encoder, LwM2mDecoder decoder,
ScheduledExecutorService sharedExecutor) {

Validate.notNull(endpoint);
Expand Down Expand Up @@ -194,7 +194,7 @@ protected Resource createRoot() {

protected void linkObjectTreeToCoapServer(final CoapServer coapServer, final RegistrationEngine registrationEngine,
final CaliforniumEndpointsManager endpointsManager, LwM2mObjectTree objectTree,
final LwM2mNodeEncoder encoder, final LwM2mNodeDecoder decoder) {
final LwM2mEncoder encoder, final LwM2mDecoder decoder) {

// Create CoAP resources for each lwm2m Objects.
for (LwM2mObjectEnabler enabler : objectTree.getObjectEnablers().values()) {
Expand Down Expand Up @@ -224,7 +224,7 @@ public void objectRemoved(LwM2mObjectEnabler object) {
}

protected CoapResource createObjectResource(LwM2mObjectEnabler enabler, RegistrationEngine registrationEngine,
CaliforniumEndpointsManager endpointsManager, LwM2mNodeEncoder encoder, LwM2mNodeDecoder decoder) {
CaliforniumEndpointsManager endpointsManager, LwM2mEncoder encoder, LwM2mDecoder decoder) {
return new ObjectResource(enabler, registrationEngine, endpointsManager, encoder, decoder);
}

Expand All @@ -241,7 +241,7 @@ protected CaliforniumEndpointsManager createEndpointsManager(InetSocketAddress l
}

protected CaliforniumLwM2mRequestSender createRequestSender(CaliforniumEndpointsManager endpointsManager,
ScheduledExecutorService executor, LwM2mNodeEncoder encoder, LwM2mModel model) {
ScheduledExecutorService executor, LwM2mEncoder encoder, LwM2mModel model) {
return new CaliforniumLwM2mRequestSender(endpointsManager, executor, encoder, model);
}

Expand All @@ -253,7 +253,7 @@ protected RegistrationUpdateHandler createRegistrationUpdateHandler(Registration
return registrationUpdateHandler;
}

protected Set<ContentFormat> getSupportedContentFormat(LwM2mNodeDecoder decoder, LwM2mNodeEncoder encoder) {
protected Set<ContentFormat> getSupportedContentFormat(LwM2mDecoder decoder, LwM2mEncoder encoder) {
Set<ContentFormat> supportedContentFormat = new TreeSet<>();
supportedContentFormat.addAll(decoder.getSupportedContentFormat());
supportedContentFormat.addAll(encoder.getSupportedContentFormat());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@
import org.eclipse.leshan.core.californium.DefaultEndpointFactory;
import org.eclipse.leshan.core.californium.EndpointFactory;
import org.eclipse.leshan.core.node.LwM2mNode;
import org.eclipse.leshan.core.node.codec.DefaultLwM2mNodeDecoder;
import org.eclipse.leshan.core.node.codec.DefaultLwM2mNodeEncoder;
import org.eclipse.leshan.core.node.codec.LwM2mNodeDecoder;
import org.eclipse.leshan.core.node.codec.LwM2mNodeEncoder;
import org.eclipse.leshan.core.node.codec.DefaultLwM2mDecoder;
import org.eclipse.leshan.core.node.codec.DefaultLwM2mEncoder;
import org.eclipse.leshan.core.node.codec.LwM2mDecoder;
import org.eclipse.leshan.core.node.codec.LwM2mEncoder;
import org.eclipse.leshan.core.request.BindingMode;
import org.eclipse.leshan.core.request.BootstrapRequest;
import org.eclipse.leshan.core.util.Validate;
Expand All @@ -67,8 +67,8 @@ public class LeshanClientBuilder {
private Builder dtlsConfigBuilder;
private List<Certificate> trustStore;

private LwM2mNodeEncoder encoder;
private LwM2mNodeDecoder decoder;
private LwM2mEncoder encoder;
private LwM2mDecoder decoder;

private EndpointFactory endpointFactory;
private RegistrationEngineFactory engineFactory;
Expand Down Expand Up @@ -126,21 +126,21 @@ public LeshanClientBuilder setObjects(List<? extends LwM2mObjectEnabler> objectE
}

/**
* Set the {@link LwM2mNodeEncoder} which will encode {@link LwM2mNode} with supported content format.
* Set the {@link LwM2mEncoder} which will encode {@link LwM2mNode} with supported content format.
* <p>
* By default the {@link DefaultLwM2mNodeEncoder} is used. It supports Text, Opaque, TLV and JSON format.
* By default the {@link DefaultLwM2mEncoder} is used. It supports Text, Opaque, TLV and JSON format.
*/
public LeshanClientBuilder setEncoder(LwM2mNodeEncoder encoder) {
public LeshanClientBuilder setEncoder(LwM2mEncoder encoder) {
this.encoder = encoder;
return this;
}

/**
* Set the {@link LwM2mNodeDecoder} which will decode data in supported content format to create {@link LwM2mNode}.
* Set the {@link LwM2mDecoder} which will decode data in supported content format to create {@link LwM2mNode}.
* <p>
* By default the {@link DefaultLwM2mNodeDecoder} is used. It supports Text, Opaque, TLV and JSON format.
* By default the {@link DefaultLwM2mDecoder} is used. It supports Text, Opaque, TLV and JSON format.
*/
public LeshanClientBuilder setDecoder(LwM2mNodeDecoder decoder) {
public LeshanClientBuilder setDecoder(LwM2mDecoder decoder) {
this.decoder = decoder;
return this;
}
Expand Down Expand Up @@ -276,9 +276,9 @@ public LeshanClient build() {
objectEnablers = initializer.createAll();
}
if (encoder == null)
encoder = new DefaultLwM2mNodeEncoder();
encoder = new DefaultLwM2mEncoder();
if (decoder == null)
decoder = new DefaultLwM2mNodeDecoder();
decoder = new DefaultLwM2mDecoder();
if (coapConfig == null) {
coapConfig = createDefaultNetworkConfig();
}
Expand Down Expand Up @@ -375,7 +375,7 @@ protected LeshanClient createLeshanClient(String endpoint, InetSocketAddress loc
List<? extends LwM2mObjectEnabler> objectEnablers, NetworkConfig coapConfig, Builder dtlsConfigBuilder,
List<Certificate> trustStore, EndpointFactory endpointFactory, RegistrationEngineFactory engineFactory,
BootstrapConsistencyChecker checker, Map<String, String> additionalAttributes,
Map<String, String> bsAdditionalAttributes, LwM2mNodeEncoder encoder, LwM2mNodeDecoder decoder,
Map<String, String> bsAdditionalAttributes, LwM2mEncoder encoder, LwM2mDecoder decoder,
ScheduledExecutorService sharedExecutor) {
return new LeshanClient(endpoint, localAddress, objectEnablers, coapConfig, dtlsConfigBuilder, trustStore,
endpointFactory, engineFactory, checker, additionalAttributes, bsAdditionalAttributes, encoder, decoder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
import org.eclipse.leshan.core.Link;
import org.eclipse.leshan.core.node.LwM2mNode;
import org.eclipse.leshan.core.node.LwM2mPath;
import org.eclipse.leshan.core.node.codec.LwM2mNodeDecoder;
import org.eclipse.leshan.core.node.codec.LwM2mNodeEncoder;
import org.eclipse.leshan.core.node.codec.LwM2mDecoder;
import org.eclipse.leshan.core.node.codec.LwM2mEncoder;
import org.eclipse.leshan.core.request.BootstrapDeleteRequest;
import org.eclipse.leshan.core.request.BootstrapDiscoverRequest;
import org.eclipse.leshan.core.request.ContentFormat;
Expand All @@ -56,12 +56,12 @@ public class RootResource extends LwM2mClientCoapResource {
protected CoapServer coapServer;
protected BootstrapHandler bootstrapHandler;
protected LwM2mRootEnabler rootEnabler;
protected LwM2mNodeEncoder encoder;
protected LwM2mNodeDecoder decoder;
protected LwM2mEncoder encoder;
protected LwM2mDecoder decoder;

public RootResource(RegistrationEngine registrationEngine, CaliforniumEndpointsManager endpointsManager,
BootstrapHandler bootstrapHandler, CoapServer coapServer, LwM2mRootEnabler rootEnabler,
LwM2mNodeEncoder encoder, LwM2mNodeDecoder decoder) {
LwM2mEncoder encoder, LwM2mDecoder decoder) {
super("", registrationEngine, endpointsManager);
this.bootstrapHandler = bootstrapHandler;
setVisible(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
import org.eclipse.leshan.core.node.LwM2mPath;
import org.eclipse.leshan.core.node.LwM2mResource;
import org.eclipse.leshan.core.node.codec.CodecException;
import org.eclipse.leshan.core.node.codec.LwM2mNodeDecoder;
import org.eclipse.leshan.core.node.codec.LwM2mNodeEncoder;
import org.eclipse.leshan.core.node.codec.LwM2mDecoder;
import org.eclipse.leshan.core.node.codec.LwM2mEncoder;
import org.eclipse.leshan.core.request.BootstrapDeleteRequest;
import org.eclipse.leshan.core.request.BootstrapDiscoverRequest;
import org.eclipse.leshan.core.request.BootstrapReadRequest;
Expand Down Expand Up @@ -80,11 +80,11 @@
public class ObjectResource extends LwM2mClientCoapResource implements ObjectListener {

protected final LwM2mObjectEnabler nodeEnabler;
protected final LwM2mNodeEncoder encoder;
protected final LwM2mNodeDecoder decoder;
protected final LwM2mEncoder encoder;
protected final LwM2mDecoder decoder;

public ObjectResource(LwM2mObjectEnabler nodeEnabler, RegistrationEngine registrationEngine,
CaliforniumEndpointsManager endpointsManager, LwM2mNodeEncoder encoder, LwM2mNodeDecoder decoder) {
CaliforniumEndpointsManager endpointsManager, LwM2mEncoder encoder, LwM2mDecoder decoder) {
super(Integer.toString(nodeEnabler.getId()), registrationEngine, endpointsManager);
this.nodeEnabler = nodeEnabler;
this.nodeEnabler.addListener(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import org.eclipse.leshan.core.californium.AsyncRequestObserver;
import org.eclipse.leshan.core.californium.SyncRequestObserver;
import org.eclipse.leshan.core.model.LwM2mModel;
import org.eclipse.leshan.core.node.codec.LwM2mNodeEncoder;
import org.eclipse.leshan.core.node.codec.LwM2mEncoder;
import org.eclipse.leshan.core.request.UplinkRequest;
import org.eclipse.leshan.core.response.ErrorCallback;
import org.eclipse.leshan.core.response.LwM2mResponse;
Expand All @@ -47,11 +47,11 @@ public class CaliforniumLwM2mRequestSender implements LwM2mRequestSender {
private final ScheduledExecutorService executor;
private final boolean attached;
private final CaliforniumEndpointsManager endpointsManager;
private final LwM2mNodeEncoder encoder;
private final LwM2mEncoder encoder;
private final LwM2mModel model;

public CaliforniumLwM2mRequestSender(CaliforniumEndpointsManager endpointsManager,
ScheduledExecutorService sharedExecutor, LwM2mNodeEncoder encoder, LwM2mModel model) {
ScheduledExecutorService sharedExecutor, LwM2mEncoder encoder, LwM2mModel model) {
this.endpointsManager = endpointsManager;
if (sharedExecutor == null) {
this.executor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("Leshan Async Request timeout"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.eclipse.leshan.core.Link;
import org.eclipse.leshan.core.californium.EndpointContextUtil;
import org.eclipse.leshan.core.model.LwM2mModel;
import org.eclipse.leshan.core.node.codec.LwM2mNodeEncoder;
import org.eclipse.leshan.core.node.codec.LwM2mEncoder;
import org.eclipse.leshan.core.request.BindingMode;
import org.eclipse.leshan.core.request.BootstrapRequest;
import org.eclipse.leshan.core.request.ContentFormat;
Expand All @@ -45,10 +45,10 @@ public class CoapRequestBuilder implements UplinkRequestVisitor {

protected Request coapRequest;
protected final Identity server;
protected final LwM2mNodeEncoder encoder;
protected final LwM2mEncoder encoder;
protected final LwM2mModel model;

public CoapRequestBuilder(Identity server, LwM2mNodeEncoder encoder, LwM2mModel model) {
public CoapRequestBuilder(Identity server, LwM2mEncoder encoder, LwM2mModel model) {
this.server = server;
this.encoder = encoder;
this.model = model;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@
import org.eclipse.leshan.core.model.ResourceModel.Operations;
import org.eclipse.leshan.core.model.ResourceModel.Type;
import org.eclipse.leshan.core.model.StaticModel;
import org.eclipse.leshan.core.node.codec.DefaultLwM2mNodeDecoder;
import org.eclipse.leshan.core.node.codec.DefaultLwM2mNodeEncoder;
import org.eclipse.leshan.core.node.codec.DefaultLwM2mDecoder;
import org.eclipse.leshan.core.node.codec.DefaultLwM2mEncoder;
import org.eclipse.leshan.core.util.Hex;
import org.eclipse.leshan.core.util.SecurityUtil;
import org.slf4j.Logger;
Expand Down Expand Up @@ -810,8 +810,8 @@ public void handshakeFailed(Handshaker handshaker, Throwable error) {
builder.setRegistrationEngineFactory(engineFactory);
builder.setEndpointFactory(endpointFactory);
if (supportOldFormat) {
builder.setDecoder(new DefaultLwM2mNodeDecoder(true));
builder.setEncoder(new DefaultLwM2mNodeEncoder(true));
builder.setDecoder(new DefaultLwM2mDecoder(true));
builder.setEncoder(new DefaultLwM2mEncoder(true));
}
builder.setAdditionalAttributes(additionalAttributes);
builder.setBootstrapAdditionalAttributes(bsAdditionalAttributes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
import org.slf4j.LoggerFactory;

/**
* A default {@link LwM2mNodeDecoder}.
* A default {@link LwM2mDecoder}.
* <p>
* For {@link LwM2mNode} decoding, those formats are supported :
* <ul>
Expand All @@ -65,9 +65,9 @@
* <li>{@link ContentFormat#SENML_CBOR}</li>
* </ul>
*/
public class DefaultLwM2mNodeDecoder implements LwM2mNodeDecoder {
public class DefaultLwM2mDecoder implements LwM2mDecoder {

private static final Logger LOG = LoggerFactory.getLogger(DefaultLwM2mNodeDecoder.class);
private static final Logger LOG = LoggerFactory.getLogger(DefaultLwM2mDecoder.class);

public static Map<ContentFormat, NodeDecoder> getDefaultNodeDecoders(boolean supportDeprecatedContentFormat) {
Map<ContentFormat, NodeDecoder> decoders = new HashMap<>();
Expand Down Expand Up @@ -104,29 +104,29 @@ public static Map<ContentFormat, PathDecoder> getDefaultPathDecoder() {
protected final Map<ContentFormat, PathDecoder> pathDecoders;

/**
* Create {@link DefaultLwM2mNodeDecoder} without support of old TLV and JSON code.
* Create {@link DefaultLwM2mDecoder} without support of old TLV and JSON code.
*/
public DefaultLwM2mNodeDecoder() {
public DefaultLwM2mDecoder() {
this(false);
}

/**
* Create {@link DefaultLwM2mNodeDecoder} allowing to enable support for old TLV and JSON code.
* Create {@link DefaultLwM2mDecoder} allowing to enable support for old TLV and JSON code.
* <p>
* Those old codes was used by the LWM2M specification before the official v1.0.0 release and could still be needed
* for backward compatibility.
*
* @param supportDeprecatedContentFormat True to accept to decode old code.
*/
public DefaultLwM2mNodeDecoder(boolean supportDeprecatedContentFormat) {
public DefaultLwM2mDecoder(boolean supportDeprecatedContentFormat) {
this(getDefaultNodeDecoders(supportDeprecatedContentFormat));
}

public DefaultLwM2mNodeDecoder(Map<ContentFormat, NodeDecoder> nodeDecoders) {
public DefaultLwM2mDecoder(Map<ContentFormat, NodeDecoder> nodeDecoders) {
this(nodeDecoders, getDefaultPathDecoder());
}

public DefaultLwM2mNodeDecoder(Map<ContentFormat, NodeDecoder> nodeDecoders,
public DefaultLwM2mDecoder(Map<ContentFormat, NodeDecoder> nodeDecoders,
Map<ContentFormat, PathDecoder> pathDecoders) {
this.nodeDecoders = nodeDecoders;
this.pathDecoders = pathDecoders;
Expand Down
Loading

0 comments on commit d5f3f1b

Please sign in to comment.