From 1ef949cc5bbdaf000c3d08c9ee6686cc17a7c10b Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Tue, 27 May 2014 22:48:56 +0200 Subject: [PATCH] BUG-625: convert TopologyProvider This patch converts TopologyProvider from being xtend class to being a pure Java class. Change-Id: I1ba91f5988243259d39c812a0ffdda7b3d7d608e Signed-off-by: Robert Varga --- .../topology/TopologyProvider.java | 64 +++++++++++++++++++ .../topology/TopologyProvider.xtend | 64 ------------------- 2 files changed, 64 insertions(+), 64 deletions(-) create mode 100644 opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyProvider.java delete mode 100644 opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyProvider.xtend diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyProvider.java b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyProvider.java new file mode 100644 index 0000000000..d78bce4787 --- /dev/null +++ b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyProvider.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.controller.sal.compatibility.topology; + +import org.opendaylight.controller.sal.binding.api.data.DataChangeListener; +import org.opendaylight.controller.sal.binding.api.data.DataProviderService; +import org.opendaylight.controller.sal.topology.IPluginOutTopologyService; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link; +import org.opendaylight.yangtools.concepts.ListenerRegistration; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.base.Preconditions; + +public class TopologyProvider implements AutoCloseable{ + private static final Logger LOG = LoggerFactory.getLogger(TopologyProvider.class); + private static final InstanceIdentifier PATH = InstanceIdentifier.builder(NetworkTopology.class) + .child(Topology.class ,new TopologyKey(new TopologyId("flow:1"))) + .child(Link.class) + .toInstance(); + private TopologyCommitHandler commitHandler; + + private ListenerRegistration listenerRegistration; + private IPluginOutTopologyService topologyPublisher; + private DataProviderService dataService; + + public void startAdapter() { + if(dataService == null){ + LOG.error("dataService not set"); + return; + } + commitHandler = new TopologyCommitHandler(dataService,topologyPublisher); + listenerRegistration = dataService.registerDataChangeListener(PATH, commitHandler); + LOG.info("TopologyProvider started"); + } + + @Override + public void close() { + if (listenerRegistration != null) { + listenerRegistration.close(); + } + } + + void setTopologyPublisher(final IPluginOutTopologyService topologyPublisher) { + this.topologyPublisher = topologyPublisher; + if (commitHandler != null) { + commitHandler.setTopologyPublisher(topologyPublisher); + } + } + + public void setDataService(final DataProviderService dataService) { + this.dataService = Preconditions.checkNotNull(dataService); + } +} diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyProvider.xtend b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyProvider.xtend deleted file mode 100644 index 21f2b35f40..0000000000 --- a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyProvider.xtend +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.compatibility.topology - -import org.opendaylight.controller.sal.binding.api.data.DataProviderService -import org.opendaylight.controller.sal.topology.IPluginOutTopologyService -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey -import org.opendaylight.yangtools.yang.binding.DataObject -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link -import org.slf4j.LoggerFactory -import org.opendaylight.yangtools.concepts.ListenerRegistration -import org.opendaylight.controller.sal.binding.api.data.DataChangeListener - -class TopologyProvider implements AutoCloseable{ - static val LOG = LoggerFactory.getLogger(TopologyProvider); - TopologyCommitHandler commitHandler - - @Property - IPluginOutTopologyService topologyPublisher; - - @Property - DataProviderService dataService; - - ListenerRegistration listenerRegistration - - - def void start() { - - } - def void startAdapter() { - if(dataService == null){ - LOG.error("dataService not set"); - return; - } - commitHandler = new TopologyCommitHandler(dataService,topologyPublisher); - val InstanceIdentifier path = InstanceIdentifier.builder(NetworkTopology) - .child(Topology,new TopologyKey(new TopologyId("flow:1"))) - .child(Link) - .toInstance(); - listenerRegistration = dataService.registerDataChangeListener(path,commitHandler); - LOG.info("TopologyProvider started") - } - - override close() throws Exception { - listenerRegistration.close - } - - def setTopologyPublisher(IPluginOutTopologyService topologyPublisher) { - _topologyPublisher = topologyPublisher; - if(commitHandler != null){ - commitHandler.setTopologyPublisher(topologyPublisher); - } - } - -} -- 2.36.6