2 * ============LICENSE_START========================================================================
3 * ONAP : ccsdk feature sdnr wt
4 * =================================================================================================
5 * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved.
6 * =================================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8 * in compliance with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software distributed under the License
13 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14 * or implied. See the License for the specific language governing permissions and limitations under
16 * ============LICENSE_END==========================================================================
18 package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.access.binding;
20 import java.util.Objects;
21 import java.util.Optional;
22 import org.eclipse.jdt.annotation.NonNull;
23 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor;
24 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils;
25 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.access.NetconfAccessorImpl;
26 import org.opendaylight.mdsal.binding.api.DataBroker;
27 import org.opendaylight.mdsal.binding.api.MountPoint;
28 import org.opendaylight.mdsal.binding.api.NotificationService;
29 import org.opendaylight.yangtools.concepts.ListenerRegistration;
30 import org.opendaylight.yangtools.yang.binding.NotificationListener;
31 import org.slf4j.Logger;
32 import org.slf4j.LoggerFactory;
34 public abstract class NetconfBindingAccessorImpl extends NetconfAccessorImpl implements NetconfBindingAccessor {
36 private static final Logger log = LoggerFactory.getLogger(NetconfBindingAccessorImpl.class);
38 private final static GenericTransactionUtils GENERICTRANSACTIONUTILS = new GenericTransactionUtils();
40 private final DataBroker dataBroker;
41 private final MountPoint mountpoint;
44 * Contains all data to access and manage netconf device
46 * @param nodeId of managed netconf node
47 * @param netconfNode information
48 * @param dataBroker to access node
49 * @param mountpoint of netconfNode
51 public NetconfBindingAccessorImpl(NetconfAccessorImpl accessor, DataBroker dataBroker, MountPoint mountpoint) {
53 this.dataBroker = Objects.requireNonNull(dataBroker);
54 this.mountpoint = Objects.requireNonNull(mountpoint);
58 public DataBroker getDataBroker() {
63 public MountPoint getMountpoint() {
68 public TransactionUtils getTransactionUtils() {
69 return GENERICTRANSACTIONUTILS;
73 public @NonNull <T extends NotificationListener> ListenerRegistration<NotificationListener> doRegisterNotificationListener(
74 @NonNull T listener) {
75 log.info("Begin register listener for Mountpoint {}", mountpoint.getIdentifier().toString());
76 final Optional<NotificationService> optionalNotificationService =
77 mountpoint.getService(NotificationService.class);
78 final NotificationService notificationService = optionalNotificationService.get();
79 final ListenerRegistration<NotificationListener> ranListenerRegistration =
80 notificationService.registerNotificationListener(listener);
81 log.info("End registration listener for Mountpoint {} Listener: {} Result: {}",
82 mountpoint.getIdentifier().toString(), optionalNotificationService, ranListenerRegistration);
83 return ranListenerRegistration;