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.md.sal.binding.util.TypeSafeDataReader;
11 import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
12 import org.opendaylight.controller.sal.topology.IPluginInTopologyService;
13 import org.opendaylight.controller.sal.topology.IPluginOutTopologyService;
14 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
15 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
16 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
17 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
18 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
20 import com.google.common.base.Preconditions;
22 public class TopologyAdapter implements IPluginInTopologyService {
23 private final InstanceIdentifier<Topology> topology = InstanceIdentifier.builder(NetworkTopology.class)
24 .child(Topology.class, new TopologyKey(new TopologyId("flow:1"))).toInstance();
26 // Injected via Apache DM
27 private IPluginOutTopologyService topologyPublisher;
30 private DataProviderService dataService;
32 public void setDataService(final DataProviderService dataService) {
33 this.dataService = Preconditions.checkNotNull(dataService);
37 public void sollicitRefresh() {
38 final TypeSafeDataReader reader = TypeSafeDataReader.forReader(dataService);
39 final Topology t = reader.readOperationalData(topology);
40 topologyPublisher.edgeUpdate(TopologyMapping.toADEdgeUpdates(t, reader));
43 public IPluginOutTopologyService getTopologyPublisher() {
44 return topologyPublisher;
47 public void setTopologyPublisher(final IPluginOutTopologyService topologyPublisher) {
48 this.topologyPublisher = topologyPublisher;