Bug 809: Enhancements to the toaster example
[controller.git] / opendaylight / md-sal / compatibility / sal-compatibility / src / main / java / org / opendaylight / controller / sal / compatibility / topology / TopologyProvider.xtend
index bf1a23d4bc2d90ae8307c3ab6f2998eb0fab716a..4aef75d9916565dc20c3c18a87149669116f4753 100644 (file)
@@ -1,3 +1,10 @@
+/*
+ * 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
@@ -24,8 +31,15 @@ class TopologyProvider implements AutoCloseable{
     DataProviderService dataService;
     
     Registration<DataCommitHandler<InstanceIdentifier<? extends DataObject>,DataObject>> commitHandlerRegistration;
-    
+
     def void start() {
+
+    }
+    def void startAdapter() {
+        if(dataService == null){
+            LOG.error("dataService not set");
+            return;
+        }
         commitHandler = new TopologyCommitHandler(dataService)
         commitHandler.setTopologyPublisher(topologyPublisher)
         val InstanceIdentifier<? extends DataObject> path = InstanceIdentifier.builder(NetworkTopology)
@@ -42,7 +56,9 @@ class TopologyProvider implements AutoCloseable{
     
     def setTopologyPublisher(IPluginOutTopologyService topologyPublisher) {
         _topologyPublisher = topologyPublisher;
-        commitHandler.setTopologyPublisher(topologyPublisher);
+        if(commitHandler != null){
+            commitHandler.setTopologyPublisher(topologyPublisher);
+        }
     }
     
-}
\ No newline at end of file
+}