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.sal.compatibility.topology
10 import org.opendaylight.controller.sal.binding.api.data.DataProviderService
11 import org.opendaylight.controller.sal.topology.IPluginOutTopologyService
12 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology
13 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId
14 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology
15 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey
16 import org.opendaylight.yangtools.yang.binding.DataObject
17 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
18 import org.opendaylight.yangtools.concepts.Registration
19 import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler
20 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link
21 import org.slf4j.LoggerFactory
23 class TopologyProvider implements AutoCloseable{
24 static val LOG = LoggerFactory.getLogger(TopologyProvider);
25 TopologyCommitHandler commitHandler
28 IPluginOutTopologyService topologyPublisher;
31 DataProviderService dataService;
33 Registration<DataCommitHandler<InstanceIdentifier<? extends DataObject>,DataObject>> commitHandlerRegistration;
36 commitHandler = new TopologyCommitHandler(dataService)
37 commitHandler.setTopologyPublisher(topologyPublisher)
38 val InstanceIdentifier<? extends DataObject> path = InstanceIdentifier.builder(NetworkTopology)
39 .child(Topology,new TopologyKey(new TopologyId("flow:1")))
42 commitHandlerRegistration = dataService.registerCommitHandler(path,commitHandler);
43 LOG.info("TopologyProvider started")
46 override close() throws Exception {
47 commitHandlerRegistration.close
50 def setTopologyPublisher(IPluginOutTopologyService topologyPublisher) {
51 _topologyPublisher = topologyPublisher;
52 commitHandler.setTopologyPublisher(topologyPublisher);