1 package org.opendaylight.controller.protocol_plugins.stub.internal;
3 import java.util.Dictionary;
4 import java.util.Hashtable;
6 import org.apache.felix.dm.Component;
8 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
9 import org.opendaylight.controller.sal.core.IContainerListener;
10 import org.opendaylight.controller.sal.utils.INodeConnectorFactory;
11 import org.opendaylight.controller.sal.utils.INodeFactory;
12 import org.opendaylight.controller.sal.core.Node;
13 import org.opendaylight.controller.sal.core.NodeConnector;
14 import org.opendaylight.controller.sal.discovery.IDiscoveryService;
15 import org.opendaylight.controller.sal.flowprogrammer.IPluginInFlowProgrammerService;
16 import org.opendaylight.controller.sal.inventory.IPluginInInventoryService;
17 import org.opendaylight.controller.sal.inventory.IPluginOutInventoryService;
18 import org.opendaylight.controller.sal.packet.IPluginInDataPacketService;
19 import org.opendaylight.controller.sal.packet.IPluginOutDataPacketService;
20 import org.opendaylight.controller.sal.reader.IPluginInReadService;
21 import org.opendaylight.controller.sal.reader.IReadService;
22 import org.opendaylight.controller.sal.topology.IPluginInTopologyService;
23 import org.opendaylight.controller.sal.topology.IPluginOutTopologyService;
24 import org.opendaylight.controller.sal.utils.GlobalConstants;
26 import org.slf4j.Logger;
27 import org.slf4j.LoggerFactory;
30 * stub protocol plugin Activator
34 public class Activator extends ComponentActivatorAbstractBase {
35 protected static final Logger logger = LoggerFactory
36 .getLogger(Activator.class);
39 * Function called when the activator starts just after some initializations
40 * are done by the ComponentActivatorAbstractBase.
44 Node.NodeIDType.registerIDType("STUB", Integer.class);
45 NodeConnector.NodeConnectorIDType.registerIDType("STUB", Integer.class, "STUB");
49 * Function called when the activator stops just before the cleanup done by
50 * ComponentActivatorAbstractBase
53 public void destroy() {
54 Node.NodeIDType.unRegisterIDType("STUB");
55 NodeConnector.NodeConnectorIDType.unRegisterIDType("STUB");
59 * Function that is used to communicate to dependency manager the list of
60 * known implementations for services inside a container
63 * @return An array containing all the CLASS objects that will be
64 * instantiated in order to get an fully working implementation
67 public Object[] getImplementations() {
68 Object[] res = { ReadService.class, InventoryService.class };
73 * Function that is called when configuration of the dependencies is
77 * dependency manager Component object, used for configuring the
78 * dependencies exported and imported
80 * Implementation class that is being configured, needed as long
81 * as the same routine can configure multiple implementations
82 * @param containerName
83 * The containerName being configured, this allow also optional
84 * per-container different behavior if needed, usually should not
87 public void configureInstance(Component c, Object imp, String containerName) {
88 if (imp.equals(ReadService.class)) {
89 // export the service to be used by SAL
90 Dictionary<String, Object> props = new Hashtable<String, Object>();
91 // Set the protocolPluginType property which will be used
93 props.put("protocolPluginType", "STUB");
94 c.setInterface(IPluginInReadService.class.getName(), props);
97 if (imp.equals(InventoryService.class)) {
98 // export the service to be used by SAL
99 Dictionary<String, Object> props = new Hashtable<String, Object>();
100 // Set the protocolPluginType property which will be used
102 props.put("protocolPluginType", "STUB");
103 c.setInterface(IPluginInInventoryService.class.getName(), props);
107 public Object[] getGlobalImplementations() {
108 Object[] res = { FlowProgrammerService.class, StubNodeFactory.class, StubNodeConnectorFactory.class };
112 public void configureGlobalInstance(Component c, Object imp){
113 if (imp.equals(FlowProgrammerService.class)) {
114 // export the service to be used by SAL
115 Dictionary<String, Object> props = new Hashtable<String, Object>();
116 // Set the protocolPluginType property which will be used
118 props.put("protocolPluginType", "STUB");
119 c.setInterface(IPluginInFlowProgrammerService.class.getName(), props);
121 if (imp.equals(StubNodeFactory.class)) {
122 // export the service to be used by SAL
123 Dictionary<String, Object> props = new Hashtable<String, Object>();
124 // Set the protocolPluginType property which will be used
126 props.put("protocolPluginType", "STUB");
127 props.put("protocolName", "STUB");
128 c.setInterface(INodeFactory.class.getName(), props);
130 if (imp.equals(StubNodeConnectorFactory.class)) {
131 // export the service to be used by SAL
132 Dictionary<String, Object> props = new Hashtable<String, Object>();
133 // Set the protocolPluginType property which will be used
135 props.put("protocolPluginType", "STUB");
136 props.put("protocolName", "STUB");
137 c.setInterface(INodeConnectorFactory.class.getName(), props);