Initial implementation of ListenerRegistration actor and all related messages
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / Shard.java
index f59e05ae9935f50f58a9481a46f2e8bfc2820baf..8365328669587b5e083c8e53ca819eb63857cd40 100644 (file)
@@ -31,6 +31,7 @@ import java.util.concurrent.Executors;
  * A Shard represents a portion of the logical data tree
  * <p/>
  * Our Shard uses InMemoryDataStore as it's internal representation and delegates all requests it
+ *
  */
 public class Shard extends UntypedProcessor {
 
@@ -47,15 +48,18 @@ public class Shard extends UntypedProcessor {
     } else if(message instanceof RegisterChangeListener){
       registerChangeListener((RegisterChangeListener) message);
     } else if(message instanceof UpdateSchemaContext){
-      store.onGlobalContextUpdated(((UpdateSchemaContext) message).getSchemaContext());
+      updateSchemaContext((UpdateSchemaContext) message);
     }
   }
 
+  private void updateSchemaContext(UpdateSchemaContext message) {
+    store.onGlobalContextUpdated(message.getSchemaContext());
+  }
+
   private void registerChangeListener(RegisterChangeListener registerChangeListener) {
     org.opendaylight.yangtools.concepts.ListenerRegistration<AsyncDataChangeListener<InstanceIdentifier, NormalizedNode<?, ?>>> registration =
             store.registerChangeListener(registerChangeListener.getPath(), registerChangeListener.getListener(), registerChangeListener.getScope());
-    // TODO: Construct a ListenerRegistration actor with the actual registration returned when registering a listener with the datastore
-    ActorRef listenerRegistration = getContext().actorOf(ListenerRegistration.props(null));
+    ActorRef listenerRegistration = getContext().actorOf(ListenerRegistration.props(registration));
     getSender().tell(new RegisterChangeListenerReply(listenerRegistration.path()), getSelf());
   }