Controller to listen to expired flow removal message
[controller.git] / opendaylight / protocol_plugins / openflow / src / main / java / org / opendaylight / controller / protocol_plugin / openflow / internal / Activator.java
index 45c0211787d837b7b7a40a02095d9cd1c8804140..26471a7f754247c9b68d7845550ee382aabfa3b5 100644 (file)
@@ -1,4 +1,3 @@
-
 /*
  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
  *
@@ -15,6 +14,7 @@ import java.util.Hashtable;
 import org.apache.felix.dm.Component;
 import org.opendaylight.controller.protocol_plugin.openflow.IDataPacketListen;
 import org.opendaylight.controller.protocol_plugin.openflow.IDataPacketMux;
+import org.opendaylight.controller.protocol_plugin.openflow.IFlowProgrammerNotifier;
 import org.opendaylight.controller.protocol_plugin.openflow.IInventoryShimExternalListener;
 import org.opendaylight.controller.protocol_plugin.openflow.IInventoryShimInternalListener;
 import org.opendaylight.controller.protocol_plugin.openflow.IOFStatisticsManager;
@@ -23,12 +23,14 @@ import org.opendaylight.controller.protocol_plugin.openflow.IRefreshInternalProv
 import org.opendaylight.controller.protocol_plugin.openflow.IStatisticsListener;
 import org.opendaylight.controller.protocol_plugin.openflow.ITopologyServiceShimListener;
 import org.opendaylight.controller.protocol_plugin.openflow.core.IController;
+import org.opendaylight.controller.protocol_plugin.openflow.core.IMessageListener;
 import org.opendaylight.controller.protocol_plugin.openflow.core.internal.Controller;
 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
 import org.opendaylight.controller.sal.core.IContainerListener;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.discovery.IDiscoveryService;
 import org.opendaylight.controller.sal.flowprogrammer.IPluginInFlowProgrammerService;
+import org.opendaylight.controller.sal.flowprogrammer.IPluginOutFlowProgrammerService;
 import org.opendaylight.controller.sal.inventory.IPluginInInventoryService;
 import org.opendaylight.controller.sal.inventory.IPluginOutInventoryService;
 import org.opendaylight.controller.sal.packet.IPluginInDataPacketService;
@@ -42,92 +44,98 @@ import org.slf4j.LoggerFactory;
 
 /**
  * Openflow protocol plugin Activator
- *
- *
+ * 
+ * 
  */
 public class Activator extends ComponentActivatorAbstractBase {
     protected static final Logger logger = LoggerFactory
             .getLogger(Activator.class);
 
     /**
-     * Function called when the activator starts just after some
-     * initializations are done by the
-     * ComponentActivatorAbstractBase.
-     *
+     * Function called when the activator starts just after some initializations
+     * are done by the ComponentActivatorAbstractBase.
+     * 
      */
     public void init() {
     }
 
     /**
-     * Function called when the activator stops just before the
-     * cleanup done by ComponentActivatorAbstractBase
-     *
+     * Function called when the activator stops just before the cleanup done by
+     * ComponentActivatorAbstractBase
+     * 
      */
     public void destroy() {
     }
 
     /**
-     * Function that is used to communicate to dependency manager the
-     * list of known implementations for services inside a container
-     *
-     *
+     * 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
+     *         instantiated in order to get an fully working implementation
+     *         Object
      */
     public Object[] getImplementations() {
         Object[] res = { TopologyServices.class, DataPacketServices.class,
-                InventoryService.class, ReadService.class };
+                InventoryService.class, ReadService.class,
+                FlowProgrammerNotifier.class };
         return res;
     }
 
     /**
-     * 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
-     * @param imp Implementation class that is being configured,
-     * needed as long as the same routine can configure multiple
-     * implementations
-     * @param containerName The containerName being configured, this allow
-     * also optional per-container different behavior if needed, usually
-     * should not be the case though.
+     * 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
+     * @param imp
+     *            Implementation class that is being configured, needed as long
+     *            as the same routine can configure multiple implementations
+     * @param containerName
+     *            The containerName being configured, this allow also optional
+     *            per-container different behavior if needed, usually should not
+     *            be the case though.
      */
     public void configureInstance(Component c, Object imp, String containerName) {
         if (imp.equals(TopologyServices.class)) {
             // export the service to be used by SAL
-            c.setInterface(new String[] {
-                    IPluginInTopologyService.class.getName(),
-                    ITopologyServiceShimListener.class.getName() }, null);
+            c.setInterface(
+                    new String[] { IPluginInTopologyService.class.getName(),
+                            ITopologyServiceShimListener.class.getName() },
+                    null);
             // Hook the services coming in from SAL, as optional in
             // case SAL is not yet there, could happen
-            c.add(createContainerServiceDependency(containerName).setService(
-                    IPluginOutTopologyService.class).setCallbacks(
-                    "setPluginOutTopologyService",
-                    "unsetPluginOutTopologyService").setRequired(false));
-            c.add(createServiceDependency().setService(
-                    IRefreshInternalProvider.class).setCallbacks(
-                    "setRefreshInternalProvider",
-                    "unsetRefreshInternalProvider").setRequired(false));
+            c.add(createContainerServiceDependency(containerName)
+                    .setService(IPluginOutTopologyService.class)
+                    .setCallbacks("setPluginOutTopologyService",
+                            "unsetPluginOutTopologyService").setRequired(false));
+            c.add(createServiceDependency()
+                    .setService(IRefreshInternalProvider.class)
+                    .setCallbacks("setRefreshInternalProvider",
+                            "unsetRefreshInternalProvider").setRequired(false));
         }
 
         if (imp.equals(InventoryService.class)) {
             // export the service
-            c.setInterface(new String[] {
-                    IPluginInInventoryService.class.getName(),
-                    IStatisticsListener.class.getName(),
-                    IInventoryShimInternalListener.class.getName() }, null);
+            c.setInterface(
+                    new String[] { IPluginInInventoryService.class.getName(),
+                            IStatisticsListener.class.getName(),
+                            IInventoryShimInternalListener.class.getName() },
+                    null);
 
             // Now lets add a service dependency to make sure the
             // provider of service exists
-            c.add(createServiceDependency().setService(IController.class,
-                    "(name=Controller)").setCallbacks("setController",
-                    "unsetController").setRequired(true));
-            c.add(createContainerServiceDependency(containerName).setService(
-                    IPluginOutInventoryService.class).setCallbacks(
-                    "setPluginOutInventoryServices",
-                    "unsetPluginOutInventoryServices").setRequired(false));
+            c.add(createServiceDependency()
+                    .setService(IController.class, "(name=Controller)")
+                    .setCallbacks("setController", "unsetController")
+                    .setRequired(true));
+            c.add(createContainerServiceDependency(containerName)
+                    .setService(IPluginOutInventoryService.class)
+                    .setCallbacks("setPluginOutInventoryServices",
+                            "unsetPluginOutInventoryServices")
+                    .setRequired(false));
         }
 
         if (imp.equals(DataPacketServices.class)) {
@@ -139,17 +147,19 @@ public class Activator extends ComponentActivatorAbstractBase {
             c.setInterface(IPluginInDataPacketService.class.getName(), props);
             // Hook the services coming in from SAL, as optional in
             // case SAL is not yet there, could happen
-            c.add(createServiceDependency().setService(IController.class,
-                    "(name=Controller)").setCallbacks("setController",
-                    "unsetController").setRequired(true));
+            c.add(createServiceDependency()
+                    .setService(IController.class, "(name=Controller)")
+                    .setCallbacks("setController", "unsetController")
+                    .setRequired(true));
             // This is required for the transmission to happen properly
             c.add(createServiceDependency().setService(IDataPacketMux.class)
                     .setCallbacks("setIDataPacketMux", "unsetIDataPacketMux")
                     .setRequired(true));
-            c.add(createContainerServiceDependency(containerName).setService(
-                    IPluginOutDataPacketService.class).setCallbacks(
-                    "setPluginOutDataPacketService",
-                    "unsetPluginOutDataPacketService").setRequired(false));
+            c.add(createContainerServiceDependency(containerName)
+                    .setService(IPluginOutDataPacketService.class)
+                    .setCallbacks("setPluginOutDataPacketService",
+                            "unsetPluginOutDataPacketService")
+                    .setRequired(false));
         }
 
         if (imp.equals(ReadService.class)) {
@@ -159,21 +169,36 @@ public class Activator extends ComponentActivatorAbstractBase {
             // by SAL
             props.put("protocolPluginType", Node.NodeIDType.OPENFLOW);
             c.setInterface(IPluginInReadService.class.getName(), props);
-            c.add(createServiceDependency().setService(
-                    IPluginReadServiceFilter.class).setCallbacks("setService",
-                    "unsetService").setRequired(true));
+            c.add(createServiceDependency()
+                    .setService(IPluginReadServiceFilter.class)
+                    .setCallbacks("setService", "unsetService")
+                    .setRequired(true));
+        }
+
+        if (imp.equals(FlowProgrammerNotifier.class)) {
+            // export the service to be used by SAL
+            Dictionary<String, Object> props = new Hashtable<String, Object>();
+            // Set the protocolPluginType property which will be used
+            // by SAL
+            props.put("protocolPluginType", Node.NodeIDType.OPENFLOW);
+            c.setInterface(IFlowProgrammerNotifier.class.getName(), props);
+
+            c.add(createContainerServiceDependency(containerName)
+                    .setService(IPluginOutFlowProgrammerService.class)
+                    .setCallbacks("setPluginOutFlowProgrammerService",
+                            "unsetPluginOutFlowProgrammerService")
+                    .setRequired(true));
         }
     }
 
     /**
-     * Function that is used to communicate to dependency manager the
-     * list of known implementations for services that are container
-     * independent.
-     *
-     *
+     * Function that is used to communicate to dependency manager the list of
+     * known implementations for services that are container independent.
+     * 
+     * 
      * @return An array containing all the CLASS objects that will be
-     * instantiated in order to get an fully working implementation
-     * Object
+     *         instantiated in order to get an fully working implementation
+     *         Object
      */
     public Object[] getGlobalImplementations() {
         Object[] res = { Controller.class, OFStatisticsManager.class,
@@ -184,14 +209,15 @@ 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
-     * @param imp Implementation class that is being configured,
-     * needed as long as the same routine can configure multiple
-     * implementations
+     * 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
+     * @param imp
+     *            Implementation class that is being configured, needed as long
+     *            as the same routine can configure multiple implementations
      */
     public void configureGlobalInstance(Component c, Object imp) {
 
@@ -208,26 +234,39 @@ public class Activator extends ComponentActivatorAbstractBase {
             // Set the protocolPluginType property which will be used
             // by SAL
             props.put("protocolPluginType", Node.NodeIDType.OPENFLOW);
-            c.setInterface(IPluginInFlowProgrammerService.class
-                           .getName(), props);
+            c.setInterface(
+                    new String[] {
+                            IPluginInFlowProgrammerService.class.getName(),
+                            IMessageListener.class.getName(),
+                            IContainerListener.class.getName() }, props);
+
+            c.add(createServiceDependency()
+                    .setService(IController.class, "(name=Controller)")
+                    .setCallbacks("setController", "unsetController")
+                    .setRequired(true));
+
+            c.add(createServiceDependency()
+                    .setService(IFlowProgrammerNotifier.class)
+                    .setCallbacks("setFlowProgrammerNotifier",
+                            "unsetsetFlowProgrammerNotifier")
+                    .setRequired(false));
 
-            c.add(createServiceDependency().setService(IController.class,
-                    "(name=Controller)").setCallbacks("setController",
-                    "unsetController").setRequired(true));
         }
 
         if (imp.equals(ReadServiceFilter.class)) {
 
-            c.setInterface(new String[] {
-                    IPluginReadServiceFilter.class.getName(),
-                    IContainerListener.class.getName() }, null);
+            c.setInterface(
+                    new String[] { IPluginReadServiceFilter.class.getName(),
+                            IContainerListener.class.getName() }, null);
 
-            c.add(createServiceDependency().setService(IController.class,
-                    "(name=Controller)").setCallbacks("setController",
-                    "unsetController").setRequired(true));
-            c.add(createServiceDependency().setService(
-                    IOFStatisticsManager.class).setCallbacks("setService",
-                    "unsetService").setRequired(true));
+            c.add(createServiceDependency()
+                    .setService(IController.class, "(name=Controller)")
+                    .setCallbacks("setController", "unsetController")
+                    .setRequired(true));
+            c.add(createServiceDependency()
+                    .setService(IOFStatisticsManager.class)
+                    .setCallbacks("setService", "unsetService")
+                    .setRequired(true));
         }
 
         if (imp.equals(OFStatisticsManager.class)) {
@@ -235,34 +274,38 @@ public class Activator extends ComponentActivatorAbstractBase {
             c.setInterface(new String[] { IOFStatisticsManager.class.getName(),
                     IInventoryShimExternalListener.class.getName() }, null);
 
-            c.add(createServiceDependency().setService(IController.class,
-                    "(name=Controller)").setCallbacks("setController",
-                    "unsetController").setRequired(true));
-            c.add(createServiceDependency().setService(
-                       IStatisticsListener.class)
-                       .setCallbacks("setStatisticsListener",
-                    "unsetStatisticsListener").setRequired(false));
+            c.add(createServiceDependency()
+                    .setService(IController.class, "(name=Controller)")
+                    .setCallbacks("setController", "unsetController")
+                    .setRequired(true));
+            c.add(createServiceDependency()
+                    .setService(IStatisticsListener.class)
+                    .setCallbacks("setStatisticsListener",
+                            "unsetStatisticsListener").setRequired(false));
         }
 
         if (imp.equals(DiscoveryService.class)) {
             // export the service
-            c.setInterface(new String[] {
-                    IInventoryShimExternalListener.class.getName(),
-                    IDataPacketListen.class.getName(),
-                    IContainerListener.class.getName() }, null);
-
-            c.add(createServiceDependency().setService(IController.class,
-                    "(name=Controller)").setCallbacks("setController",
-                    "unsetController").setRequired(true));
+            c.setInterface(
+                    new String[] {
+                            IInventoryShimExternalListener.class.getName(),
+                            IDataPacketListen.class.getName(),
+                            IContainerListener.class.getName() }, null);
+
+            c.add(createServiceDependency()
+                    .setService(IController.class, "(name=Controller)")
+                    .setCallbacks("setController", "unsetController")
+                    .setRequired(true));
             c.add(createContainerServiceDependency(
-                    GlobalConstants.DEFAULT.toString()).setService(
-                    IPluginInInventoryService.class).setCallbacks(
-                    "setPluginInInventoryService",
-                    "unsetPluginInInventoryService").setRequired(true));
+                    GlobalConstants.DEFAULT.toString())
+                    .setService(IPluginInInventoryService.class)
+                    .setCallbacks("setPluginInInventoryService",
+                            "unsetPluginInInventoryService").setRequired(true));
             c.add(createServiceDependency().setService(IDataPacketMux.class)
                     .setCallbacks("setIDataPacketMux", "unsetIDataPacketMux")
                     .setRequired(true));
-            c.add(createServiceDependency().setService(IDiscoveryService.class)
+            c.add(createServiceDependency()
+                    .setService(IDiscoveryService.class)
                     .setCallbacks("setDiscoveryService",
                             "unsetDiscoveryService").setRequired(true));
         }
@@ -274,15 +317,18 @@ public class Activator extends ComponentActivatorAbstractBase {
                     IContainerListener.class.getName(),
                     IInventoryShimExternalListener.class.getName() }, null);
 
-            c.add(createServiceDependency().setService(IController.class,
-                    "(name=Controller)").setCallbacks("setController",
-                    "unsetController").setRequired(true));
-            c.add(createServiceDependency().setService(
-                    IPluginOutDataPacketService.class).setCallbacks(
-                    "setPluginOutDataPacketService",
-                    "unsetPluginOutDataPacketService").setRequired(false));
+            c.add(createServiceDependency()
+                    .setService(IController.class, "(name=Controller)")
+                    .setCallbacks("setController", "unsetController")
+                    .setRequired(true));
+            c.add(createServiceDependency()
+                    .setService(IPluginOutDataPacketService.class)
+                    .setCallbacks("setPluginOutDataPacketService",
+                            "unsetPluginOutDataPacketService")
+                    .setRequired(false));
             // See if there is any local packet dispatcher
-            c.add(createServiceDependency().setService(IDataPacketListen.class)
+            c.add(createServiceDependency()
+                    .setService(IDataPacketListen.class)
                     .setCallbacks("setIDataPacketListen",
                             "unsetIDataPacketListen").setRequired(false));
         }
@@ -291,31 +337,35 @@ public class Activator extends ComponentActivatorAbstractBase {
             c.setInterface(new String[] { IContainerListener.class.getName() },
                     null);
 
-            c.add(createServiceDependency().setService(IController.class,
-                    "(name=Controller)").setCallbacks("setController",
-                    "unsetController").setRequired(true));
-            c.add(createServiceDependency().setService(
-                    IInventoryShimInternalListener.class).setCallbacks(
-                    "setInventoryShimInternalListener",
-                    "unsetInventoryShimInternalListener").setRequired(true));
-            c.add(createServiceDependency().setService(
-                    IInventoryShimExternalListener.class).setCallbacks(
-                    "setInventoryShimExternalListener",
-                    "unsetInventoryShimExternalListener").setRequired(false));
+            c.add(createServiceDependency()
+                    .setService(IController.class, "(name=Controller)")
+                    .setCallbacks("setController", "unsetController")
+                    .setRequired(true));
+            c.add(createServiceDependency()
+                    .setService(IInventoryShimInternalListener.class)
+                    .setCallbacks("setInventoryShimInternalListener",
+                            "unsetInventoryShimInternalListener")
+                    .setRequired(true));
+            c.add(createServiceDependency()
+                    .setService(IInventoryShimExternalListener.class)
+                    .setCallbacks("setInventoryShimExternalListener",
+                            "unsetInventoryShimExternalListener")
+                    .setRequired(false));
         }
 
         if (imp.equals(TopologyServiceShim.class)) {
             c.setInterface(new String[] { IDiscoveryService.class.getName(),
                     IContainerListener.class.getName(),
                     IRefreshInternalProvider.class.getName() }, null);
-            c.add(createServiceDependency().setService(
-                    ITopologyServiceShimListener.class).setCallbacks(
-                    "setTopologyServiceShimListener",
-                    "unsetTopologyServiceShimListener").setRequired(true));
-            c.add(createServiceDependency().setService(
-                    IOFStatisticsManager.class).setCallbacks(
-                    "setStatisticsManager", "unsetStatisticsManager")
-                    .setRequired(false));
+            c.add(createServiceDependency()
+                    .setService(ITopologyServiceShimListener.class)
+                    .setCallbacks("setTopologyServiceShimListener",
+                            "unsetTopologyServiceShimListener")
+                    .setRequired(true));
+            c.add(createServiceDependency()
+                    .setService(IOFStatisticsManager.class)
+                    .setCallbacks("setStatisticsManager",
+                            "unsetStatisticsManager").setRequired(false));
         }
     }
 }