BUG-625: split off SalCompatibilityProvider 36/7436/1
authorRobert Varga <rovarga@cisco.com>
Tue, 27 May 2014 19:22:21 +0000 (21:22 +0200)
committerRobert Varga <rovarga@cisco.com>
Tue, 27 May 2014 19:22:21 +0000 (21:22 +0200)
This patch splits off SalCompatibilityProvider from
ComponentActivator.xtend, lowering the amount of xtend code present in
the code base.

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

index 57682bc..d65dee6 100644 (file)
@@ -13,12 +13,6 @@ import java.util.Hashtable
 import org.apache.felix.dm.Component
 import org.opendaylight.controller.clustering.services.IClusterGlobalServices
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext
-import org.opendaylight.controller.sal.binding.api.BindingAwareProvider
-import org.opendaylight.controller.sal.binding.api.NotificationService
-import org.opendaylight.controller.sal.binding.api.data.DataBrokerService
-import org.opendaylight.controller.sal.binding.api.data.DataProviderService
 import org.opendaylight.controller.sal.compatibility.adsal.DataPacketServiceAdapter
 import org.opendaylight.controller.sal.compatibility.topology.TopologyAdapter
 import org.opendaylight.controller.sal.compatibility.topology.TopologyProvider
@@ -39,12 +33,6 @@ import org.opendaylight.controller.sal.topology.IPluginOutTopologyService
 import org.opendaylight.controller.sal.utils.GlobalConstants
 import org.opendaylight.controller.sal.utils.INodeConnectorFactory
 import org.opendaylight.controller.sal.utils.INodeFactory
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsService
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.OpendaylightFlowTableStatisticsService
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.FlowTopologyDiscoveryService
-import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService
-import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.OpendaylightPortStatisticsService
 import org.osgi.framework.BundleContext
 
 import static org.opendaylight.controller.sal.compatibility.NodeMapping.*
@@ -204,55 +192,3 @@ class ComponentActivator extends ComponentActivatorAbstractBase {
         return props;
     }
 }
-package class SalCompatibilityProvider implements BindingAwareProvider {
-    
-    private val ComponentActivator activator;
-    
-    new(ComponentActivator cmpAct) {
-        activator = cmpAct;
-    }
-    
-    override getFunctionality() {
-        // Noop
-    }
-    
-    override getImplementations() {
-        // Noop
-    }
-    
-    
-    override onSessionInitialized(ConsumerContext session) {
-        // Noop
-    }
-    
-    
-    override onSessionInitiated(ProviderContext session) {
-        val it = activator
-                val subscribe = session.getSALService(NotificationService)
-
-        // Registration of Flow Service
-        flow.delegate = session.getRpcService(SalFlowService)
-        flow.dataBrokerService = session.getSALService(DataBrokerService);
-        subscribe.registerNotificationListener(flow);
-
-        // Data Packet Service
-        subscribe.registerNotificationListener(inventory);
-        dataPacketService.delegate = session.getRpcService(PacketProcessingService)
-
-        // Inventory Service
-        inventory.dataService = session.getSALService(DataBrokerService);
-        inventory.flowStatisticsService = session.getRpcService(OpendaylightFlowStatisticsService);
-        inventory.flowTableStatisticsService = session.getRpcService(OpendaylightFlowTableStatisticsService);
-        inventory.nodeConnectorStatisticsService = session.getRpcService(OpendaylightPortStatisticsService);
-        inventory.topologyDiscovery = session.getRpcService(FlowTopologyDiscoveryService);
-        inventory.dataProviderService = session.getSALService(DataProviderService)
-        topology.dataService = session.getSALService(DataProviderService)
-        tpProvider.dataService = session.getSALService(DataProviderService)
-
-        inventory.startAdapter();
-
-        tpProvider.startAdapter();
-
-        subscribe.registerNotificationListener(dataPacket)
-    }
-}
diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/SalCompatibilityProvider.java b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/SalCompatibilityProvider.java
new file mode 100644 (file)
index 0000000..0ddbcaa
--- /dev/null
@@ -0,0 +1,88 @@
+/**
+ * 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;
+
+import java.util.Collection;
+import java.util.Collections;
+
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
+import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
+import org.opendaylight.controller.sal.binding.api.NotificationService;
+import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
+import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
+import org.opendaylight.controller.sal.compatibility.adsal.DataPacketServiceAdapter;
+import org.opendaylight.controller.sal.compatibility.topology.TopologyAdapter;
+import org.opendaylight.controller.sal.compatibility.topology.TopologyProvider;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.OpendaylightFlowTableStatisticsService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.FlowTopologyDiscoveryService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.OpendaylightPortStatisticsService;
+import org.opendaylight.yangtools.yang.binding.RpcService;
+
+import com.google.common.base.Preconditions;
+
+class SalCompatibilityProvider implements BindingAwareProvider {
+    private final ComponentActivator activator;
+
+    public SalCompatibilityProvider(final ComponentActivator cmpAct) {
+        this.activator = Preconditions.checkNotNull(cmpAct);
+    }
+
+    @Override
+    public Collection<? extends ProviderFunctionality> getFunctionality() {
+        return Collections.emptyList();
+    }
+
+    @Override
+    public Collection<? extends RpcService> getImplementations() {
+        return Collections.emptyList();
+    }
+
+    @Override
+    public void onSessionInitialized(final ConsumerContext session) {
+        // No-op
+    }
+
+    @Override
+    public void onSessionInitiated(final ProviderContext session) {
+        final NotificationService subscribe = session.getSALService(NotificationService.class);
+
+        final FlowProgrammerAdapter flow = activator.getFlow();
+        flow.setDelegate(session.getRpcService(SalFlowService.class));
+        flow.setDataBrokerService(session.getSALService(DataBrokerService.class));
+        // FIXME: remember registration for clean shutdown
+        subscribe.registerNotificationListener(flow);
+
+        final InventoryAndReadAdapter inv = activator.getInventory();
+        inv.setDataService(session.getSALService(DataBrokerService.class));
+        inv.setFlowStatisticsService(session.getRpcService(OpendaylightFlowStatisticsService.class));
+        inv.setFlowTableStatisticsService(session.getRpcService(OpendaylightFlowTableStatisticsService.class));
+        inv.setNodeConnectorStatisticsService(session.getRpcService(OpendaylightPortStatisticsService.class));
+        inv.setTopologyDiscovery(session.getRpcService(FlowTopologyDiscoveryService.class));
+        inv.setDataProviderService(session.getSALService(DataProviderService.class));
+        // FIXME: remember registration for clean shutdown
+        subscribe.registerNotificationListener(inv);
+
+        final DataPacketServiceAdapter dps = activator.getDataPacketService();
+        dps.setDelegate(session.getRpcService(PacketProcessingService.class));
+
+        final TopologyAdapter topo = activator.getTopology();
+        topo.setDataService(session.getSALService(DataProviderService.class));
+
+        final TopologyProvider tpp = activator.getTpProvider();
+        tpp.setDataService(session.getSALService(DataProviderService.class));
+
+        inv.startAdapter();
+        tpp.startAdapter();
+
+        subscribe.registerNotificationListener(activator.getDataPacket());
+    }
+}