Move stats caching to FM StatisticsManager
[controller.git] / opendaylight / sal / implementation / src / main / java / org / opendaylight / controller / sal / implementation / internal / Activator.java
index 99690802e3cdd5e9539c8e0a5c33a18ccec7b3d6..85d239f4b9e1c52a265e2cb685fcb64925dac3d2 100644 (file)
@@ -8,6 +8,7 @@
 
 package org.opendaylight.controller.sal.implementation.internal;
 
+import org.apache.felix.dm.Component;
 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
 import org.opendaylight.controller.sal.flowprogrammer.IFlowProgrammerListener;
 import org.opendaylight.controller.sal.flowprogrammer.IFlowProgrammerService;
@@ -22,14 +23,15 @@ import org.opendaylight.controller.sal.packet.IListenDataPacket;
 import org.opendaylight.controller.sal.packet.IPluginInDataPacketService;
 import org.opendaylight.controller.sal.packet.IPluginOutDataPacketService;
 import org.opendaylight.controller.sal.reader.IPluginInReadService;
+import org.opendaylight.controller.sal.reader.IPluginOutReadService;
 import org.opendaylight.controller.sal.reader.IReadService;
+import org.opendaylight.controller.sal.reader.IReadServiceListener;
 import org.opendaylight.controller.sal.topology.IListenTopoUpdates;
 import org.opendaylight.controller.sal.topology.IPluginInTopologyService;
 import org.opendaylight.controller.sal.topology.IPluginOutTopologyService;
 import org.opendaylight.controller.sal.topology.ITopologyService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.apache.felix.dm.Component;
 
 public class Activator extends ComponentActivatorAbstractBase {
     protected static final Logger logger = LoggerFactory
@@ -38,8 +40,9 @@ public class Activator extends ComponentActivatorAbstractBase {
     /**
      * Function called when the activator starts just after some initializations
      * are done by the ComponentActivatorAbstractBase.
-     * 
+     *
      */
+    @Override
     public void init() {
 
     }
@@ -47,8 +50,9 @@ public class Activator extends ComponentActivatorAbstractBase {
     /**
      * Function called when the activator stops just before the cleanup done by
      * ComponentActivatorAbstractBase
-     * 
+     *
      */
+    @Override
     public void destroy() {
 
     }
@@ -56,12 +60,13 @@ public class Activator extends ComponentActivatorAbstractBase {
     /**
      * Function that is used to communicate to dependency manager the list of
      * known implementations for services inside a container
-     * 
-     * 
+     *
+     *
      * @return An array containing all the CLASS objects that will be
      *         instantiated in order to get an fully working implementation
      *         Object
      */
+    @Override
     public Object[] getImplementations() {
         Object[] res = { Topology.class, Inventory.class,
                 FlowProgrammerService.class, ReadService.class,
@@ -72,7 +77,7 @@ public class Activator extends ComponentActivatorAbstractBase {
     /**
      * Function that is called when configuration of the dependencies is
      * required.
-     * 
+     *
      * @param c
      *            dependency manager Component object, used for configuring the
      *            dependencies exported and imported
@@ -84,6 +89,7 @@ public class Activator extends ComponentActivatorAbstractBase {
      *            per-container different behavior if needed, usually should not
      *            be the case though.
      */
+    @Override
     public void configureInstance(Component c, Object imp, String containerName) {
         if (imp.equals(Topology.class)) {
             // export the service for Apps and Plugins
@@ -121,7 +127,7 @@ public class Activator extends ComponentActivatorAbstractBase {
             c.add(createContainerServiceDependency(containerName)
                     .setService(IPluginInInventoryService.class)
                     .setCallbacks("setPluginService", "unsetPluginService")
-                    .setRequired(true));
+                    .setRequired(false));
         }
 
         if (imp.equals(FlowProgrammerService.class)) {
@@ -134,21 +140,29 @@ public class Activator extends ComponentActivatorAbstractBase {
                     .setService(IPluginInFlowProgrammerService.class)
                     .setCallbacks("setService", "unsetService")
                     .setRequired(false));
-            c.add(createServiceDependency()
+            c.add(createContainerServiceDependency(containerName)
                     .setService(IFlowProgrammerListener.class)
                     .setCallbacks("setListener", "unsetListener")
                     .setRequired(false));
         }
 
         if (imp.equals(ReadService.class)) {
-            // It is the provider of IReadService
-            c.setInterface(IReadService.class.getName(), null);
+            // export services
+            c.setInterface(new String[] {
+                    IReadService.class.getName(),IPluginOutReadService.class.getName()}, null);
 
             // It is also the consumer of IPluginInReadService
             c.add(createContainerServiceDependency(containerName)
                     .setService(IPluginInReadService.class)
                     .setCallbacks("setService", "unsetService")
-                    .setRequired(true));
+                    .setRequired(false));
+
+            //consumes plugins' reader updates
+            c.add(createContainerServiceDependency(containerName)
+                    .setService(IReadServiceListener.class)
+                    .setCallbacks("setReaderListener", "unsetReaderListener")
+                    .setRequired(false));
+
         }
 
         /************************/