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.INodeFactory;
11 import org.opendaylight.controller.sal.core.Node;
12 import org.opendaylight.controller.sal.core.NodeConnector;
13 import org.opendaylight.controller.sal.discovery.IDiscoveryService;
14 import org.opendaylight.controller.sal.flowprogrammer.IPluginInFlowProgrammerService;
15 import org.opendaylight.controller.sal.inventory.IPluginInInventoryService;
16 import org.opendaylight.controller.sal.inventory.IPluginOutInventoryService;
17 import org.opendaylight.controller.sal.packet.IPluginInDataPacketService;
18 import org.opendaylight.controller.sal.packet.IPluginOutDataPacketService;
19 import org.opendaylight.controller.sal.reader.IPluginInReadService;
20 import org.opendaylight.controller.sal.reader.IReadService;
21 import org.opendaylight.controller.sal.topology.IPluginInTopologyService;
22 import org.opendaylight.controller.sal.topology.IPluginOutTopologyService;
23 import org.opendaylight.controller.sal.utils.GlobalConstants;
25 import org.slf4j.Logger;
26 import org.slf4j.LoggerFactory;
29 * stub protocol plugin Activator
33 public class Activator extends ComponentActivatorAbstractBase {
34 protected static final Logger logger = LoggerFactory
35 .getLogger(Activator.class);
38 * Function called when the activator starts just after some initializations
39 * are done by the ComponentActivatorAbstractBase.
43 Node.NodeIDType.registerIDType("STUB", Integer.class);
44 NodeConnector.NodeConnectorIDType.registerIDType("STUB", Integer.class, "STUB");
48 * Function called when the activator stops just before the cleanup done by
49 * ComponentActivatorAbstractBase
52 public void destroy() {
53 Node.NodeIDType.unRegisterIDType("STUB");
54 NodeConnector.NodeConnectorIDType.unRegisterIDType("STUB");
58 * Function that is used to communicate to dependency manager the list of
59 * known implementations for services inside a container
62 * @return An array containing all the CLASS objects that will be
63 * instantiated in order to get an fully working implementation
66 public Object[] getImplementations() {
67 Object[] res = { ReadService.class, InventoryService.class };
72 * Function that is called when configuration of the dependencies is
76 * dependency manager Component object, used for configuring the
77 * dependencies exported and imported
79 * Implementation class that is being configured, needed as long
80 * as the same routine can configure multiple implementations
81 * @param containerName
82 * The containerName being configured, this allow also optional
83 * per-container different behavior if needed, usually should not
86 public void configureInstance(Component c, Object imp, String containerName) {
87 if (imp.equals(ReadService.class)) {
88 // export the service to be used by SAL
89 Dictionary<String, Object> props = new Hashtable<String, Object>();
90 // Set the protocolPluginType property which will be used
92 props.put("protocolPluginType", "STUB");
93 c.setInterface(IPluginInReadService.class.getName(), props);
96 if (imp.equals(InventoryService.class)) {
97 // export the service to be used by SAL
98 Dictionary<String, Object> props = new Hashtable<String, Object>();
99 // Set the protocolPluginType property which will be used
101 props.put("protocolPluginType", "STUB");
102 c.setInterface(IPluginInInventoryService.class.getName(), props);
106 public Object[] getGlobalImplementations() {
107 Object[] res = { FlowProgrammerService.class, StubNodeFactory.class };
111 public void configureGlobalInstance(Component c, Object imp){
112 if (imp.equals(FlowProgrammerService.class)) {
113 // export the service to be used by SAL
114 Dictionary<String, Object> props = new Hashtable<String, Object>();
115 // Set the protocolPluginType property which will be used
117 props.put("protocolPluginType", "STUB");
118 c.setInterface(IPluginInFlowProgrammerService.class.getName(), props);
120 if (imp.equals(StubNodeFactory.class)) {
121 // export the service to be used by SAL
122 Dictionary<String, Object> props = new Hashtable<String, Object>();
123 // Set the protocolPluginType property which will be used
125 props.put("protocolPluginType", "STUB");
126 props.put("protocolName", "STUB");
127 c.setInterface(INodeFactory.class.getName(), props);