protocol plugin stub node type
[controller.git] / opendaylight / protocol_plugins / stub / src / main / java / org / opendaylight / controller / protocol_plugins / stub / internal / Activator.java
1 package org.opendaylight.controller.protocol_plugins.stub.internal;
2
3 import java.util.Dictionary;
4 import java.util.Hashtable;
5
6 import org.apache.felix.dm.Component;
7
8 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
9 import org.opendaylight.controller.sal.core.IContainerListener;
10 import org.opendaylight.controller.sal.core.Node;
11 import org.opendaylight.controller.sal.core.NodeConnector;
12 import org.opendaylight.controller.sal.discovery.IDiscoveryService;
13 import org.opendaylight.controller.sal.flowprogrammer.IPluginInFlowProgrammerService;
14 import org.opendaylight.controller.sal.inventory.IPluginInInventoryService;
15 import org.opendaylight.controller.sal.inventory.IPluginOutInventoryService;
16 import org.opendaylight.controller.sal.packet.IPluginInDataPacketService;
17 import org.opendaylight.controller.sal.packet.IPluginOutDataPacketService;
18 import org.opendaylight.controller.sal.reader.IPluginInReadService;
19 import org.opendaylight.controller.sal.reader.IReadService;
20 import org.opendaylight.controller.sal.topology.IPluginInTopologyService;
21 import org.opendaylight.controller.sal.topology.IPluginOutTopologyService;
22 import org.opendaylight.controller.sal.utils.GlobalConstants;
23
24 import org.slf4j.Logger;
25 import org.slf4j.LoggerFactory;
26
27 /**
28  * stub protocol plugin Activator
29  * 
30  * 
31  */
32 public class Activator extends ComponentActivatorAbstractBase {
33     protected static final Logger logger = LoggerFactory
34             .getLogger(Activator.class);
35
36     /**
37      * Function called when the activator starts just after some initializations
38      * are done by the ComponentActivatorAbstractBase.
39      * 
40      */
41     public void init() {
42         Node.NodeIDType.registerIDType("STUB", Integer.class);
43         NodeConnector.NodeConnectorIDType.registerIDType("STUB", Integer.class, "STUB");
44     }
45
46     /**
47      * Function called when the activator stops just before the cleanup done by
48      * ComponentActivatorAbstractBase
49      * 
50      */
51     public void destroy() {
52         Node.NodeIDType.unRegisterIDType("STUB");
53         NodeConnector.NodeConnectorIDType.unRegisterIDType("STUB");
54     }
55
56     /**
57      * Function that is used to communicate to dependency manager the list of
58      * known implementations for services inside a container
59      * 
60      * 
61      * @return An array containing all the CLASS objects that will be
62      *         instantiated in order to get an fully working implementation
63      *         Object
64      */
65     public Object[] getImplementations() {
66         Object[] res = { ReadService.class, InventoryService.class };
67         return res;
68     }
69
70     /**
71      * Function that is called when configuration of the dependencies is
72      * required.
73      * 
74      * @param c
75      *            dependency manager Component object, used for configuring the
76      *            dependencies exported and imported
77      * @param imp
78      *            Implementation class that is being configured, needed as long
79      *            as the same routine can configure multiple implementations
80      * @param containerName
81      *            The containerName being configured, this allow also optional
82      *            per-container different behavior if needed, usually should not
83      *            be the case though.
84      */
85     public void configureInstance(Component c, Object imp, String containerName) {
86         if (imp.equals(ReadService.class)) {
87             // export the service to be used by SAL
88             Dictionary<String, Object> props = new Hashtable<String, Object>();
89             // Set the protocolPluginType property which will be used
90             // by SAL
91             props.put("protocolPluginType", "STUB");
92             c.setInterface(IPluginInReadService.class.getName(), props);
93         }
94
95         if (imp.equals(InventoryService.class)) {
96             // export the service to be used by SAL
97             Dictionary<String, Object> props = new Hashtable<String, Object>();
98             // Set the protocolPluginType property which will be used
99             // by SAL
100             props.put("protocolPluginType", "STUB");
101             c.setInterface(IPluginInInventoryService.class.getName(), props);
102         }
103     }
104 }