Repository: eclipse/leshan
Pull request #220 (2016-12-16 08:35:56)

Observation registry cleanup
Observation registry API cleanup and renaming.

sbernard31: More _"registry"_ detected ;) 

About Observations:
  - 3 in `CaliforniumObservationTest` too.
  - 1 in `LwM2mServer`.
 
About Registrations (so not linked to this PR): 
  - 1 in `RedisRegistrationEventPublisher`.
  - 1 in `QueuedRequestSender`.
  - several in `CoAPMessageTracer`.




Patch:
diff --git a/leshan-server-cf/src/main/java/org/eclipse/leshan/server/californium/CaliforniumObservationRegistry.java b/leshan-server-cf/src/main/java/org/eclipse/leshan/server/californium/CaliforniumObservationRegistry.java
deleted file mode 100644
index aa519e1c..00000000
--- a/leshan-server-cf/src/main/java/org/eclipse/leshan/server/californium/CaliforniumObservationRegistry.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Sierra Wireless and others.
- * 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * and Eclipse Distribution License v1.0 which accompany this distribution.
- * 
- * The Eclipse Public License is available at
- *    http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- *    http://www.eclipse.org/org/documents/edl-v10.html.
- * 
- * Contributors:
- *     Sierra Wireless - initial API and implementation
- *******************************************************************************/
-package org.eclipse.leshan.server.californium;
-
-import org.eclipse.californium.core.network.Endpoint;
-import org.eclipse.californium.core.observe.NotificationListener;
-import org.eclipse.californium.core.observe.ObservationStore;
-import org.eclipse.leshan.server.observation.ObservationRegistry;
-
-public interface CaliforniumObservationRegistry extends ObservationRegistry, NotificationListener {
-
-    ObservationStore getObservationStore();
-
-    void setNonSecureEndpoint(Endpoint endpoint);
-
-    void setSecureEndpoint(Endpoint endpoint);
-}
diff --git a/leshan-server-cf/src/main/java/org/eclipse/leshan/server/californium/impl/CaliforniumLwM2mRequestSender.java b/leshan-server-cf/src/main/java/org/eclipse/leshan/server/californium/impl/CaliforniumLwM2mRequestSender.java
index 426f66e6..e108132d 100644
--- a/leshan-server-cf/src/main/java/org/eclipse/leshan/server/californium/impl/CaliforniumLwM2mRequestSender.java
+++ b/leshan-server-cf/src/main/java/org/eclipse/leshan/server/californium/impl/CaliforniumLwM2mRequestSender.java
@@ -38,7 +38,6 @@ import org.eclipse.leshan.core.response.LwM2mResponse;
 import org.eclipse.leshan.core.response.ResponseCallback;
 import org.eclipse.leshan.server.client.Registration;
 import org.eclipse.leshan.server.model.LwM2mModelProvider;
-import org.eclipse.leshan.server.observation.ObservationRegistry;
 import org.eclipse.leshan.server.request.LwM2mRequestSender;
 import org.eclipse.leshan.server.response.ResponseListener;
 import org.eclipse.leshan.server.response.ResponseProcessingTask;
@@ -48,7 +47,7 @@ import org.eclipse.leshan.util.Validate;
 public class CaliforniumLwM2mRequestSender implements LwM2mRequestSender {
 
     private final Set<Endpoint> endpoints;
-    private final ObservationRegistry observationRegistry;
+    private final ObservationServiceImpl observationService;
     private final LwM2mModelProvider modelProvider;
     private final LwM2mNodeDecoder decoder;
     private final LwM2mNodeEncoder encoder;
@@ -61,15 +60,16 @@ public class CaliforniumLwM2mRequestSender implements LwM2mRequestSender {
 
     /**
      * @param endpoints the CoAP endpoints to use for sending requests
-     * @param observationRegistry the registry for keeping track of observed resources
+     * @param observationService the service for keeping track of observed resources
      * @param modelProvider provides the supported objects definitions
      */
-    public CaliforniumLwM2mRequestSender(final Set<Endpoint> endpoints, final ObservationRegistry observationRegistry,
-            LwM2mModelProvider modelProvider, LwM2mNodeEncoder encoder, LwM2mNodeDecoder decoder) {
+    public CaliforniumLwM2mRequestSender(final Set<Endpoint> endpoints,
+            final ObservationServiceImpl observationService, LwM2mModelProvider modelProvider,
+            LwM2mNodeEncoder encoder, LwM2mNodeDecoder decoder) {
         Validate.notNull(endpoints);
-        Validate.notNull(observationRegistry);
+        Validate.notNull(observationService);
         Validate.notNull(modelProvider);
-        this.observationRegistry = observationRegistry;
+        this.observationService = observationService;
         this.endpoints = endpoints;
         this.modelProvider = modelProvider;
         this.encoder = encoder;
@@ -96,7 +96,7 @@ public class CaliforniumLwM2mRequestSender implements LwM2mRequestSender {
             public T buildResponse(final Response coapResponse) {
                 // Build LwM2m response
                 final LwM2mResponseBuilder<T> lwm2mResponseBuilder = new LwM2mResponseBuilder<T>(coapRequest,
-                        coapResponse, destination, model, observationRegistry, decoder);
+                        coapResponse, destination, model, observationService, decoder);
                 request.accept(lwm2mResponseBuilder);
                 return lwm2mResponseBuilder.getResponse();
             }
@@ -133,7 +133,7 @@ public class CaliforniumLwM2mRequestSender implements LwM2mRequestSender {
             public T buildResponse(final Response coapResponse) {
                 // Build LwM2m response
                 final LwM2mResponseBuilder<T> lwm2mResponseBuilder = new LwM2mResponseBuilder<T>(coapRequest,
-                        coapResponse, destination, model, observationRegistry, decoder);
+                        coapResponse, destination, model, observationService, decoder);
                 request.accept(lwm2mResponseBuilder);
                 return lwm2mResponseBuilder.getResponse();
             }
diff --git a/leshan-server-cf/src/main/java/org/eclipse/leshan/server/californium/impl/LeshanServer.java b/leshan-server-cf/src/main/java/org/eclipse/leshan/server/californium/impl/LeshanServer.java
index 23736537..0ea3c883 100644
--- a/leshan-server-cf/src/main/java/org/eclipse/leshan/server/californium/impl/LeshanServer.java
+++ b/leshan-server-cf/src/main/java/org/eclipse/leshan/server/californium/impl/LeshanServer.java
@@ -45,16 +45,15 @@ import org.eclipse.leshan.server.Destroyable;
 import org.eclipse.leshan.server.LwM2mServer;
 import org.eclipse.leshan.server.Startable;
 import org.eclipse.leshan.server.Stoppable;
-import org.eclipse.leshan.server.californium.CaliforniumObservationRegistry;
 import org.eclipse.leshan.server.californium.CaliforniumRegistrationStore;
 import org.eclipse.leshan.server.californium.LeshanServerBuilder;
 import org.eclipse.leshan.server.client.Registration;
-import org.eclipse.leshan.server.client.RegistrationUpdate;
 import org.eclipse.leshan.server.client.RegistrationListener;
 import org.eclipse.leshan.server.client.RegistrationService;
+import org.eclipse.leshan.server.client.RegistrationUpdate;
 import org.eclipse.leshan.server.impl.RegistrationServiceImpl;
 import org.eclipse.leshan.server.model.LwM2mModelProvider;
-import org.eclipse.leshan.server.observation.ObservationRegistry;
+import org.eclipse.leshan.server.observation.ObservationService;
 import org.eclipse.leshan.server.registration.RegistrationHandler;
 import org.eclipse.leshan.server.request.LwM2mRequestSender;
 import org.eclipse.leshan.server.response.ResponseListener;
@@ -87,7 +86,7 @@ public class LeshanServer implements LwM2mServer {
 
     private final RegistrationServiceImpl registrationService;
 
-    private final CaliforniumObservationRegistry observationRegistry;
+    private final ObservationServiceImpl observationService;
 
     private final SecurityRegistry securityRegistry;
 
@@ -123,7 +122,7 @@ public class LeshanServer implements LwM2mServer {
         // Init registries
         this.registrationService = new RegistrationServiceImpl(registrationStore);
         this.securityRegistry = securityRegistry;
-        this.observationRegistry = new CaliforniumObservationRegistryImpl(registrationStore, modelProvider, decoder);
+        this.observationService = new ObservationServiceImpl(registrationStore, modelProvider, decoder);
         this.modelProvider = modelProvider;
 
         // Cancel observations on client unregistering
@@ -135,7 +134,7 @@ public class LeshanServer implements LwM2mServer {
 
             @Override
             public void unregistered(final Registration registration) {
-                LeshanServer.this.observationRegistry.cancelObservations(registration);
+                LeshanServer.this.observationService.cancelObservations(registration);
                 requestSender.cancelPendingRequests(registration);
             }
 
@@ -152,9 +151,9 @@ public class LeshanServer implements LwM2mServer {
             }
         };
         nonSecureEndpoint = new CoapEndpoint(localAddress, NetworkConfig.getStandard(),
-                this.observationRegistry.getObservationStore());
-        nonSecureEndpoint.addNotificationListener(observationRegistry);
-        observationRegistry.setNonSecureEndpoint(nonSecureEndpoint);
+                this.observationService.getObservationStore());
+        nonSecureEndpoint.addNotificationListener(observationService);
+        observationService.setNonSecureEndpoint(nonSecureEndpoint);
         coapServer.addEndpoint(nonSecureEndpoint);
 
         // secure endpoint
@@ -179,9 +178,9 @@ public class LeshanServer implements LwM2mServer {
         }
 
         secureEndpoint = new CoapEndpoint(new DTLSConnector(builder.build()), NetworkConfig.getStandard(),
-                this.observationRegistry.getObservationStore());
-        secureEndpoint.addNotificationListener(observationRegistry);
-        observationRegistry.setSecureEndpoint(secureEndpoint);
+                this.observationService.getObservationStore());
+        secureEndpoint.addNotificationListener(observationService);
+        observationService.setSecureEndpoint(secureEndpoint);
         coapServer.addEndpoint(secureEndpoint);
 
         // define /rd resource
@@ -193,7 +192,7 @@ public class LeshanServer implements LwM2mServer {
         final Set<Endpoint> endpoints = new HashSet<>();
         endpoints.add(nonSecureEndpoint);
         endpoints.add(secureEndpoint);
-        requestSender = new CaliforniumLwM2mRequestSender(endpoints, this.observationRegistry, modelProvider, encoder,
+        requestSender = new CaliforniumLwM2mRequestSender(endpoints, this.observationService, modelProvider, encoder,
                 decoder);
     }
 
@@ -207,8 +206,8 @@ public class LeshanServer implements LwM2mServer {
         if (securityRegistry instanceof Startable) {
             ((Startable) securityRegistry).start();
         }
-        if (observationRegistry instanceof Startable) {
-            ((Startable) observationRegistry).start();
+        if (observationService instanceof Startable) {
+            ((Startable) observationService).start();
         }
 
         // Start server
@@ -229,8 +228,8 @@ public class LeshanServer implements LwM2mServer {
         if (securityRegistry instanceof Stoppable) {
             ((Stoppable) securityRegistry).stop();
         }
-        if (observationRegistry instanceof Stoppable) {
-            ((Stoppable) observationRegistry).stop();
+        if (observationService instanceof Stoppable) {
+            ((Stoppable) observationService).stop();
         }
 
         LOG.info("LWM2M server stopped.");
@@ -247,8 +246,8 @@ public class LeshanServer implements LwM2mServer {
         if (securityRegistry instanceof Destroyable) {
             ((Destroyable) securityRegistry).destroy();
         }
-        if (observationRegistry instanceof Destroyable) {
-            ((Destroyable) observationRegistry).destroy();
+        if (observationService instanceof Destroyable) {
+            ((Destroyable) observationService).destroy();
         }
 
         LOG.info("LWM2M server destroyed.");
@@ -260,8 +259,8 @@ public class LeshanServer implements LwM2mServer {
     }
 
     @Override
-    public ObservationRegistry getObservationRegistry() {
-        return this.observationRegistry;
+    public ObservationService getObservationService() {
+        return this.observationService;
     }
 
     @Override
diff --git a/leshan-server-cf/src/main/java/org/eclipse/leshan/server/californium/impl/LwM2mResponseBuilder.java b/leshan-server-cf/src/main/java/org/eclipse/leshan/server/californium/impl/LwM2mResponseBuilder.java
index 5d4c66f9..fd6a89be 100644
--- a/leshan-server-cf/src/main/java/org/eclipse/leshan/server/californium/impl/LwM2mResponseBuilder.java
+++ b/leshan-server-cf/src/main/java/org/eclipse/leshan/server/californium/impl/LwM2mResponseBuilder.java
@@ -54,7 +54,6 @@ import org.eclipse.leshan.core.response.ReadResponse;
 import org.eclipse.leshan.core.response.WriteAttributesResponse;
 import org.eclipse.leshan.core.response.WriteResponse;
 import org.eclipse.leshan.server.client.Registration;
-import org.eclipse.leshan.server.observation.ObservationRegistry;
 import org.eclipse.leshan.util.Validate;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -66,7 +65,7 @@ public class LwM2mResponseBuilder<T extends LwM2mResponse> implements DownlinkRe
     private LwM2mResponse lwM2mresponse;
     private final Request coapRequest;
     private final Response coapResponse;
-    private final ObservationRegistry observationRegistry;
+    private final ObservationServiceImpl observationService;
     private final Registration registration;
     private final LwM2mModel model;
     private final LwM2mNodeDecoder decoder;
@@ -106,10 +105,11 @@ public class LwM2mResponseBuilder<T extends LwM2mResponse> implements DownlinkRe
     }
 
     public LwM2mResponseBuilder(final Request coapRequest, final Response coapResponse, final Registration registration,
-            final LwM2mModel model, final ObservationRegistry observationRegistry, final LwM2mNodeDecoder decoder) {
+            final LwM2mModel model, final ObservationServiceImpl observationService,
+            final LwM2mNodeDecoder decoder) {
         this.coapRequest = coapRequest;
         this.coapResponse = coapResponse;
-        this.observationRegistry = observationRegistry;
+        this.observationService = observationService;
         this.registration = registration;
         this.model = model;
         this.decoder = decoder;
@@ -274,10 +274,10 @@ public class LwM2mResponseBuilder<T extends LwM2mResponse> implements DownlinkRe
         case CONTENT:
             LwM2mNode content = decodeCoapResponse(request.getPath(), coapResponse);
             if (coapResponse.getOptions().hasObserve()) {
-                // observe request succeed so we can add and observation to registry
+                // observe request successful
                 Observation observation = new Observation(coapRequest.getToken(), registration.getId(),
                         request.getPath(), request.getContext());
-                observationRegistry.addObservation(observation);
+                observationService.addObservation(observation);
                 // add the observation to an ObserveResponse instance
                 lwM2mresponse = new ObserveResponse(ResponseCode.CONTENT, content, null, observation, null,
                         coapResponse);
diff --git a/leshan-server-cf/src/main/java/org/eclipse/leshan/server/californium/impl/CaliforniumObservationRegistryImpl.java b/leshan-server-cf/src/main/java/org/eclipse/leshan/server/californium/impl/ObservationServiceImpl.java
similarity index 88%
rename from leshan-server-cf/src/main/java/org/eclipse/leshan/server/californium/impl/CaliforniumObservationRegistryImpl.java
rename to leshan-server-cf/src/main/java/org/eclipse/leshan/server/californium/impl/ObservationServiceImpl.java
index a93d4a17..0742e344 100644
--- a/leshan-server-cf/src/main/java/org/eclipse/leshan/server/californium/impl/CaliforniumObservationRegistryImpl.java
+++ b/leshan-server-cf/src/main/java/org/eclipse/leshan/server/californium/impl/ObservationServiceImpl.java
@@ -29,6 +29,7 @@ import org.eclipse.californium.core.coap.CoAP;
 import org.eclipse.californium.core.coap.Request;
 import org.eclipse.californium.core.coap.Response;
 import org.eclipse.californium.core.network.Endpoint;
+import org.eclipse.californium.core.observe.NotificationListener;
 import org.eclipse.californium.core.observe.ObservationStore;
 import org.eclipse.leshan.ResponseCode;
 import org.eclipse.leshan.core.model.LwM2mModel;
@@ -39,23 +40,23 @@ import org.eclipse.leshan.core.node.codec.LwM2mNodeDecoder;
 import org.eclipse.leshan.core.observation.Observation;
 import org.eclipse.leshan.core.request.ContentFormat;
 import org.eclipse.leshan.core.response.ObserveResponse;
-import org.eclipse.leshan.server.californium.CaliforniumObservationRegistry;
 import org.eclipse.leshan.server.californium.CaliforniumRegistrationStore;
 import org.eclipse.leshan.server.client.Registration;
 import org.eclipse.leshan.server.model.LwM2mModelProvider;
-import org.eclipse.leshan.server.observation.ObservationRegistryListener;
+import org.eclipse.leshan.server.observation.ObservationService;
+import org.eclipse.leshan.server.observation.ObservationListener;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * Implementation of the {@link CaliforniumObservationRegistry} accessing the persisted observation via the provided
+ * Implementation of the {@link ObservationService} accessing the persisted observation via the provided
  * {@link LwM2mObservationStore}.
  * 
  * When a new observation is added or changed or canceled, the registered listeners are notified.
  */
-public class CaliforniumObservationRegistryImpl implements CaliforniumObservationRegistry {
+public class ObservationServiceImpl implements ObservationService, NotificationListener {
 
-    private final Logger LOG = LoggerFactory.getLogger(CaliforniumObservationRegistry.class);
+    private final Logger LOG = LoggerFactory.getLogger(ObservationServiceImpl.class);
 
     private final CaliforniumRegistrationStore registrationStore;
     private final LwM2mModelProvider modelProvider;
@@ -63,23 +64,22 @@ public class CaliforniumObservationRegistryImpl implements CaliforniumObservatio
     private Endpoint secureEndpoint;
     private Endpoint nonSecureEndpoint;
 
-    private final List<ObservationRegistryListener> listeners = new CopyOnWriteArrayList<>();
+    private final List<ObservationListener> listeners = new CopyOnWriteArrayList<>();
 
     /**
-     * Creates an instance of {@link CaliforniumObservationRegistryImpl}
+     * Creates an instance of {@link ObservationServiceImpl}
      * 
      * @param store instance of californium's {@link ObservationStore}
      * @param modelProvider instance of {@link LwM2mModelProvider}
      * @param decoder instance of {@link LwM2mNodeDecoder}
      */
-    public CaliforniumObservationRegistryImpl(CaliforniumRegistrationStore store,
-            LwM2mModelProvider modelProvider, LwM2mNodeDecoder decoder) {
+    public ObservationServiceImpl(CaliforniumRegistrationStore store, LwM2mModelProvider modelProvider,
+            LwM2mNodeDecoder decoder) {
         this.registrationStore = store;
         this.modelProvider = modelProvider;
         this.decoder = decoder;
     }
 
-    @Override
     public void addObservation(Observation observation) {
         // cancel any other observation for the same path and registration id.
         // delegate this to the observation store to avoid race conditions on add/cancel?
@@ -91,17 +91,15 @@ public class CaliforniumObservationRegistryImpl implements CaliforniumObservatio
 
         // the observation is already persisted by the CoAP layer
 
-        for (ObservationRegistryListener listener : listeners) {
+        for (ObservationListener listener : listeners) {
             listener.newObservation(observation);
         }
     }
 
-    @Override
     public void setNonSecureEndpoint(Endpoint endpoint) {
         nonSecureEndpoint = endpoint;
     }
 
-    @Override
     public void setSecureEndpoint(Endpoint endpoint) {
         secureEndpoint = endpoint;
     }
@@ -124,7 +122,7 @@ public class CaliforniumObservationRegistryImpl implements CaliforniumObservatio
             if (nonSecureEndpoint != null)
                 nonSecureEndpoint.cancelObservation(observation.getId());
 
-            for (ObservationRegistryListener listener : listeners) {
+            for (ObservationListener listener : listeners) {
                 listener.cancelled(observation);
             }
         }
@@ -155,7 +153,7 @@ public class CaliforniumObservationRegistryImpl implements CaliforniumObservatio
             nonSecureEndpoint.cancelObservation(observation.getId());
         registrationStore.removeObservation(observation.getRegistrationId(), observation.getId());
 
-        for (ObservationRegistryListener listener : listeners) {
+        for (ObservationListener listener : listeners) {
             listener.cancelled(observation);
         }
     }
@@ -186,18 +184,20 @@ public class CaliforniumObservationRegistryImpl implements CaliforniumObservatio
         return result;
     }
 
-    @Override
+    /**
+     * @return the Californium {@link ObservationStore}
+     */
     public ObservationStore getObservationStore() {
         return registrationStore;
     }
 
     @Override
-    public void addListener(ObservationRegistryListener listener) {
+    public void addListener(ObservationListener listener) {
         listeners.add(listener);
     }
 
     @Override
-    public void removeListener(ObservationRegistryListener listener) {
+    public void removeListener(ObservationListener listener) {
         listeners.remove(listener);
     }
 
@@ -251,7 +251,7 @@ public class CaliforniumObservationRegistryImpl implements CaliforniumObservatio
                 }
 
                 // notify all listeners
-                for (ObservationRegistryListener listener : listeners) {
+                for (ObservationListener listener : listeners) {
                     listener.newValue(observation, response);
                 }
             } catch (InvalidValueException e) {
diff --git a/leshan-server-cluster/src/main/java/org/eclipse/leshan/server/cluster/LeshanClusterServer.java b/leshan-server-cluster/src/main/java/org/eclipse/leshan/server/cluster/LeshanClusterServer.java
index 8f28342a..22a147cf 100644
--- a/leshan-server-cluster/src/main/java/org/eclipse/leshan/server/cluster/LeshanClusterServer.java
+++ b/leshan-server-cluster/src/main/java/org/eclipse/leshan/server/cluster/LeshanClusterServer.java
@@ -165,7 +165,7 @@ public class LeshanClusterServer {
         // Create Clustering support
         RedisTokenHandler tokenHandler = new RedisTokenHandler(jedis, clusterInstanceId);
         new RedisRequestResponseHandler(jedis, lwServer, lwServer.getRegistrationService(), tokenHandler,
-                lwServer.getObservationRegistry());
+                lwServer.getObservationService());
         lwServer.getRegistrationService().addListener(tokenHandler);
         lwServer.getRegistrationService().addListener(new RedisRegistrationEventPublisher(jedis));
 
diff --git a/leshan-server-cluster/src/main/java/org/eclipse/leshan/server/cluster/RedisRequestResponseHandler.java b/leshan-server-cluster/src/main/java/org/eclipse/leshan/server/cluster/RedisRequestResponseHandler.java
index 37ee889a..88238e11 100644
--- a/leshan-server-cluster/src/main/java/org/eclipse/leshan/server/cluster/RedisRequestResponseHandler.java
+++ b/leshan-server-cluster/src/main/java/org/eclipse/leshan/server/cluster/RedisRequestResponseHandler.java
@@ -32,8 +32,8 @@ import org.eclipse.leshan.server.client.Registration;
 import org.eclipse.leshan.server.client.RegistrationService;
 import org.eclipse.leshan.server.cluster.serialization.DownlinkRequestSerDes;
 import org.eclipse.leshan.server.cluster.serialization.ResponseSerDes;
-import org.eclipse.leshan.server.observation.ObservationRegistry;
-import org.eclipse.leshan.server.observation.ObservationRegistryListener;
+import org.eclipse.leshan.server.observation.ObservationService;
+import org.eclipse.leshan.server.observation.ObservationListener;
 import org.eclipse.leshan.server.response.ResponseListener;
 import org.eclipse.leshan.util.NamedThreadFactory;
 import org.slf4j.Logger;
@@ -63,21 +63,21 @@ public class RedisRequestResponseHandler {
     private final RegistrationService registrationService;
     private final ExecutorService executorService;
     private final RedisTokenHandler tokenHandler;
-    private final ObservationRegistry observationRegistry;
+    private final ObservationService observationService;
     private final Map<KeyId, String> observatioIdToTicket = new ConcurrentHashMap<>();
 
     public RedisRequestResponseHandler(Pool<Jedis> p, LwM2mServer server, RegistrationService registrationService,
-            RedisTokenHandler tokenHandler, ObservationRegistry observationRegistry) {
+            RedisTokenHandler tokenHandler, ObservationService observationService) {
         // Listen LWM2M response
         this.server = server;
         this.registrationService = registrationService;
-        this.observationRegistry = observationRegistry;
+        this.observationService = observationService;
         this.tokenHandler = tokenHandler;
         this.executorService = Executors.newCachedThreadPool(
                 new NamedThreadFactory(String.format("Redis %s channel writer", RESPONSE_CHANNEL)));
 
         // Listen LWM2M notification from client
-        this.observationRegistry.addListener(new ObservationRegistryListener() {
+        this.observationService.addListener(new ObservationListener() {
 
             @Override
             public void newValue(Observation observation, ObserveResponse response) {
diff --git a/leshan-server-core/src/main/java/org/eclipse/leshan/server/LwM2mServer.java b/leshan-server-core/src/main/java/org/eclipse/leshan/server/LwM2mServer.java
index f712b532..740bd190 100644
--- a/leshan-server-core/src/main/java/org/eclipse/leshan/server/LwM2mServer.java
+++ b/leshan-server-core/src/main/java/org/eclipse/leshan/server/LwM2mServer.java
@@ -22,7 +22,7 @@ import org.eclipse.leshan.core.response.ResponseCallback;
 import org.eclipse.leshan.server.client.Registration;
 import org.eclipse.leshan.server.client.RegistrationService;
 import org.eclipse.leshan.server.model.LwM2mModelProvider;
-import org.eclipse.leshan.server.observation.ObservationRegistry;
+import org.eclipse.leshan.server.observation.ObservationService;
 import org.eclipse.leshan.server.response.ResponseListener;
 import org.eclipse.leshan.server.security.SecurityRegistry;
 
@@ -112,10 +112,10 @@ public interface LwM2mServer {
     RegistrationService getRegistrationService();
 
     /**
-     * Get the Observation registry containing of current observation. You can use this object for listening resource
+     * Get the Observation service to access current observations. You can use this object for listening resource
      * observation or cancel it.
      */
-    ObservationRegistry getObservationRegistry();
+    ObservationService getObservationService();
 
     /**
      * Get the SecurityRegistry containing of security information.
diff --git a/leshan-server-core/src/main/java/org/eclipse/leshan/server/observation/ObservationRegistryListener.java b/leshan-server-core/src/main/java/org/eclipse/leshan/server/observation/ObservationListener.java
similarity index 96%
rename from leshan-server-core/src/main/java/org/eclipse/leshan/server/observation/ObservationRegistryListener.java
rename to leshan-server-core/src/main/java/org/eclipse/leshan/server/observation/ObservationListener.java
index 7a4a869f..9dc88d50 100644
--- a/leshan-server-core/src/main/java/org/eclipse/leshan/server/observation/ObservationRegistryListener.java
+++ b/leshan-server-core/src/main/java/org/eclipse/leshan/server/observation/ObservationListener.java
@@ -18,7 +18,8 @@ package org.eclipse.leshan.server.observation;
 import org.eclipse.leshan.core.observation.Observation;
 import org.eclipse.leshan.core.response.ObserveResponse;
 
-public interface ObservationRegistryListener {
+public interface ObservationListener {
+
     void newObservation(Observation observation);
 
     void cancelled(Observation observation);
diff --git a/leshan-server-core/src/main/java/org/eclipse/leshan/server/observation/ObservationRegistry.java b/leshan-server-core/src/main/java/org/eclipse/leshan/server/observation/ObservationService.java
similarity index 85%
rename from leshan-server-core/src/main/java/org/eclipse/leshan/server/observation/ObservationRegistry.java
rename to leshan-server-core/src/main/java/org/eclipse/leshan/server/observation/ObservationService.java
index e3f600af..d7848b7e 100644
--- a/leshan-server-core/src/main/java/org/eclipse/leshan/server/observation/ObservationRegistry.java
+++ b/leshan-server-core/src/main/java/org/eclipse/leshan/server/observation/ObservationService.java
@@ -21,17 +21,9 @@ import org.eclipse.leshan.core.observation.Observation;
 import org.eclipse.leshan.server.client.Registration;
 
 /**
- * A registry for keeping track of observed resources implemented by LWM2M Clients.
- * 
+ * A service keeping track observation. Can be used for finding observations and cancel them.
  */
-public interface ObservationRegistry {
-
-    /**
-     * Adds an observation of resource(s) to the registry.
-     * 
-     * @param observation the observation
-     */
-    void addObservation(Observation observation);
+public interface ObservationService {
 
     /**
      * Cancels all active observations of resource(s) implemented by a particular LWM2M registration.
@@ -73,7 +65,7 @@ public interface ObservationRegistry {
      */
     Set<Observation> getObservations(Registration registration);
 
-    void addListener(ObservationRegistryListener listener);
+    void addListener(ObservationListener listener);
 
-    void removeListener(ObservationRegistryListener listener);
+    void removeListener(ObservationListener listener);
 }
diff --git a/leshan-server-core/src/main/java/org/eclipse/leshan/server/queue/impl/QueuedRequestSender.java b/leshan-server-core/src/main/java/org/eclipse/leshan/server/queue/impl/QueuedRequestSender.java
index f263319f..6587c583 100644
--- a/leshan-server-core/src/main/java/org/eclipse/leshan/server/queue/impl/QueuedRequestSender.java
+++ b/leshan-server-core/src/main/java/org/eclipse/leshan/server/queue/impl/QueuedRequestSender.java
@@ -38,8 +38,8 @@ import org.eclipse.leshan.server.client.Registration;
 import org.eclipse.leshan.server.client.RegistrationListener;
 import org.eclipse.leshan.server.client.RegistrationService;
 import org.eclipse.leshan.server.client.RegistrationUpdate;
-import org.eclipse.leshan.server.observation.ObservationRegistry;
-import org.eclipse.leshan.server.observation.ObservationRegistryListener;
+import org.eclipse.leshan.server.observation.ObservationListener;
+import org.eclipse.leshan.server.observation.ObservationService;
 import org.eclipse.leshan.server.queue.MessageStore;
 import org.eclipse.leshan.server.queue.QueuedRequest;
 import org.eclipse.leshan.server.request.LwM2mRequestSender;
@@ -62,9 +62,9 @@ public class QueuedRequestSender implements LwM2mRequestSender, Stoppable {
             .newCachedThreadPool(new NamedThreadFactory("leshan-qmode-processingExecutor-%d"));
     private final MessageStore messageStore;
     private final QueueModeRegistrationListener queueModeRegistrationListener;
-    private final QueueModeObservationRegistryListener queueModeObservationRegistryListener;
+    private final QueueModeObservationListener queueModeObservationListener;
     private final RegistrationService registrationService;
-    private final ObservationRegistry observationRegistry;
+    private final ObservationService observationService;
     private final ClientStatusTracker clientStatusTracker;
     private final Collection<ResponseListener> responseListeners = new ConcurrentLinkedQueue<>();
 
@@ -78,15 +78,15 @@ public class QueuedRequestSender implements LwM2mRequestSender, Stoppable {
     private QueuedRequestSender(Builder builder) {
         this.messageStore = builder.messageStore;
         this.registrationService = builder.registrationService;
-        this.observationRegistry = builder.observationRegistry;
+        this.observationService = builder.observationService;
         this.delegateSender = builder.delegateSender;
 
         this.clientStatusTracker = new ClientStatusTracker();
 
         this.queueModeRegistrationListener = new QueueModeRegistrationListener();
         registrationService.addListener(queueModeRegistrationListener);
-        this.queueModeObservationRegistryListener = new QueueModeObservationRegistryListener();
-        observationRegistry.addListener(queueModeObservationRegistryListener);
+        this.queueModeObservationListener = new QueueModeObservationListener();
+        observationService.addListener(queueModeObservationListener);
         delegateSender.addResponseListener(createResponseListener());
     }
 
@@ -158,7 +158,7 @@ public class QueuedRequestSender implements LwM2mRequestSender, Stoppable {
     @Override
     public void stop() {
         registrationService.removeListener(queueModeRegistrationListener);
-        observationRegistry.removeListener(queueModeObservationRegistryListener);
+        observationService.removeListener(queueModeObservationListener);
         processingExecutor.shutdown();
         try {
             boolean queueProcessingExecutorTerminated = processingExecutor.awaitTermination(5, TimeUnit.SECONDS);
@@ -258,7 +258,7 @@ public class QueuedRequestSender implements LwM2mRequestSender, Stoppable {
                 clientEndpoint);
     }
 
-    private final class QueueModeObservationRegistryListener implements ObservationRegistryListener {
+    private final class QueueModeObservationListener implements ObservationListener {
         @Override
         public void newValue(Observation observation, ObserveResponse response) {
             Registration registration = registrationService.getById(observation.getRegistrationId());
@@ -332,7 +332,7 @@ public class QueuedRequestSender implements LwM2mRequestSender, Stoppable {
         private MessageStore messageStore;
         private LwM2mRequestSender delegateSender;
         private RegistrationService registrationService;
-        private ObservationRegistry observationRegistry;
+        private ObservationService observationService;
 
         public Builder setMessageStore(MessageStore messageStore) {
             this.messageStore = messageStore;
@@ -349,8 +349,8 @@ public class QueuedRequestSender implements LwM2mRequestSender, Stoppable {
             return this;
         }
 
-        public Builder setObservationRegistry(ObservationRegistry observationRegistry) {
-            this.observationRegistry = observationRegistry;
+        public Builder setObservationService(ObservationService observationService) {
+            this.observationService = observationService;
             return this;
         }
 
@@ -358,7 +358,7 @@ public class QueuedRequestSender implements LwM2mRequestSender, Stoppable {
             Validate.notNull(messageStore, "messageStore cannot be null");
             Validate.notNull(delegateSender, "delegateSender cannot be null");
             Validate.notNull(registrationService, "registrationService cannot be null");
-            Validate.notNull(observationRegistry, "observationRegistry cannot be null");
+            Validate.notNull(observationService, "observationService cannot be null");
 
             return new QueuedRequestSender(this);
         }
diff --git a/leshan-server-demo/src/main/java/org/eclipse/leshan/server/demo/servlet/ClientServlet.java b/leshan-server-demo/src/main/java/org/eclipse/leshan/server/demo/servlet/ClientServlet.java
index 901f80d2..1add9f04 100644
--- a/leshan-server-demo/src/main/java/org/eclipse/leshan/server/demo/servlet/ClientServlet.java
+++ b/leshan-server-demo/src/main/java/org/eclipse/leshan/server/demo/servlet/ClientServlet.java
@@ -329,7 +329,7 @@ public class ClientServlet extends HttpServlet {
                 String target = StringUtils.substringsBetween(req.getPathInfo(), clientEndpoint, "/observe")[0];
                 Registration registration = server.getRegistrationService().getByEndpoint(clientEndpoint);
                 if (registration != null) {
-                    server.getObservationRegistry().cancelObservations(registration, target);
+                    server.getObservationService().cancelObservations(registration, target);
                     resp.setStatus(HttpServletResponse.SC_OK);
                 } else {
                     resp.setStatus(HttpServletResponse.SC_BAD_REQUEST);
diff --git a/leshan-server-demo/src/main/java/org/eclipse/leshan/server/demo/servlet/EventServlet.java b/leshan-server-demo/src/main/java/org/eclipse/leshan/server/demo/servlet/EventServlet.java
index 06c8ec23..70fd3860 100644
--- a/leshan-server-demo/src/main/java/org/eclipse/leshan/server/demo/servlet/EventServlet.java
+++ b/leshan-server-demo/src/main/java/org/eclipse/leshan/server/demo/servlet/EventServlet.java
@@ -37,7 +37,7 @@ import org.eclipse.leshan.server.demo.servlet.log.CoapMessageListener;
 import org.eclipse.leshan.server.demo.servlet.log.CoapMessageTracer;
 import org.eclipse.leshan.server.demo.utils.EventSource;
 import org.eclipse.leshan.server.demo.utils.EventSourceServlet;
-import org.eclipse.leshan.server.observation.ObservationRegistryListener;
+import org.eclipse.leshan.server.observation.ObservationListener;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -92,7 +92,7 @@ public class EventServlet extends EventSourceServlet {
         }
     };
 
-    private final ObservationRegistryListener observationRegistryListener = new ObservationRegistryListener() {
+    private final ObservationListener observationListener = new ObservationListener() {
 
         @Override
         public void cancelled(Observation observation) {
@@ -124,7 +124,7 @@ public class EventServlet extends EventSourceServlet {
     public EventServlet(LeshanServer server, int securePort) {
         this.server = server;
         server.getRegistrationService().addListener(this.registrationListener);
-        server.getObservationRegistry().addListener(this.observationRegistryListener);
+        server.getObservationService().addListener(this.observationListener);
 
         // add an interceptor to each endpoint to trace all CoAP messages
         coapMessageTracer = new CoapMessageTracer(server.getRegistrationService());


Test patch:
diff --git a/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/ObserveTest.java b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/ObserveTest.java
index 9e559344..e14aa284 100644
--- a/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/ObserveTest.java
+++ b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/ObserveTest.java
@@ -50,7 +50,7 @@ import org.eclipse.leshan.core.request.WriteRequest;
 import org.eclipse.leshan.core.response.LwM2mResponse;
 import org.eclipse.leshan.core.response.ObserveResponse;
 import org.eclipse.leshan.core.response.ReadResponse;
-import org.eclipse.leshan.server.observation.ObservationRegistryListener;
+import org.eclipse.leshan.server.observation.ObservationListener;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -79,7 +79,7 @@ public class ObserveTest {
     @Test
     public void can_observe_resource() throws InterruptedException {
         TestObservationListener listener = new TestObservationListener();
-        helper.server.getObservationRegistry().addListener(listener);
+        helper.server.getObservationService().addListener(listener);
 
         // observe device timezone
         ObserveResponse observeResponse = helper.server.send(helper.getCurrentRegistration(), new ObserveRequest(3, 0, 15));
@@ -108,7 +108,7 @@ public class ObserveTest {
     @Test
     public void can_observe_instance() throws InterruptedException {
         TestObservationListener listener = new TestObservationListener();
-        helper.server.getObservationRegistry().addListener(listener);
+        helper.server.getObservationService().addListener(listener);
 
         // observe device timezone
         ObserveResponse observeResponse = helper.server.send(helper.getCurrentRegistration(), new ObserveRequest(3, 0));
@@ -142,7 +142,7 @@ public class ObserveTest {
     @Test
     public void can_observe_object() throws InterruptedException {
         TestObservationListener listener = new TestObservationListener();
-        helper.server.getObservationRegistry().addListener(listener);
+        helper.server.getObservationService().addListener(listener);
 
         // observe device timezone
         ObserveResponse observeResponse = helper.server.send(helper.getCurrentRegistration(), new ObserveRequest(3));
@@ -176,7 +176,7 @@ public class ObserveTest {
     @Test
     public void can_observe_timestamped_resource() throws InterruptedException {
         TestObservationListener listener = new TestObservationListener();
-        helper.server.getObservationRegistry().addListener(listener);
+        helper.server.getObservationService().addListener(listener);
 
         // observe device timezone
         ObserveResponse observeResponse = helper.server.send(helper.getCurrentRegistration(),
@@ -216,7 +216,7 @@ public class ObserveTest {
     @Test
     public void can_observe_timestamped_instance() throws InterruptedException {
         TestObservationListener listener = new TestObservationListener();
-        helper.server.getObservationRegistry().addListener(listener);
+        helper.server.getObservationService().addListener(listener);
 
         // observe device timezone
         ObserveResponse observeResponse = helper.server.send(helper.getCurrentRegistration(),
@@ -256,7 +256,7 @@ public class ObserveTest {
     @Test
     public void can_observe_timestamped_object() throws InterruptedException {
         TestObservationListener listener = new TestObservationListener();
-        helper.server.getObservationRegistry().addListener(listener);
+        helper.server.getObservationService().addListener(listener);
 
         // observe device timezone
         ObserveResponse observeResponse = helper.server.send(helper.getCurrentRegistration(),
@@ -322,7 +322,7 @@ public class ObserveTest {
         }
     }
 
-    private final class TestObservationListener implements ObservationRegistryListener {
+    private final class TestObservationListener implements ObservationListener {
 
         private final CountDownLatch latch = new CountDownLatch(1);
         private final AtomicBoolean receivedNotify = new AtomicBoolean();
diff --git a/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/QueueModeIntegrationTestHelper.java b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/QueueModeIntegrationTestHelper.java
index 8c2d727b..bb652db8 100644
--- a/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/QueueModeIntegrationTestHelper.java
+++ b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/QueueModeIntegrationTestHelper.java
@@ -42,7 +42,7 @@ import org.eclipse.leshan.core.response.ExecuteResponse;
 import org.eclipse.leshan.integration.tests.util.QueueModeLeshanServer;
 import org.eclipse.leshan.integration.tests.util.QueuedModeLeshanClient;
 import org.eclipse.leshan.server.californium.impl.CaliforniumLwM2mRequestSender;
-import org.eclipse.leshan.server.californium.impl.CaliforniumObservationRegistryImpl;
+import org.eclipse.leshan.server.californium.impl.ObservationServiceImpl;
 import org.eclipse.leshan.server.californium.impl.InMemoryRegistrationStore;
 import org.eclipse.leshan.server.californium.impl.RegisterResource;
 import org.eclipse.leshan.server.client.Registration;
@@ -115,22 +115,22 @@ public class QueueModeIntegrationTestHelper extends IntegrationTestHelper {
         LwM2mModelProvider modelProvider = new StandardModelProvider();
         LwM2mNodeEncoder encoder = new DefaultLwM2mNodeEncoder();
         LwM2mNodeDecoder decoder = new DefaultLwM2mNodeDecoder();
-        CaliforniumObservationRegistryImpl observationRegistry = new CaliforniumObservationRegistryImpl(
+        ObservationServiceImpl observationService = new ObservationServiceImpl(
                 registrationStore, modelProvider, decoder);
-        observationRegistry.setSecureEndpoint(secureEndpoint);
-        secureEndpoint.addNotificationListener(observationRegistry);
-        observationRegistry.setNonSecureEndpoint(noSecureEndpoint);
-        noSecureEndpoint.addNotificationListener(observationRegistry);
+        observationService.setSecureEndpoint(secureEndpoint);
+        secureEndpoint.addNotificationListener(observationService);
+        observationService.setNonSecureEndpoint(noSecureEndpoint);
+        noSecureEndpoint.addNotificationListener(observationService);
         LwM2mRequestSender delegateSender = new CaliforniumLwM2mRequestSender(new HashSet<>(coapServer.getEndpoints()),
-                observationRegistry, modelProvider, encoder, decoder);
+                observationService, modelProvider, encoder, decoder);
         LwM2mRequestSender secondDelegateSender = new CaliforniumLwM2mRequestSender(
-                new HashSet<>(coapServer.getEndpoints()), observationRegistry, modelProvider, encoder, decoder);
+                new HashSet<>(coapServer.getEndpoints()), observationService, modelProvider, encoder, decoder);
         QueuedRequestSender queueRequestSender = QueuedRequestSender.builder().setMessageStore(inMemoryMessageStore)
                 .setRequestSender(secondDelegateSender).setRegistrationService(registrationService)
-                .setObservationRegistry(observationRegistry).build();
+                .setObservationService(observationService).build();
         LwM2mRequestSender lwM2mRequestSender = new LwM2mRequestSenderImpl(delegateSender, queueRequestSender);
 
-        server = new QueueModeLeshanServer(coapServer, registrationService, observationRegistry, securityRegistry,
+        server = new QueueModeLeshanServer(coapServer, registrationService, observationService, securityRegistry,
                 modelProvider, lwM2mRequestSender, inMemoryMessageStore);
     }
 
diff --git a/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/QueueModeTest.java b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/QueueModeTest.java
index 21f18e39..1fd4b618 100644
--- a/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/QueueModeTest.java
+++ b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/QueueModeTest.java
@@ -39,7 +39,7 @@ import org.eclipse.leshan.core.response.WriteResponse;
 import org.eclipse.leshan.integration.tests.util.QueuedModeLeshanClient;
 import org.eclipse.leshan.integration.tests.util.QueuedModeLeshanClient.OnGetCallback;
 import org.eclipse.leshan.server.client.Registration;
-import org.eclipse.leshan.server.observation.ObservationRegistryListener;
+import org.eclipse.leshan.server.observation.ObservationListener;
 import org.eclipse.leshan.server.queue.MessageStore;
 import org.eclipse.leshan.server.queue.impl.InMemoryMessageStore;
 import org.eclipse.leshan.server.response.ResponseListener;
@@ -219,7 +219,7 @@ public class QueueModeTest {
     @Test
     public void request_sent_after_client_notify() throws Exception {
         TestObservationListener listener = new TestObservationListener();
-        helper.server.getObservationRegistry().addListener(listener);
+        helper.server.getObservationService().addListener(listener);
         // stop default client as we need client with a custom life time.
         helper.client.stop(false);
 
@@ -282,7 +282,7 @@ public class QueueModeTest {
     @Test
     public void all_requests_sent_if_client_reachable() throws Exception {
         TestObservationListener listener = new TestObservationListener();
-        helper.server.getObservationRegistry().addListener(listener);
+        helper.server.getObservationService().addListener(listener);
         QueuedModeLeshanClient client = (QueuedModeLeshanClient) helper.client;
 
         responseListener = new ResponseListener() {
@@ -350,7 +350,7 @@ public class QueueModeTest {
     @Test
     public void no_duplicate_send_on_consecutive_notifies() throws Exception {
         TestObservationListener listener = new TestObservationListener();
-        helper.server.getObservationRegistry().addListener(listener);
+        helper.server.getObservationService().addListener(listener);
         // stop default client as we need client with a custom life time.
         helper.client.stop(false);
 
@@ -665,7 +665,7 @@ public class QueueModeTest {
         };
     }
 
-    private final class TestObservationListener implements ObservationRegistryListener {
+    private final class TestObservationListener implements ObservationListener {
 
         private CountDownLatch latch = new CountDownLatch(1);
         private final AtomicBoolean receivedNotify = new AtomicBoolean();
diff --git a/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/RegistrationTest.java b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/RegistrationTest.java
index e66dde90..d9c7f7d5 100644
--- a/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/RegistrationTest.java
+++ b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/RegistrationTest.java
@@ -213,7 +213,7 @@ public class RegistrationTest {
 
         // check observation registry is not null
         Registration currentRegistration = helper.getCurrentRegistration();
-        Set<Observation> observations = helper.server.getObservationRegistry()
+        Set<Observation> observations = helper.server.getObservationService()
                 .getObservations(currentRegistration);
         assertEquals(1, observations.size());
         Observation obs = observations.iterator().next();
@@ -224,7 +224,7 @@ public class RegistrationTest {
         helper.client.stop(true);
         helper.waitForDeregistration(1);
         helper.assertClientNotRegisterered();
-        observations = helper.server.getObservationRegistry()
+        observations = helper.server.getObservationService()
                 .getObservations(currentRegistration);
         assertTrue(observations.isEmpty());
 
@@ -233,7 +233,7 @@ public class RegistrationTest {
         assertNull(observeResponse);
 
         // check observationStore is empty
-        observations = helper.server.getObservationRegistry().getObservations(currentRegistration);
+        observations = helper.server.getObservationService().getObservations(currentRegistration);
         assertTrue(observations.isEmpty());
     }
 
diff --git a/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/util/QueueModeLeshanServer.java b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/util/QueueModeLeshanServer.java
index 29dad2fe..28c66f82 100644
--- a/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/util/QueueModeLeshanServer.java
+++ b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/util/QueueModeLeshanServer.java
@@ -26,11 +26,11 @@ import org.eclipse.leshan.server.LwM2mServer;
 import org.eclipse.leshan.server.Startable;
 import org.eclipse.leshan.server.Stoppable;
 import org.eclipse.leshan.server.client.Registration;
-import org.eclipse.leshan.server.client.RegistrationService;
 import org.eclipse.leshan.server.client.RegistrationListener;
+import org.eclipse.leshan.server.client.RegistrationService;
 import org.eclipse.leshan.server.client.RegistrationUpdate;
 import org.eclipse.leshan.server.model.LwM2mModelProvider;
-import org.eclipse.leshan.server.observation.ObservationRegistry;
+import org.eclipse.leshan.server.observation.ObservationService;
 import org.eclipse.leshan.server.queue.MessageStore;
 import org.eclipse.leshan.server.request.LwM2mRequestSender;
 import org.eclipse.leshan.server.response.ResponseListener;
@@ -42,20 +42,20 @@ public class QueueModeLeshanServer implements LwM2mServer {
     private static final Logger LOG = LoggerFactory.getLogger(QueueModeLeshanServer.class);
     private final CoapServer coapServer;
     private final RegistrationService registrationService;
-    private final ObservationRegistry observationRegistry;
+    private final ObservationService observationService;
     private final SecurityRegistry securityRegistry;
     private final LwM2mModelProvider modelProvider;
     private final LwM2mRequestSender lwM2mRequestSender;
     private final MessageStore messageStore;
 
     public QueueModeLeshanServer(CoapServer coapServer, RegistrationService registrationService,
-            ObservationRegistry observationRegistry, SecurityRegistry securityRegistry,
+            ObservationService observationService, SecurityRegistry securityRegistry,
             LwM2mModelProvider modelProvider, LwM2mRequestSender lwM2mRequestSender,
             MessageStore inMemoryMessageStore) {
 
         this.coapServer = coapServer;
         this.registrationService = registrationService;
-        this.observationRegistry = observationRegistry;
+        this.observationService = observationService;
         this.securityRegistry = securityRegistry;
         this.modelProvider = modelProvider;
         this.lwM2mRequestSender = lwM2mRequestSender;
@@ -70,7 +70,7 @@ public class QueueModeLeshanServer implements LwM2mServer {
 
             @Override
             public void unregistered(Registration registration) {
-                QueueModeLeshanServer.this.observationRegistry.cancelObservations(registration);
+                QueueModeLeshanServer.this.observationService.cancelObservations(registration);
                 QueueModeLeshanServer.this.lwM2mRequestSender.cancelPendingRequests(registration);
             }
 
@@ -90,8 +90,8 @@ public class QueueModeLeshanServer implements LwM2mServer {
         if (securityRegistry instanceof Startable) {
             ((Startable) securityRegistry).start();
         }
-        if (observationRegistry instanceof Startable) {
-            ((Startable) observationRegistry).start();
+        if (observationService instanceof Startable) {
+            ((Startable) observationService).start();
         }
 
         // Start server
@@ -112,8 +112,8 @@ public class QueueModeLeshanServer implements LwM2mServer {
         if (securityRegistry instanceof Stoppable) {
             ((Stoppable) securityRegistry).stop();
         }
-        if (observationRegistry instanceof Stoppable) {
-            ((Stoppable) observationRegistry).stop();
+        if (observationService instanceof Stoppable) {
+            ((Stoppable) observationService).stop();
         }
         if (lwM2mRequestSender instanceof Stoppable) {
             ((Stoppable) lwM2mRequestSender).stop();
@@ -134,8 +134,8 @@ public class QueueModeLeshanServer implements LwM2mServer {
         if (securityRegistry instanceof Destroyable) {
             ((Destroyable) securityRegistry).destroy();
         }
-        if (observationRegistry instanceof Destroyable) {
-            ((Destroyable) observationRegistry).destroy();
+        if (observationService instanceof Destroyable) {
+            ((Destroyable) observationService).destroy();
         }
 
         LOG.info("LW-M2M server destroyed");
@@ -180,8 +180,8 @@ public class QueueModeLeshanServer implements LwM2mServer {
     }
 
     @Override
-    public ObservationRegistry getObservationRegistry() {
-        return observationRegistry;
+    public ObservationService getObservationService() {
+        return observationService;
     }
 
     @Override
diff --git a/leshan-server-cf/src/test/java/org/eclipse/leshan/server/californium/impl/CaliforniumObservationTest.java b/leshan-server-cf/src/test/java/org/eclipse/leshan/server/californium/impl/CaliforniumObservationTest.java
index 439c1859..4b60520e 100644
--- a/leshan-server-cf/src/test/java/org/eclipse/leshan/server/californium/impl/CaliforniumObservationTest.java
+++ b/leshan-server-cf/src/test/java/org/eclipse/leshan/server/californium/impl/CaliforniumObservationTest.java
@@ -26,7 +26,6 @@ import org.eclipse.californium.core.coap.Request;
 import org.eclipse.leshan.core.node.LwM2mPath;
 import org.eclipse.leshan.core.node.codec.DefaultLwM2mNodeDecoder;
 import org.eclipse.leshan.core.observation.Observation;
-import org.eclipse.leshan.server.californium.CaliforniumObservationRegistry;
 import org.eclipse.leshan.server.californium.CaliforniumRegistrationStore;
 import org.eclipse.leshan.server.client.Registration;
 import org.eclipse.leshan.server.model.StandardModelProvider;
@@ -38,7 +37,7 @@ public class CaliforniumObservationTest {
 
     Request coapRequest;
     LwM2mPath target;
-    CaliforniumObservationRegistry registry;
+    ObservationServiceImpl observationService;
     CaliforniumRegistrationStore store;
 
     private CaliforniumTestSupport support = new CaliforniumTestSupport();
@@ -47,7 +46,7 @@ public class CaliforniumObservationTest {
     public void setUp() throws Exception {
         support.givenASimpleClient();
         store = new InMemoryRegistrationStore();
-        registry = new CaliforniumObservationRegistryImpl(store,
+        observationService = new ObservationServiceImpl(store,
                 new StandardModelProvider(),
                 new DefaultLwM2mNodeDecoder());
     }
@@ -58,34 +57,34 @@ public class CaliforniumObservationTest {
         givenAnObservation(support.registration.getId(), new LwM2mPath(3, 0, 12));
 
         // check the presence of only one observation.
-        Set<Observation> observations = registry.getObservations(support.registration);
+        Set<Observation> observations = observationService.getObservations(support.registration);
         Assert.assertEquals(1, observations.size());
     }
 
     @Test
     public void cancel_by_client() {
-        // create some observations and add it to registry
+        // create some observations
         givenAnObservation(support.registration.getId(), new LwM2mPath(3, 0, 13));
         givenAnObservation(support.registration.getId(), new LwM2mPath(3, 0, 12));
 
         givenAnObservation("anotherClient", new LwM2mPath(3, 0, 12));
 
         // check its presence
-        Set<Observation> observations = registry.getObservations(support.registration);
+        Set<Observation> observations = observationService.getObservations(support.registration);
         Assert.assertEquals(2, observations.size());
 
         // cancel it
-        int nbCancelled = registry.cancelObservations(support.registration);
+        int nbCancelled = observationService.cancelObservations(support.registration);
         Assert.assertEquals(2, nbCancelled);
 
         // check its absence
-        observations = registry.getObservations(support.registration);
+        observations = observationService.getObservations(support.registration);
         Assert.assertTrue(observations.isEmpty());
     }
 
     @Test
     public void cancel_by_path() {
-        // create some observations and add it to registry
+        // create some observations
         givenAnObservation(support.registration.getId(), new LwM2mPath(3, 0, 13));
         givenAnObservation(support.registration.getId(), new LwM2mPath(3, 0, 12));
         givenAnObservation(support.registration.getId(), new LwM2mPath(3, 0, 12));
@@ -93,21 +92,21 @@ public class CaliforniumObservationTest {
         givenAnObservation("anotherClient", new LwM2mPath(3, 0, 12));
 
         // check its presence
-        Set<Observation> observations = registry.getObservations(support.registration);
+        Set<Observation> observations = observationService.getObservations(support.registration);
         Assert.assertEquals(2, observations.size());
 
         // cancel it
-        int nbCancelled = registry.cancelObservations(support.registration, "/3/0/12");
+        int nbCancelled = observationService.cancelObservations(support.registration, "/3/0/12");
         Assert.assertEquals(1, nbCancelled);
 
         // check its absence
-        observations = registry.getObservations(support.registration);
+        observations = observationService.getObservations(support.registration);
         Assert.assertEquals(1, observations.size());
     }
 
     @Test
     public void cancel_by_observation() throws UnknownHostException {
-        // create some observations and add it to registry
+        // create some observations
         givenAnObservation(support.registration.getId(), new LwM2mPath(3, 0, 13));
         givenAnObservation(support.registration.getId(), new LwM2mPath(3, 0, 12));
         givenAnObservation("anotherClient", new LwM2mPath(3, 0, 12));
@@ -116,14 +115,14 @@ public class CaliforniumObservationTest {
                 new LwM2mPath(3, 0, 12));
 
         // check its presence
-        Set<Observation> observations = registry.getObservations(support.registration);
+        Set<Observation> observations = observationService.getObservations(support.registration);
         Assert.assertEquals(2, observations.size());
 
         // cancel it
-        registry.cancelObservation(observationToCancel);
+        observationService.cancelObservation(observationToCancel);
 
         // check its absence
-        observations = registry.getObservations(support.registration);
+        observations = observationService.getObservations(support.registration);
         Assert.assertEquals(1, observations.size());
     }
 
@@ -146,7 +145,7 @@ public class CaliforniumObservationTest {
         store.add(new org.eclipse.californium.core.observe.Observation(coapRequest, null));
 
         Observation observation = new Observation(coapRequest.getToken(), registrationId, target, null);
-        registry.addObservation(observation);
+        observationService.addObservation(observation);
 
         return observation;
     }
diff --git a/leshan-server-cf/src/test/java/org/eclipse/leshan/server/californium/impl/RegistrationServiceImplTest.java b/leshan-server-cf/src/test/java/org/eclipse/leshan/server/californium/impl/RegistrationServiceImplTest.java
index 1dfcee1b..640f9808 100644
--- a/leshan-server-cf/src/test/java/org/eclipse/leshan/server/californium/impl/RegistrationServiceImplTest.java
+++ b/leshan-server-cf/src/test/java/org/eclipse/leshan/server/californium/impl/RegistrationServiceImplTest.java
@@ -29,7 +29,7 @@ import org.junit.Test;
 
 public class RegistrationServiceImplTest {
 
-    RegistrationServiceImpl registry;
+    RegistrationServiceImpl registrationService;
     String ep = "urn:endpoint";
     InetAddress address;
     int port = 23452;
@@ -43,21 +43,21 @@ public class RegistrationServiceImplTest {
     @Before
     public void setUp() throws Exception {
         address = InetAddress.getLocalHost();
-        registry = new RegistrationServiceImpl(new InMemoryRegistrationStore());
+        registrationService = new RegistrationServiceImpl(new InMemoryRegistrationStore());
     }
 
     @Test
     public void update_registration_keeps_properties_unchanged() {
         givenASimpleRegistration(lifetime);
-        registry.registerClient(registration);
+        registrationService.registerClient(registration);
 
         RegistrationUpdate update = new RegistrationUpdate(registrationId, address, port, null, null, null, null);
-        Registration updatedRegistration = registry.updateRegistration(update);
+        Registration updatedRegistration = registrationService.updateRegistration(update);
         Assert.assertEquals(lifetime, updatedRegistration.getLifeTimeInSec());
         Assert.assertSame(binding, updatedRegistration.getBindingMode());
         Assert.assertEquals(sms, updatedRegistration.getSmsNumber());
 
-        Registration reg = registry.getByEndpoint(ep);
+        Registration reg = registrationService.getByEndpoint(ep);
         Assert.assertEquals(lifetime, reg.getLifeTimeInSec());
         Assert.assertSame(binding, reg.getBindingMode());
         Assert.assertEquals(sms, reg.getSmsNumber());
@@ -66,21 +66,21 @@ public class RegistrationServiceImplTest {
     @Test
     public void client_registration_sets_time_to_live() {
         givenASimpleRegistration(lifetime);
-        registry.registerClient(registration);
+        registrationService.registerClient(registration);
         Assert.assertTrue(registration.isAlive());
     }
 
     @Test
     public void update_registration_to_extend_time_to_live() {
         givenASimpleRegistration(0L);
-        registry.registerClient(registration);
+        registrationService.registerClient(registration);
         Assert.assertFalse(registration.isAlive());
 
         RegistrationUpdate update = new RegistrationUpdate(registrationId, address, port, lifetime, null, null, null);
-        Registration updatedRegistration = registry.updateRegistration(update);
+        Registration updatedRegistration = registrationService.updateRegistration(update);
         Assert.assertTrue(updatedRegistration.isAlive());
 
-        Registration reg = registry.getByEndpoint(ep);
+        Registration reg = registrationService.getByEndpoint(ep);
         Assert.assertTrue(reg.isAlive());
     }