Add first integration test for the TopologyManager bundle
[controller.git] / opendaylight / protocol_plugins / stub / src / main / java / org / opendaylight / controller / protocol_plugins / stub / internal / Activator.java
index 8e4c985c06b76ea6055717ae7a5d46370335673e..843e60ec36fba1218b0aa61eac75a019d5e96067 100644 (file)
@@ -1,35 +1,39 @@
-package org.opendaylight.controller.protocol_plugins.stub.internal;
+/*
+ * Copyright (c) 2013 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
+ */
 
-import java.util.Dictionary;
-import java.util.Hashtable;
 
-import org.apache.felix.dm.Component;
 
+
+package org.opendaylight.controller.protocol_plugins.stub.internal;
+
+import org.apache.felix.dm.Component;
 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
-import org.opendaylight.controller.sal.core.IContainerListener;
-import org.opendaylight.controller.sal.utils.INodeConnectorFactory;
-import org.opendaylight.controller.sal.utils.INodeFactory;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.NodeConnector;
-import org.opendaylight.controller.sal.discovery.IDiscoveryService;
 import org.opendaylight.controller.sal.flowprogrammer.IPluginInFlowProgrammerService;
 import org.opendaylight.controller.sal.inventory.IPluginInInventoryService;
 import org.opendaylight.controller.sal.inventory.IPluginOutInventoryService;
-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.IReadService;
 import org.opendaylight.controller.sal.topology.IPluginInTopologyService;
 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.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.util.Dictionary;
+import java.util.Hashtable;
+
 /**
  * stub protocol plugin Activator
- * 
- * 
+ *
+ *
  */
 public class Activator extends ComponentActivatorAbstractBase {
     protected static final Logger logger = LoggerFactory
@@ -38,8 +42,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() {
         Node.NodeIDType.registerIDType("STUB", Integer.class);
         NodeConnector.NodeConnectorIDType.registerIDType("STUB", Integer.class, "STUB");
@@ -48,8 +53,9 @@ public class Activator extends ComponentActivatorAbstractBase {
     /**
      * Function called when the activator stops just before the cleanup done by
      * ComponentActivatorAbstractBase
-     * 
+     *
      */
+    @Override
     public void destroy() {
         Node.NodeIDType.unRegisterIDType("STUB");
         NodeConnector.NodeConnectorIDType.unRegisterIDType("STUB");
@@ -58,21 +64,22 @@ 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 = { ReadService.class, InventoryService.class };
+        Object[] res = { ReadService.class, InventoryService.class, TopologyServices.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
@@ -84,13 +91,14 @@ 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(ReadService.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", "STUB");
+            props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "STUB");
             c.setInterface(IPluginInReadService.class.getName(), props);
         }
 
@@ -99,23 +107,42 @@ public class Activator extends ComponentActivatorAbstractBase {
             Dictionary<String, Object> props = new Hashtable<String, Object>();
             // Set the protocolPluginType property which will be used
             // by SAL
-            props.put("protocolPluginType", "STUB");
+            props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "STUB");
             c.setInterface(IPluginInInventoryService.class.getName(), props);
         }
+
+        if(imp.equals(TopologyServices.class)){
+            Dictionary<String, Object> props = new Hashtable<String, Object>();
+            props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "STUB");
+            c.setInterface(IPluginInTopologyService.class.getName(), props);
+            c.add(createServiceDependency().setService(IPluginOutTopologyService.class, "")
+                    .setCallbacks("setPluginOutTopologyService", "unsetPluginOutTopologyService")
+                    .setRequired(true));
+
+        }
+
     }
-    
+
+    @Override
     public Object[] getGlobalImplementations() {
-        Object[] res = { FlowProgrammerService.class, StubNodeFactory.class, StubNodeConnectorFactory.class };
+        Object[] res =
+                {
+                        FlowProgrammerService.class,
+                        StubNodeFactory.class,
+                        StubNodeConnectorFactory.class,
+                        InventoryService.class
+                };
         return res;
     }
-    
+
+    @Override
     public void configureGlobalInstance(Component c, Object imp){
         if (imp.equals(FlowProgrammerService.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", "STUB");
+            props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "STUB");
             c.setInterface(IPluginInFlowProgrammerService.class.getName(), props);
         }
         if (imp.equals(StubNodeFactory.class)) {
@@ -123,7 +150,7 @@ public class Activator extends ComponentActivatorAbstractBase {
             Dictionary<String, Object> props = new Hashtable<String, Object>();
             // Set the protocolPluginType property which will be used
             // by SAL
-            props.put("protocolPluginType", "STUB");
+            props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "STUB");
             props.put("protocolName", "STUB");
             c.setInterface(INodeFactory.class.getName(), props);
         }
@@ -132,10 +159,22 @@ public class Activator extends ComponentActivatorAbstractBase {
             Dictionary<String, Object> props = new Hashtable<String, Object>();
             // Set the protocolPluginType property which will be used
             // by SAL
-            props.put("protocolPluginType", "STUB");
+            props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "STUB");
             props.put("protocolName", "STUB");
             c.setInterface(INodeConnectorFactory.class.getName(), props);
         }
-        
+        if (imp.equals(InventoryService.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(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "STUB");
+            props.put("scope", "Global");
+            c.setInterface(IPluginInInventoryService.class.getName(), props);
+            c.add(createServiceDependency().setService(IPluginOutInventoryService.class, "(scope=Global)")
+                    .setCallbacks("setPluginOutInventoryServices", "unsetPluginOutInventoryServices")
+                    .setRequired(true));
+        }
+
     }
 }