NodeFactory service
[controller.git] / opendaylight / protocol_plugins / stub / src / main / java / org / opendaylight / controller / protocol_plugins / stub / internal / Activator.java
index ad447b9584c79284bad5a03ad64ab07c8e7e91ce..9c47b3b9839dec497ff8dc0d6a23d3e896aad35d 100644 (file)
@@ -7,7 +7,9 @@ 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.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;
@@ -38,6 +40,8 @@ public class Activator extends ComponentActivatorAbstractBase {
      * 
      */
     public void init() {
+        Node.NodeIDType.registerIDType("STUB", Integer.class);
+        NodeConnector.NodeConnectorIDType.registerIDType("STUB", Integer.class, "STUB");
     }
 
     /**
@@ -46,6 +50,8 @@ public class Activator extends ComponentActivatorAbstractBase {
      * 
      */
     public void destroy() {
+        Node.NodeIDType.unRegisterIDType("STUB");
+        NodeConnector.NodeConnectorIDType.unRegisterIDType("STUB");
     }
 
     /**
@@ -58,7 +64,7 @@ public class Activator extends ComponentActivatorAbstractBase {
      *         Object
      */
     public Object[] getImplementations() {
-        Object[] res = { ReadService.class };
+        Object[] res = { ReadService.class, InventoryService.class };
         return res;
     }
 
@@ -83,9 +89,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", Node.NodeIDType.OPENFLOW);
+            props.put("protocolPluginType", "STUB");
             c.setInterface(IPluginInReadService.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("protocolPluginType", "STUB");
+            c.setInterface(IPluginInInventoryService.class.getName(), props);
+        }
+    }
+    
+    public Object[] getGlobalImplementations() {
+        Object[] res = { FlowProgrammerService.class, StubNodeFactory.class };
+        return res;
+    }
+    
+    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");
+            c.setInterface(IPluginInFlowProgrammerService.class.getName(), props);
+        }
+        if (imp.equals(StubNodeFactory.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("protocolName", "STUB");
+            c.setInterface(INodeFactory.class.getName(), props);
+        }
+    }
 }