Initial Netty + JSON Deserializer + all the enhancements happening in many private...
[ovsdb.git] / ovsdb / src / main / java / org / opendaylight / ovsdb / internal / Activator.java
1 package org.opendaylight.ovsdb.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.networkconfig.bridgedomain.IPluginInBridgeDomainConfigService;
9 import org.opendaylight.controller.sal.connection.IPluginInConnectionService;
10 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
11 import org.opendaylight.controller.sal.utils.INodeConnectorFactory;
12 import org.opendaylight.controller.sal.utils.INodeFactory;
13 import org.opendaylight.controller.sal.core.Node;
14 import org.opendaylight.controller.sal.core.NodeConnector;
15 import org.opendaylight.controller.sal.flowprogrammer.IPluginInFlowProgrammerService;
16 import org.opendaylight.controller.sal.utils.GlobalConstants;
17
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
20
21 /**
22  * OVSDB protocol plugin Activator
23  *
24  *
25  */
26 public class Activator extends ComponentActivatorAbstractBase {
27     protected static final Logger logger = LoggerFactory
28             .getLogger(Activator.class);
29
30     /**
31      * Function called when the activator starts just after some initializations
32      * are done by the ComponentActivatorAbstractBase.
33      * Here it registers the node Type
34      *
35      */
36     public void init() {
37         Node.NodeIDType.registerIDType("OVS", String.class);
38         NodeConnector.NodeConnectorIDType.registerIDType("OVS", String.class, "OVS");
39     }
40
41     /**
42      * Function called when the activator stops just before the cleanup done by
43      * ComponentActivatorAbstractBase
44      *
45      */
46     public void destroy() {
47         Node.NodeIDType.unRegisterIDType("OVS");
48         NodeConnector.NodeConnectorIDType.unRegisterIDType("OVS");
49     }
50     public Object[] getGlobalImplementations() {
51         Object[] res = { ConnectionService.class, ConfigurationService.class, NodeFactory.class, NodeConnectorFactory.class };
52         return res;
53     }
54
55     public void configureGlobalInstance(Component c, Object imp){
56         if (imp.equals(ConfigurationService.class)) {
57             // export the service to be used by SAL
58             Dictionary<String, Object> props = new Hashtable<String, Object>();
59             // Set the protocolPluginType property which will be used
60             // by SAL
61             props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "OVS");
62             c.setInterface(IPluginInBridgeDomainConfigService.class.getName(), props);
63
64             c.add(createServiceDependency()
65                     .setService(IConnectionServiceInternal.class)
66                     .setCallbacks("setConnectionServiceInternal", "unsetConnectionServiceInternal")
67                     .setRequired(true));
68         }
69
70         if (imp.equals(ConnectionService.class)) {
71             // export the service to be used by SAL
72             Dictionary<String, Object> props = new Hashtable<String, Object>();
73             // Set the protocolPluginType property which will be used
74             // by SAL
75             props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "OVS");
76             c.setInterface(
77                     new String[] {IPluginInConnectionService.class.getName(),
78                                   IConnectionServiceInternal.class.getName()}, props);
79         }
80
81         if (imp.equals(NodeFactory.class)) {
82             // export the service to be used by SAL
83             Dictionary<String, Object> props = new Hashtable<String, Object>();
84             // Set the protocolPluginType property which will be used
85             // by SAL
86             props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "OVS");
87             props.put("protocolName", "OVS");
88             c.setInterface(INodeFactory.class.getName(), props);
89         }
90         if (imp.equals(NodeConnectorFactory.class)) {
91             // export the service to be used by SAL
92             Dictionary<String, Object> props = new Hashtable<String, Object>();
93             // Set the protocolPluginType property which will be used
94             // by SAL
95             props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "OVS");
96             props.put("protocolName", "OVS");
97             c.setInterface(INodeConnectorFactory.class.getName(), props);
98         }
99
100     }
101 }