BUG-625: convert TopologyProvider 39/7439/1
authorRobert Varga <rovarga@cisco.com>
Tue, 27 May 2014 20:48:56 +0000 (22:48 +0200)
committerRobert Varga <rovarga@cisco.com>
Tue, 27 May 2014 20:48:56 +0000 (22:48 +0200)
This patch converts TopologyProvider from being xtend class to being a
pure Java class.

Change-Id: I1ba91f5988243259d39c812a0ffdda7b3d7d608e
Signed-off-by: Robert Varga <rovarga@cisco.com>
opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyProvider.java [new file with mode: 0644]
opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyProvider.xtend [deleted file]

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 (file)
index 0000000..d78bce4
--- /dev/null
@@ -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<Link> PATH = InstanceIdentifier.builder(NetworkTopology.class)
+            .child(Topology.class ,new TopologyKey(new TopologyId("flow:1")))
+            .child(Link.class)
+            .toInstance();
+    private TopologyCommitHandler commitHandler;
+
+    private ListenerRegistration<DataChangeListener> 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 (file)
index 21f2b35..0000000
+++ /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<DataChangeListener> listenerRegistration
-    
-    
-    def void start() {
-
-    }
-    def void startAdapter() {
-        if(dataService == null){
-            LOG.error("dataService not set");
-            return;
-        }
-        commitHandler = new TopologyCommitHandler(dataService,topologyPublisher);
-        val InstanceIdentifier<? extends DataObject> 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);
-        }
-    }
-    
-}