2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.md.inventory.manager;
10 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
11 import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
12 import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
13 import org.opendaylight.yangtools.concepts.Registration;
14 import org.opendaylight.yangtools.yang.binding.NotificationListener;
15 import org.slf4j.Logger;
16 import org.slf4j.LoggerFactory;
18 public class FlowCapableInventoryProvider implements AutoCloseable {
20 private final static Logger LOG = LoggerFactory.getLogger(FlowCapableInventoryProvider.class);
22 private DataProviderService dataService;
23 private NotificationProviderService notificationService;
24 private Registration<NotificationListener> listenerRegistration;
25 private final NodeChangeCommiter changeCommiter = new NodeChangeCommiter(FlowCapableInventoryProvider.this);
28 this.listenerRegistration = this.notificationService.registerNotificationListener(this.changeCommiter);
29 LOG.info("Flow Capable Inventory Provider started.");
32 protected DataModificationTransaction startChange() {
33 DataProviderService _dataService = this.dataService;
34 return _dataService.beginTransaction();
40 LOG.info("Flow Capable Inventory Provider stopped.");
41 if (this.listenerRegistration != null) {
42 this.listenerRegistration.close();
44 } catch (Exception e) {
45 String errMsg = "Error by stop Flow Capable Inventory Provider.";
47 throw new RuntimeException(errMsg, e);
51 public DataProviderService getDataService() {
52 return this.dataService;
55 public void setDataService(final DataProviderService dataService) {
56 this.dataService = dataService;
59 public NotificationProviderService getNotificationService() {
60 return this.notificationService;
63 public void setNotificationService(
64 final NotificationProviderService notificationService) {
65 this.notificationService = notificationService;