- Entry<DataChangeListenerRegistration<AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>>>,
- Optional<DataTreeCandidate>> regEntry = getShard().getDataStore().registerChangeListener(
- message.getPath(), listener, message.getScope());
-
- getShard().getDataStore().notifyOfInitialData(regEntry.getKey(), regEntry.getValue());
-
- listenerActors.add(dataChangeListenerPath);
- final DataChangeListenerRegistration<AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>>>
- delegate = regEntry.getKey();
- return new DataChangeListenerRegistration<AsyncDataChangeListener<YangInstanceIdentifier,
- NormalizedNode<?,?>>>() {
- @Override
- public void close() {
- listenerActors.remove(dataChangeListenerPath);
- delegate.close();
- }
-
- @Override
- public AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>> getInstance() {
- return delegate.getInstance();
- }
-
- @Override
- public YangInstanceIdentifier getPath() {
- return delegate.getPath();
- }
-
- @Override
- public DataChangeScope getScope() {
- return delegate.getScope();
- }
- };
- }
-
- @Override
- protected DelayedDataChangeListenerRegistration newDelayedListenerRegistration(RegisterChangeListener message) {
- return new DelayedDataChangeListenerRegistration(message);
+ final ShardDataTree shardDataTree = getShard().getDataStore();
+ shardDataTree.registerDataChangeListener(message.getPath(), listener, message.getScope(),
+ shardDataTree.readCurrentData(), registration -> registrationActor.tell(
+ new DataTreeNotificationListenerRegistrationActor.SetRegistration(registration, () ->
+ removeListenerActor(listenerActor)), ActorRef.noSender()));