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.
45 Node.NodeIDType.registerIDType("STUB", Integer.class);
46 NodeConnector.NodeConnectorIDType.registerIDType("STUB", Integer.class, "STUB");
50 * Function called when the activator stops just before the cleanup done by
51 * ComponentActivatorAbstractBase
55 public void destroy() {
56 Node.NodeIDType.unRegisterIDType("STUB");
57 NodeConnector.NodeConnectorIDType.unRegisterIDType("STUB");
61 * Function that is used to communicate to dependency manager the list of
62 * known implementations for services inside a container
65 * @return An array containing all the CLASS objects that will be
66 * instantiated in order to get an fully working implementation
70 public Object[] getImplementations() {
71 Object[] res = { ReadService.class, InventoryService.class };
76 * Function that is called when configuration of the dependencies is
80 * dependency manager Component object, used for configuring the
81 * dependencies exported and imported
83 * Implementation class that is being configured, needed as long
84 * as the same routine can configure multiple implementations
85 * @param containerName
86 * The containerName being configured, this allow also optional
87 * per-container different behavior if needed, usually should not
91 public void configureInstance(Component c, Object imp, String containerName) {
92 if (imp.equals(ReadService.class)) {
93 // export the service to be used by SAL
94 Dictionary<String, Object> props = new Hashtable<String, Object>();
95 // Set the protocolPluginType property which will be used
97 props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "STUB");
98 c.setInterface(IPluginInReadService.class.getName(), props);
101 if (imp.equals(InventoryService.class)) {
102 // export the service to be used by SAL
103 Dictionary<String, Object> props = new Hashtable<String, Object>();
104 // Set the protocolPluginType property which will be used
106 props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "STUB");
107 c.setInterface(IPluginInInventoryService.class.getName(), props);
112 public Object[] getGlobalImplementations() {
115 FlowProgrammerService.class,
116 StubNodeFactory.class,
117 StubNodeConnectorFactory.class,
118 InventoryService.class };
123 public void configureGlobalInstance(Component c, Object imp){
124 if (imp.equals(FlowProgrammerService.class)) {
125 // export the service to be used by SAL
126 Dictionary<String, Object> props = new Hashtable<String, Object>();
127 // Set the protocolPluginType property which will be used
129 props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "STUB");
130 c.setInterface(IPluginInFlowProgrammerService.class.getName(), props);
132 if (imp.equals(StubNodeFactory.class)) {
133 // export the service to be used by SAL
134 Dictionary<String, Object> props = new Hashtable<String, Object>();
135 // Set the protocolPluginType property which will be used
137 props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "STUB");
138 props.put("protocolName", "STUB");
139 c.setInterface(INodeFactory.class.getName(), props);
141 if (imp.equals(StubNodeConnectorFactory.class)) {
142 // export the service to be used by SAL
143 Dictionary<String, Object> props = new Hashtable<String, Object>();
144 // Set the protocolPluginType property which will be used
146 props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "STUB");
147 props.put("protocolName", "STUB");
148 c.setInterface(INodeConnectorFactory.class.getName(), props);
150 if (imp.equals(InventoryService.class)) {
151 // export the service to be used by SAL
152 Dictionary<String, Object> props = new Hashtable<String, Object>();
153 // Set the protocolPluginType property which will be used
155 props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "STUB");
156 props.put("scope", "Global");
157 c.setInterface(IPluginInInventoryService.class.getName(), props);
158 c.add(createServiceDependency().setService(IPluginOutInventoryService.class, "(scope=Global)")
159 .setCallbacks("setPluginOutInventoryServices", "unsetPluginOutInventoryServices")