- public void onDataChanged(AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
- for (InstanceIdentifier<?> removedPath : change.getRemovedPaths()) {
- if (removedPath.getTargetType() != NetconfNode.class)
- continue;
-
- final NodeId nodeId = getNodeId(removedPath);
- if (nodeId != null) {
- handleDisconnectedNetconfNode(nodeId);
- return;
+ public void onDataTreeChanged(final Collection<DataTreeModification<Node>> changes) {
+ for (DataTreeModification<Node> change: changes) {
+ final DataObjectModification<Node> rootNode = change.getRootNode();
+ final InstanceIdentifier<Node> identifier = change.getRootPath().getRootIdentifier();
+ switch (rootNode.getModificationType()) {
+ case WRITE:
+ case SUBTREE_MODIFIED:
+ if (isNetconfNode(rootNode.getDataAfter())) {
+ NodeId nodeId = getNodeId(identifier);
+ if (nodeId != null) {
+ NetconfNode nnode = rootNode.getDataAfter().augmentation(NetconfNode.class);
+ handledNetconfNode(nodeId, nnode);
+ }
+ }
+ break;
+ case DELETE:
+ if (isNetconfNode(rootNode.getDataBefore())) {
+ final NodeId nodeId = getNodeId(identifier);
+ if (nodeId != null) {
+ handleDisconnectedNetconfNode(nodeId);
+ }
+ }
+ break;
+ default:
+ break;