ec8da8693fd5dd83379377786a6c3dc015797d34
[controller.git] / opendaylight / md-sal / inventory-manager / src / main / java / org / opendaylight / controller / md / inventory / manager / FlowCapableInventoryProvider.xtend
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  * 
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
7  */
8 package org.opendaylight.controller.md.inventory.manager
9
10 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.OpendaylightInventoryListener
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRemoved
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdated
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRemoved
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeUpdated
15 import org.opendaylight.controller.sal.binding.api.NotificationProviderService
16 import org.opendaylight.controller.sal.binding.api.data.DataProviderService
17 import org.opendaylight.yangtools.concepts.Registration
18 import org.opendaylight.yangtools.yang.binding.NotificationListener
19 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
20 import org.opendaylight.yangtools.yang.binding.DataObject
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorBuilder
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorUpdated
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeUpdated
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey
27 import static extension org.opendaylight.controller.md.inventory.manager.InventoryMapping.*
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey
32 import org.slf4j.LoggerFactory
33
34 class FlowCapableInventoryProvider implements AutoCloseable {
35
36
37     static val LOG = LoggerFactory.getLogger(FlowCapableInventoryProvider);
38
39     @Property
40     DataProviderService dataService;
41
42     @Property
43     NotificationProviderService notificationService;
44     val NodeChangeCommiter changeCommiter = new NodeChangeCommiter(this);
45
46     Registration<NotificationListener> listenerRegistration
47
48     def void start() {
49         listenerRegistration = notificationService.registerNotificationListener(changeCommiter);
50         LOG.info("Flow Capable Inventory Provider started.");
51         
52     }
53
54     protected def startChange() {
55         return dataService.beginTransaction;
56     }
57
58     override close() {
59        LOG.info("Flow Capable Inventory Provider stopped.");
60         listenerRegistration?.close();
61     }
62     
63 }